1
0
mirror of https://github.com/MrDetonia/Maki.git synced 2024-11-26 04:57:18 -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" name = "Maki"
# bot version # bot version
version = "v0.12.1" version = "v0.12.2"
# text shown by .help command # text shown by .help command
helptext = """I am a bot written in Python by MrDetonia 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 # this instance of the Discord client
client = discord.Client() client = discord.Client()
# are we running?
run = True
# logging setup # logging setup
logger = logging.getLogger('discord') logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
@ -206,6 +209,7 @@ def on_message(message):
if message.author.id in admins: if message.author.id in admins:
# exit discord and kill bot # exit discord and kill bot
print('INFO: Accepting .die from ' + message.author.name) print('INFO: Accepting .die from ' + message.author.name)
run = False
yield from client.send_message(message.channel, 'But will I dream? ;_;') yield from client.send_message(message.channel, 'But will I dream? ;_;')
yield from client.logout() yield from client.logout()
else: else:
@ -345,4 +349,15 @@ def on_message(message):
# Run the client # 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)