Added youtube and image search
Showing
4 changed files
with
43 additions
and
3 deletions
1 | {"Rui": {"Everybody": {"delivery_time": "2015/12/04 00:00:00", "message": "You are a faggot", "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"}}, "<@49237234515181568>": {"<@47934670406422528>": {"delivery_time": "2047/08/11 18:39:12", "message": "ur a fgt", "user_id": "49237234515181568", "channel": "47934985176354816"}}, "<@78767557628133376>": {"<@47934670406422528>": {"delivery_time": "2015/12/04 00:00:00", "message": "I'm gay", "user_id": "78767557628133376", "channel": "47934985176354816"}}, "<@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 |
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 | ["あなたのガールフレンドは、あなたの後ろの大きな黒い男とセックスを持っているし、それは非常に楽しんでいます。あなたは3年後、彼女はあなたが仕事であったが、それは毎日起こっている明らかにし、その時点でアウトになるまで見つけることができません。あなたはそこに彼女のためにされていないことをお詫びし、あなたと結婚するために彼女をお願いします。 wwwwwww", "Your future is looking grim, consider purchasing Fallout 4™", "あなたのガールフレンドは、あなたの後ろの大きな黒い男とセックスを持っているし、それは非常に楽しんでいます。あなたは3年後、彼女はあなたが仕事であったが、それは毎日起こっている明らかにし、その時点でアウトになるまで見つけることができません。あなたはそこに彼女のためにされていないことをお詫びし、あなたと結婚するために彼女をお願いします。 wwwwwww", "You are being cucked as you are reading this.", "In a world of immigration, censorship and equality... You are being cucked.", "Bright future, white future.", "Fortune Not Found: Abort, Retry, Ignore?", "Now would be a good time to get cucked.", "Come back later... I am sleeping.", "http://cdn.memegenerator.net/instances/400x/12009294.jpg", "Your Allagan Cane will drop next run.", "Your Allagan Cane will never drop.", "http://puu.sh/lFYCG/7f0cfb0004.jpg", "You could not be less interesting, but you are going to keep trying -- right?", "Xorfos will get his Dreadwyrm Axe someday.", "Reminder that Rui never beat Turn 13.", "Fallout 4 will win TGA 2015", "You will get a big fat futa cock up your ass soon.", "Your current problems will only get worse.", "Your cuck shed will see lots of activity in the near future.", "To do great things is difficult; but for you, it is impossible.", "When people tell you that you can't do something, they are probably right.", "There are now 23 nicknames going around for you; None of them are flattering. Tonight you're getting another one.", "Undertale will win TGA 2015", "You are going to develop http://puu.sh/lGFdS/71d497e8e8.gif", "You will go blind and your penis will shrivel by next week, but all can be prevented by inviting your friends & family to use Discord!", "Fortune smiles upon you! Goshzilla will be receiving his BBC into his ass shortly -- AND YOU GOT FRONT ROW SEAT.", "Miss Fortune demands that you play this http://store.steampowered.com/app/418010/", "I foresee fapping in your near future! http://puu.sh/lHdZn/aa737a5846.jpg", "Everything will be fire.", "Good bombings and many refugees will come to you but only if you post \"HILLARY 2016\" in this chat."] | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | ["あなたのガールフレンドは、あなたの後ろの大きな黒い男とセックスを持っているし、それは非常に楽しんでいます。あなたは3年後、彼女はあなたが仕事であったが、それは毎日起こっている明らかにし、その時点でアウトになるまで見つけることができません。あなたはそこに彼女のためにされていないことをお詫びし、あなたと結婚するために彼女をお願いします。 wwwwwww", "Your future is looking grim, consider purchasing Fallout 4™", "あなたのガールフレンドは、あなたの後ろの大きな黒い男とセックスを持っているし、それは非常に楽しんでいます。あなたは3年後、彼女はあなたが仕事であったが、それは毎日起こっている明らかにし、その時点でアウトになるまで見つけることができません。あなたはそこに彼女のためにされていないことをお詫びし、あなたと結婚するために彼女をお願いします。 wwwwwww", "You are being cucked as you are reading this.", "In a world of immigration, censorship and equality... You are being cucked.", "Bright future, white future.", "Fortune Not Found: Abort, Retry, Ignore?", "Now would be a good time to get cucked.", "Come back later... I am sleeping.", "http://cdn.memegenerator.net/instances/400x/12009294.jpg", "Your Allagan Cane will drop next run.", "Your Allagan Cane will never drop.", "http://puu.sh/lFYCG/7f0cfb0004.jpg", "You could not be less interesting, but you are going to keep trying -- right?", "Xorfos will get his Dreadwyrm Axe someday.", "Reminder that Rui never beat Turn 13.", "Fallout 4 will win TGA 2015", "You will get a big fat futa cock up your ass soon.", "Your current problems will only get worse.", "Your cuck shed will see lots of activity in the near future.", "To do great things is difficult; but for you, it is impossible.", "When people tell you that you can't do something, they are probably right.", "There are now 23 nicknames going around for you; None of them are flattering. Tonight you're getting another one.", "Undertale will win TGA 2015", "You are going to develop http://puu.sh/lGFdS/71d497e8e8.gif", "You will go blind and your penis will shrivel by next week, but all can be prevented by inviting your friends & family to use Discord!", "Fortune smiles upon you! Goshzilla will be receiving his BBC into his ass shortly -- AND YOU GOT FRONT ROW SEAT.", "Miss Fortune demands that you play this http://store.steampowered.com/app/418010/", "Everything will be fire.", "Good bombings and many refugees will come to you but only if you post \"HILLARY 2016\" in this chat.", "You will marry 3dpd and have many ugly children. http://i.imgur.com/uNSz7B7.jpg"] | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -2,6 +2,10 @@ import requests | ... | @@ -2,6 +2,10 @@ import requests |
2 | import discord | 2 | import discord |
3 | import random | 3 | import random |
4 | import datetime | 4 | import datetime |
5 | import re | ||
6 | |||
7 | #import urllib.parse | ||
8 | |||
5 | from dateutil.parser import parse | 9 | from dateutil.parser import parse |
6 | 10 | ||
7 | from discord.object import Object | 11 | from discord.object import Object |
... | @@ -37,6 +41,30 @@ def byteify(input): | ... | @@ -37,6 +41,30 @@ def byteify(input): |
37 | else: | 41 | else: |
38 | return input | 42 | return input |
39 | 43 | ||
44 | def search_youtube(query): | ||
45 | query_string = {"search_query" : query} | ||
46 | r = requests.get("http://www.youtube.com/results", params=query_string) | ||
47 | search_results = re.findall(r'href=\"\/watch\?v=(.{11})', r.content) | ||
48 | print("http://www.youtube.com/watch?v=" + search_results[0]) | ||
49 | return "http://www.youtube.com/watch?v=" + search_results[0] | ||
50 | |||
51 | def search_google_images(query): | ||
52 | 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} | ||
54 | |||
55 | r = requests.get("http://www.google.com/search", params=query_string, headers=headers) | ||
56 | |||
57 | start_idx = r.content.find('imgurl=') + 7 | ||
58 | if start_idx > 0: | ||
59 | search_result = r.content[start_idx:r.content.find('&', start_idx)] | ||
60 | if '/revision/' in search_result: | ||
61 | search_result = search_result[:search_result.find('/revision/')] | ||
62 | if '%' in search_result: | ||
63 | search_result = search_result[:search_result.find('%')] | ||
64 | print(search_result) | ||
65 | return search_result | ||
66 | return "boo you fail.." | ||
67 | |||
40 | @client.event | 68 | @client.event |
41 | def on_socket_raw_send(payload, binary=False): | 69 | def on_socket_raw_send(payload, binary=False): |
42 | check_msg_queue() | 70 | check_msg_queue() |
... | @@ -199,7 +227,9 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a | ... | @@ -199,7 +227,9 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a |
199 | !whoplayed <gamename> - Returns a list of players who have played the game. | 227 | !whoplayed <gamename> - Returns a list of players who have played the game. |
200 | !lastseen <username> - Returns info on when the user was last seen and their status. | 228 | !lastseen <username> - Returns info on when the user was last seen and their status. |
201 | !addfortune <fortune> - Adds a new fortune. | 229 | !addfortune <fortune> - Adds a new fortune. |
202 | !fortune - Returns your fortune | 230 | !fortune - Returns your fortune. |
231 | !youtube <search term> - Returns the first video from the search results for the search term. | ||
232 | !image <search term> - Returns the first image from the search results. | ||
203 | !secret | 233 | !secret |
204 | !bemyirlwaifu""".format(message.author.mention())) | 234 | !bemyirlwaifu""".format(message.author.mention())) |
205 | return | 235 | return |
... | @@ -232,6 +262,16 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a | ... | @@ -232,6 +262,16 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a |
232 | else: | 262 | else: |
233 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) | 263 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) |
234 | 264 | ||
265 | if message.content.startswith('!youtube'): | ||
266 | query = message.content[9:] | ||
267 | client.send_message(message.channel, search_youtube(query)) | ||
268 | return | ||
269 | |||
270 | if message.content.startswith('!image'): | ||
271 | query = message.content[7:] | ||
272 | client.send_message(message.channel, search_google_images(query)) | ||
273 | return | ||
274 | |||
235 | if message.content.startswith('!gameslist'): | 275 | if message.content.startswith('!gameslist'): |
236 | data = None | 276 | data = None |
237 | try: | 277 | try: | ... | ... |
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment