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
import logging
def byteify(input):
if isinstance(input, dict):
return {byteify(key): byteify(value) for key, value in input.iteritems()}
elif isinstance(input, list):
return [byteify(element) for element in input]
elif isinstance(input, unicode):
return input.encode('utf-8')
else:
return input
def log(message):
try:
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',
'HILLARY 2016': 'do_hillary',
'!squid': 'do_squid',
'!stars': 'do_stars',
'!rigged': 'do_rigged',
}
......@@ -282,6 +283,7 @@ Stuff:
!roll <1d20> - Roll X number of dice of size X. 1d20 returns 1 roll 1-20. 3d6 returns 3 rolls of 1-6 etc...
!secret
!shutup - disables all image / gif / youtube spam for 5 minutes
!rigged - Cause Study is no good at betting.
!bemyirlwaifu""".format(message.author.mention()))
......@@ -485,7 +487,7 @@ def do_startraffle(client, message_parts, message):
for key, value in raffles.iteritems():
if value['current'] == 1:
title = value['title']
key = value['key']
game_key = value['key']
if 'dlc' in value:
dlc = value['dlc']
......@@ -508,7 +510,7 @@ def do_startraffle(client, message_parts, message):
for member in client.get_all_members():
log(member.id)
if member.id == '78767557628133376':
priv_message = "1st: {} key: {}\n2nd: {} keys: {}\n3rd: {} keys: {}".format(byteify(winner), key, byteify(second), ' '.join(random_keys[0:2]), byteify(third), random_keys[3])
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])
log(priv_message)
client.send_message(member, priv_message)
......@@ -1009,6 +1011,13 @@ def do_stars(client, message_parts, message):
client.send_message(message.channel, '✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈  ✮═━┈  ✰═━┈ ✰═━┈┈ ✰═━┈┈')
return
def do_rigged(client, message_parts, message):
lines = open('studylyrics.txt').read().splitlines()
client.send_message(message.channel, ":musical_note: {} :musical_note:".format(random.choice(lines)))
return
def thread_exception_handler(method, client, message_parts, message):
try:
globals()[method](client, message_parts[1:], message)
......