forked from iethree/wan-party-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·38 lines (26 loc) · 912 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python3
import sqlite3
import os
import discord
import message_handler as mh
import subprocess as sub
from commands import bot
from tables import initiate_tables
initiate_tables()
@bot.event
async def on_ready():
print("we have logged in as {0.user}".format(bot))
commit = sub.run("git log -1 --pretty=%B".split(), stdout=sub.PIPE)
env = sub.run("hostname".split(), stdout=sub.PIPE)
status_info = env.stdout.decode("utf-8") + " | " + commit.stdout.decode("utf-8")
await bot.change_presence(activity=discord.Game(status_info))
@bot.event
async def on_message(message):
if message.author == bot.user:
return
print(message.author.display_name + ": " + message.content)
await bot.process_commands(message)
response = await mh.respond_to(bot, message)
if response:
await message.channel.send(response)
bot.run(os.getenv("DISCORD_TOKEN"))