-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (29 loc) · 893 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
39
40
import os
import discord
try:
from core import business
from core import command
FATAL_STATE = False
except:
FATAL_STATE = True
TOKEN = os.getenv('DISCORD_TOKEN')
class Client(discord.Client):
async def on_ready(self) -> None:
pass
async def on_message(self, message) -> None:
if message.author == self.user:
return
if FATAL_STATE:
await message.reply('Критическая ошибка(')
return
try:
cmd = command.parse(message.content)
if cmd is not None:
answer = cmd.run(business.Context())
await message.reply(answer)
except business.LogicError as exc:
await message.reply(str(exc))
except:
await message.reply('Я сломался(')
if __name__ == '__main__':
Client().run(TOKEN)