6c38afa3 by Barry

Fixed whoplayed.

1 parent 8c05f710
No preview for this file type
......@@ -24,8 +24,8 @@ conn = sqlite3.connect('db.sqlite3')
member_status = 'members.json'
deliveries_file = 'deliveries.json'
fortune_file = 'fortunes.json'
joke_file = 'jokes.json'
# fortune_file = 'fortunes.json'
# joke_file = 'jokes.json'
games_file = 'games.json'
credentials = 'creds.json'
......@@ -475,16 +475,19 @@ Stuff:
for game in data:
if game['name'].lower() == game_name.lower():
game_id = game['id']
if game_id == 0:
client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(game_name, message.author.mention()))
return
#if game_id == 0:
# #client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(game_name, message.author.mention()))
# #return
matched_usernames = []
for username in member_data:
if 'games_played' in member_data[username]:
for id in member_data[username]['games_played']:
if id == game_id or id == game_name:
if id == game_name or (id == game_id and game_id != 0):
matched_usernames.append(username)
client.send_message(message.channel, 'I have seen {} playing: {}'.format(', '.join(matched_usernames), game_name))
if len(matched_usernames) == 0:
client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(game_name, message.author.mention()))
else:
client.send_message(message.channel, 'I have seen {} playing: {}'.format(', '.join(matched_usernames), game_name))
return
# !msg joe in 5 minutes YOU ARE A DICK
......@@ -558,39 +561,36 @@ Stuff:
if message.content.startswith('!addfortune'):
try:
json_data=open(fortune_file).read()
data = json.loads(json_data)
except ValueError:
data = []
if not data:
data = []
try:
if 'aa737a5846' in message.content[12:]:
fortune = message.content[9:]
if 'aa737a5846' in fortune:
client.send_message(message.channel, '{} you stop it, you are a pedofile, stop looking at little girls.'.format(message.author.mention()))
return
data.append(byteify(message.content[12:]))
jdata = json.dumps(data, ensure_ascii=False)
date_added = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')
c = conn.cursor()
c.execute("INSERT INTO fortunes (fortune, date_added) VALUES (?, ?)", (fortune, date_added))
conn.commit()
print("Added fortune")
except Exception as e:
print e.message
client.send_message(message.channel, 'Your shitty fortune has been rejected {}.'.format(message.author.mention()))
return
open(fortune_file, 'wb+').write(jdata.encode('utf8'))
client.send_message(message.channel, 'Your shitty fortune has been added {}.'.format(message.author.mention()))
return
if message.content.startswith('!fortune'):
data = None
fortune = None
try:
json_data=open(fortune_file).read()
data = json.loads(json_data)
except ValueError:
c = conn.cursor()
fortune = c.execute("SELECT fortune FROM fortunes ORDER BY RANDOM() LIMIT 1;").fetchone()[0]
print(fortune)
except Exception as e:
print(e)
pass
if not data:
client.send_message(message.channel, 'Try adding a fortune with "!addfortune <fortune>" {}!'.format(message.author.mention()))
if not fortune:
client.send_message(message.channel, 'Try adding a fortune with "!addfortune <fortune>" {}!'.format(message.author.mention()))
else:
client.send_message(message.channel, '{} Your fortune is... {}'.format(message.author.mention(), random.choice(data).encode('utf-8',errors='ignore')))
client.send_message(message.channel, '{} Your fortune is... {}'.format(message.author.mention(), byteify(fortune)))
return
if message.content.startswith('!question'):
question = message.content[10:]
......