2639440f by Barry

db update plus alias addition.

1 parent e3ae2f60
{"<@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
{"<@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
......
......@@ -4,8 +4,6 @@ import random
import datetime
import re
#import urllib.parse
from dateutil.parser import parse
from discord.object import Object
......@@ -48,9 +46,11 @@ def search_youtube(query):
print("http://www.youtube.com/watch?v=" + search_results[0])
return "http://www.youtube.com/watch?v=" + search_results[0]
def search_google_images(query):
def search_google_images(query, animated=False):
headers = {'User-Agent': "Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20100101 Firefox/12.0"}
query_string = {"safe": "off", "tbm": "isch", "q" : query}
if animated:
query_string = {"safe": "off", "tbm": "isch", "q" : query, 'tbs': 'itp:animated'}
r = requests.get("http://www.google.com/search", params=query_string, headers=headers)
......@@ -121,7 +121,8 @@ def on_status(member):
'prev_status': prev_status,
'status_change_at': status_change_at,
'game_id': game_id,
'games_played': games_played
'games_played': games_played,
'aliases': []
}
print('Status Change: %s' % (data,))
jdata = json.dumps(data, ensure_ascii=False)
......@@ -218,6 +219,8 @@ def on_message(message):
client.send_message(message.channel,
"""{} Available Commands:
You can ask compound or questions and I will choose. Example: HellsBot Rui is a Faggot or Rui is a faggot?
!aliases - Returns a list of all aliases a user has set for themselves.
!addalias <alias> - Adds an alias to your list of aliases.
!msg <username> in 5 minutes Tea is ready
!msg <username> in 45 seconds Your finished masterbating
!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
!addfortune <fortune> - Adds a new fortune.
!fortune - Returns your fortune.
!youtube <search term> - Returns the first video from the search results for the search term.
!gif <search term> - Returns the first gif from the search results.
!image <search term> - Returns the first image from the search results.
!secret
!bemyirlwaifu""".format(message.author.mention()))
......@@ -272,6 +276,11 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
client.send_message(message.channel, search_google_images(query))
return
if message.content.startswith('!gif'):
query = message.content[7:]
client.send_message(message.channel, search_google_images(query, True))
return
if message.content.startswith('!gameslist'):
data = None
try:
......@@ -299,6 +308,44 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
client.send_message(message.channel, 'The games I have seen people playing are: \n{}'.format(out_string))
return
if message.content.startswith('!aliases'):
data = None
try:
json_data=open(member_status).read()
data = json.loads(json_data)
except ValueError:
pass
if not data:
client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
else:
username = message.content[9:].replace('@', '').lower()
if username in data and 'aliases' in data[username]:
client.send_message(message.channel, '{} has the following aliases:'.format(username, ', '.join(data[username]['aliases'])))
else:
client.send_message(message.channel, 'No known alises for {} yet {}'.format(username, message.author.mention()))
return
if message.content.startswith('!addalias'):
data = None
try:
json_data=open(member_status).read()
data = json.loads(json_data)
except ValueError:
pass
if not data:
client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
else:
alias = message.content[10:]
username = message.author.name.lower()
if username in data:
if 'aliases' not in data[username]:
data[username]['aliases'] = []
data[username]['aliases'].append(alias)
client.send_message(message.channel, '{} has been added to your aliases'.format(alias))
else:
client.send_message(message.channel, 'Something horrible happened and it is all your fault.')
return
if message.content.startswith('!games'):
data = None
try:
......