This repository has been archived by the owner on Dec 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
executable file
·75 lines (64 loc) · 1.87 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import discord
import asyncio
from handlers import message_handler
from handlers import reaction_handler
from handlers import invasion_handler
import config
import time
import traceback
from raven import Client as ravenClient
enable_error_reports = False
if config.sentry_dsn is not '':
errorReporter = ravenClient(config.sentry_dsn)
enable_error_reports = True
client = discord.Client()
MessageHandler = message_handler.MessageHandler(client)
ReactionHandler = reaction_handler.ReactionHandler(client)
InvasionHandler = invasion_handler.InvasionHandler(client)
@client.event
async def invtracker():
try:
await client.wait_until_ready()
await InvasionHandler.tracker()
except:
if enable_error_reports:
errorReporter.captureException()
print(traceback.format_exc())
@client.event
async def stracker():
try:
await client.wait_until_ready()
await InvasionHandler.statustracker()
except:
if enable_error_reports:
errorReporter.captureException()
print(traceback.format_exc())
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
try:
await MessageHandler.on_message(message)
except:
if enable_error_reports:
errorReporter.captureException()
print(traceback.format_exc())
@client.event
async def on_reaction_add(reaction, user):
await ReactionHandler.on_reaction_add(reaction, user)
def Main():
try:
client.loop.create_task(invtracker())
client.loop.create_task(stracker())
client.run(config.discord_token)
except:
if enable_error_reports:
errorReporter.captureException()
print(traceback.format_exc())
time.sleep(3)
if __name__ == '__main__':
Main()