2639440f by Barry

db update plus alias addition.

1 parent e3ae2f60
1 {"<@49237234515181568>": {"<@47934670406422528>": {"delivery_time": "2047/08/11 18:39:12", "message": "ur a fgt", "user_id": "49237234515181568", "channel": "47934985176354816"}}, "<@121404665727418368>": {"<@47934670406422528>": {"delivery_time": "2016/12/02 16:54:33", "message": "I'm gay.", "user_id": "121404665727418368", "channel": "47934985176354816"}}, "<@47934670406422528>": {"<@78767557628133376>": {"delivery_time": "2015/12/25 00:00:00", "message": "Merry Fucking Christmas You Asian Jew", "user_id": "47934670406422528", "channel": "47934985176354816"}}, "<@48148712194576384>": {"<@121404665727418368>": {"delivery_time": "2019/02/03 02:38:24", "message": "u gay", "user_id": "48148712194576384", "channel": "47934985176354816"}}, "<@63649222993391616>": {"<@121404665727418368>": {"delivery_time": "2015/12/10 16:57:52", "message": "fuck off spic", "user_id": "63649222993391616", "channel": "47934985176354816"}}}
...\ No newline at end of file ...\ No newline at end of file
1 {"<@47934670406422528>": {"<@78767557628133376>": {"delivery_time": "2015/12/25 00:00:00", "message": "Merry Fucking Christmas You Asian Jew", "user_id": "47934670406422528", "channel": "47934985176354816"}}, "<@48148712194576384>": {"<@121404665727418368>": {"delivery_time": "2019/02/03 02:38:24", "message": "u gay", "user_id": "48148712194576384", "channel": "47934985176354816"}}, "<@49237234515181568>": {"<@47934670406422528>": {"delivery_time": "2047/08/11 18:39:12", "message": "ur a fgt", "user_id": "49237234515181568", "channel": "47934985176354816"}}, "<@78767557628133376>": {"<@78767557628133376>": {"delivery_time": "2015/12/22 00:00:00", "message": "happy birthday eli", "user_id": "78767557628133376", "channel": "121370073465094146"}}, "<@121404665727418368>": {"<@47934670406422528>": {"delivery_time": "2016/12/02 16:54:33", "message": "I'm gay.", "user_id": "121404665727418368", "channel": "47934985176354816"}}, "<@63649222993391616>": {"<@121404665727418368>": {"delivery_time": "2015/12/10 16:57:52", "message": "fuck off spic", "user_id": "63649222993391616", "channel": "47934985176354816"}}}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,8 +4,6 @@ import random ...@@ -4,8 +4,6 @@ import random
4 import datetime 4 import datetime
5 import re 5 import re
6 6
7 #import urllib.parse
8
9 from dateutil.parser import parse 7 from dateutil.parser import parse
10 8
11 from discord.object import Object 9 from discord.object import Object
...@@ -48,9 +46,11 @@ def search_youtube(query): ...@@ -48,9 +46,11 @@ def search_youtube(query):
48 print("http://www.youtube.com/watch?v=" + search_results[0]) 46 print("http://www.youtube.com/watch?v=" + search_results[0])
49 return "http://www.youtube.com/watch?v=" + search_results[0] 47 return "http://www.youtube.com/watch?v=" + search_results[0]
50 48
51 def search_google_images(query): 49 def search_google_images(query, animated=False):
52 headers = {'User-Agent': "Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20100101 Firefox/12.0"} 50 headers = {'User-Agent': "Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20100101 Firefox/12.0"}
53 query_string = {"safe": "off", "tbm": "isch", "q" : query} 51 query_string = {"safe": "off", "tbm": "isch", "q" : query}
52 if animated:
53 query_string = {"safe": "off", "tbm": "isch", "q" : query, 'tbs': 'itp:animated'}
54 54
55 r = requests.get("http://www.google.com/search", params=query_string, headers=headers) 55 r = requests.get("http://www.google.com/search", params=query_string, headers=headers)
56 56
...@@ -121,7 +121,8 @@ def on_status(member): ...@@ -121,7 +121,8 @@ def on_status(member):
121 'prev_status': prev_status, 121 'prev_status': prev_status,
122 'status_change_at': status_change_at, 122 'status_change_at': status_change_at,
123 'game_id': game_id, 123 'game_id': game_id,
124 'games_played': games_played 124 'games_played': games_played,
125 'aliases': []
125 } 126 }
126 print('Status Change: %s' % (data,)) 127 print('Status Change: %s' % (data,))
127 jdata = json.dumps(data, ensure_ascii=False) 128 jdata = json.dumps(data, ensure_ascii=False)
...@@ -218,6 +219,8 @@ def on_message(message): ...@@ -218,6 +219,8 @@ def on_message(message):
218 client.send_message(message.channel, 219 client.send_message(message.channel,
219 """{} Available Commands: 220 """{} Available Commands:
220 You can ask compound or questions and I will choose. Example: HellsBot Rui is a Faggot or Rui is a faggot? 221 You can ask compound or questions and I will choose. Example: HellsBot Rui is a Faggot or Rui is a faggot?
222 !aliases - Returns a list of all aliases a user has set for themselves.
223 !addalias <alias> - Adds an alias to your list of aliases.
221 !msg <username> in 5 minutes Tea is ready 224 !msg <username> in 5 minutes Tea is ready
222 !msg <username> in 45 seconds Your finished masterbating 225 !msg <username> in 45 seconds Your finished masterbating
223 !msg <username> in 2 hours The movie is over 226 !msg <username> in 2 hours The movie is over
...@@ -229,6 +232,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a ...@@ -229,6 +232,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
229 !addfortune <fortune> - Adds a new fortune. 232 !addfortune <fortune> - Adds a new fortune.
230 !fortune - Returns your fortune. 233 !fortune - Returns your fortune.
231 !youtube <search term> - Returns the first video from the search results for the search term. 234 !youtube <search term> - Returns the first video from the search results for the search term.
235 !gif <search term> - Returns the first gif from the search results.
232 !image <search term> - Returns the first image from the search results. 236 !image <search term> - Returns the first image from the search results.
233 !secret 237 !secret
234 !bemyirlwaifu""".format(message.author.mention())) 238 !bemyirlwaifu""".format(message.author.mention()))
...@@ -272,6 +276,11 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a ...@@ -272,6 +276,11 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
272 client.send_message(message.channel, search_google_images(query)) 276 client.send_message(message.channel, search_google_images(query))
273 return 277 return
274 278
279 if message.content.startswith('!gif'):
280 query = message.content[7:]
281 client.send_message(message.channel, search_google_images(query, True))
282 return
283
275 if message.content.startswith('!gameslist'): 284 if message.content.startswith('!gameslist'):
276 data = None 285 data = None
277 try: 286 try:
...@@ -299,6 +308,44 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a ...@@ -299,6 +308,44 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
299 client.send_message(message.channel, 'The games I have seen people playing are: \n{}'.format(out_string)) 308 client.send_message(message.channel, 'The games I have seen people playing are: \n{}'.format(out_string))
300 return 309 return
301 310
311 if message.content.startswith('!aliases'):
312 data = None
313 try:
314 json_data=open(member_status).read()
315 data = json.loads(json_data)
316 except ValueError:
317 pass
318 if not data:
319 client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
320 else:
321 username = message.content[9:].replace('@', '').lower()
322 if username in data and 'aliases' in data[username]:
323 client.send_message(message.channel, '{} has the following aliases:'.format(username, ', '.join(data[username]['aliases'])))
324 else:
325 client.send_message(message.channel, 'No known alises for {} yet {}'.format(username, message.author.mention()))
326 return
327
328 if message.content.startswith('!addalias'):
329 data = None
330 try:
331 json_data=open(member_status).read()
332 data = json.loads(json_data)
333 except ValueError:
334 pass
335 if not data:
336 client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
337 else:
338 alias = message.content[10:]
339 username = message.author.name.lower()
340 if username in data:
341 if 'aliases' not in data[username]:
342 data[username]['aliases'] = []
343 data[username]['aliases'].append(alias)
344 client.send_message(message.channel, '{} has been added to your aliases'.format(alias))
345 else:
346 client.send_message(message.channel, 'Something horrible happened and it is all your fault.')
347 return
348
302 if message.content.startswith('!games'): 349 if message.content.startswith('!games'):
303 data = None 350 data = None
304 try: 351 try:
......