ee471b2d by Barry

Bug fix for logging in data.

Added some dumb shit to the bot for Study.
1 parent 19159d19
...@@ -4,6 +4,17 @@ import datetime ...@@ -4,6 +4,17 @@ import datetime
4 import logging 4 import logging
5 5
6 6
7 def byteify(input):
8 if isinstance(input, dict):
9 return {byteify(key): byteify(value) for key, value in input.iteritems()}
10 elif isinstance(input, list):
11 return [byteify(element) for element in input]
12 elif isinstance(input, unicode):
13 return input.encode('utf-8')
14 else:
15 return input
16
17
7 def log(message): 18 def log(message):
8 try: 19 try:
9 logging.warning("{} - {}".format(datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), message)) 20 logging.warning("{} - {}".format(datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), message))
......
No preview for this file type
...@@ -77,6 +77,7 @@ registered_commands = {'!help': 'do_help', '!commands': 'do_help', ...@@ -77,6 +77,7 @@ registered_commands = {'!help': 'do_help', '!commands': 'do_help',
77 'HILLARY 2016': 'do_hillary', 77 'HILLARY 2016': 'do_hillary',
78 '!squid': 'do_squid', 78 '!squid': 'do_squid',
79 '!stars': 'do_stars', 79 '!stars': 'do_stars',
80 '!rigged': 'do_rigged',
80 } 81 }
81 82
82 83
...@@ -282,6 +283,7 @@ Stuff: ...@@ -282,6 +283,7 @@ Stuff:
282 !roll <1d20> - Roll X number of dice of size X. 1d20 returns 1 roll 1-20. 3d6 returns 3 rolls of 1-6 etc... 283 !roll <1d20> - Roll X number of dice of size X. 1d20 returns 1 roll 1-20. 3d6 returns 3 rolls of 1-6 etc...
283 !secret 284 !secret
284 !shutup - disables all image / gif / youtube spam for 5 minutes 285 !shutup - disables all image / gif / youtube spam for 5 minutes
286 !rigged - Cause Study is no good at betting.
285 !bemyirlwaifu""".format(message.author.mention())) 287 !bemyirlwaifu""".format(message.author.mention()))
286 288
287 289
...@@ -485,7 +487,7 @@ def do_startraffle(client, message_parts, message): ...@@ -485,7 +487,7 @@ def do_startraffle(client, message_parts, message):
485 for key, value in raffles.iteritems(): 487 for key, value in raffles.iteritems():
486 if value['current'] == 1: 488 if value['current'] == 1:
487 title = value['title'] 489 title = value['title']
488 key = value['key'] 490 game_key = value['key']
489 if 'dlc' in value: 491 if 'dlc' in value:
490 dlc = value['dlc'] 492 dlc = value['dlc']
491 493
...@@ -508,7 +510,7 @@ def do_startraffle(client, message_parts, message): ...@@ -508,7 +510,7 @@ def do_startraffle(client, message_parts, message):
508 for member in client.get_all_members(): 510 for member in client.get_all_members():
509 log(member.id) 511 log(member.id)
510 if member.id == '78767557628133376': 512 if member.id == '78767557628133376':
511 priv_message = "1st: {} key: {}\n2nd: {} keys: {}\n3rd: {} keys: {}".format(byteify(winner), key, byteify(second), ' '.join(random_keys[0:2]), byteify(third), random_keys[3]) 513 priv_message = "1st: {} key: {}\n2nd: {} keys: {}\n3rd: {} keys: {}".format(byteify(winner), game_key, byteify(second), ' '.join(random_keys[0:2]), byteify(third), random_keys[3])
512 log(priv_message) 514 log(priv_message)
513 client.send_message(member, priv_message) 515 client.send_message(member, priv_message)
514 516
...@@ -1009,6 +1011,13 @@ def do_stars(client, message_parts, message): ...@@ -1009,6 +1011,13 @@ def do_stars(client, message_parts, message):
1009 client.send_message(message.channel, '✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈ ✰═━┈┈ ✰═━┈┈') 1011 client.send_message(message.channel, '✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈ ✰═━┈┈ ✰═━┈┈')
1010 return 1012 return
1011 1013
1014
1015 def do_rigged(client, message_parts, message):
1016 lines = open('studylyrics.txt').read().splitlines()
1017 client.send_message(message.channel, ":musical_note: {} :musical_note:".format(random.choice(lines)))
1018 return
1019
1020
1012 def thread_exception_handler(method, client, message_parts, message): 1021 def thread_exception_handler(method, client, message_parts, message):
1013 try: 1022 try:
1014 globals()[method](client, message_parts[1:], message) 1023 globals()[method](client, message_parts[1:], message)
......