1
0
mirror of https://github.com/MrDetonia/Maki.git synced 2024-11-22 11:54:16 -05:00

Added exception handling and loop that stops Maki from dying on server errors, v0.12.2

This commit is contained in:
Zac Herd 2016-04-21 22:55:41 +01:00
parent 130b9b80d1
commit 74fa9d187a

19
bot.py
View File

@ -27,7 +27,7 @@ from secret import email,pwd
name = "Maki"
# bot version
version = "v0.12.1"
version = "v0.12.2"
# text shown by .help command
helptext = """I am a bot written in Python by MrDetonia
@ -88,6 +88,9 @@ if os.path.isfile('tells.json'):
# this instance of the Discord client
client = discord.Client()
# are we running?
run = True
# logging setup
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
@ -206,6 +209,7 @@ def on_message(message):
if message.author.id in admins:
# exit discord and kill bot
print('INFO: Accepting .die from ' + message.author.name)
run = False
yield from client.send_message(message.channel, 'But will I dream? ;_;')
yield from client.logout()
else:
@ -345,4 +349,15 @@ def on_message(message):
# Run the client
client.run(email, pwd)
while run:
try:
print('INFO: starting client')
client.run(email, pwd)
except:
print('ERROR: caught some exception')
continue
else:
break
# finish execution
exit(0)