Initial commit.
0 parents
Showing
6 changed files
with
214 additions
and
0 deletions
.gitignore
0 → 100644
1 | creds.json |
README.md
0 → 100644
File mode changed
fortunes.json
0 → 100644
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."] | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
games.json
0 → 100644
This diff is collapsed.
Click to expand it.
hellsbot.py
0 → 100644
1 | import requests | ||
2 | import discord | ||
3 | import random | ||
4 | import datetime | ||
5 | |||
6 | from ago import human | ||
7 | import simplejson as json | ||
8 | |||
9 | member_status = 'members.json' | ||
10 | fortune_file = 'fortunes.json' | ||
11 | games_file = 'games.json' | ||
12 | credentials = 'creds.json' | ||
13 | |||
14 | client = discord.Client() | ||
15 | |||
16 | json_data=open(credentials).read() | ||
17 | creds = json.loads(json_data) | ||
18 | client.login(creds['username'], creds['password']) | ||
19 | |||
20 | def byteify(input): | ||
21 | if isinstance(input, dict): | ||
22 | return {byteify(key):byteify(value) for key,value in input.iteritems()} | ||
23 | elif isinstance(input, list): | ||
24 | return [byteify(element) for element in input] | ||
25 | elif isinstance(input, unicode): | ||
26 | return input.encode('utf-8') | ||
27 | else: | ||
28 | return input | ||
29 | |||
30 | |||
31 | @client.event | ||
32 | def on_status(member): | ||
33 | print("Status Changed %s" % (member,)) | ||
34 | try: | ||
35 | json_data=open(member_status).read() | ||
36 | data = json.loads(json_data) | ||
37 | except ValueError: | ||
38 | data = {} | ||
39 | if not data: | ||
40 | data = {} | ||
41 | try: | ||
42 | username = member.name.lower() | ||
43 | if username in data: | ||
44 | is_afk = data[username]['is_afk'] | ||
45 | afk_at = data[username]['afk_at'] | ||
46 | status = data[username]['status'] | ||
47 | prev_status = data[username]['prev_status'] | ||
48 | status_change_at = data[username]['status_change_at'] | ||
49 | game_id = data[username]['game_id'] | ||
50 | games_played = data[username]['games_played'] | ||
51 | else: | ||
52 | is_afk = False | ||
53 | afk_at = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S') | ||
54 | status = 'online' | ||
55 | prev_status = 'offline' | ||
56 | status_change_at = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S') | ||
57 | game_id = None | ||
58 | games_played = [] | ||
59 | if member.status == 'idle': | ||
60 | afk_at = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S') | ||
61 | is_afk = True | ||
62 | else: | ||
63 | is_afk = False | ||
64 | if status != member.status: | ||
65 | prev_status = status | ||
66 | status = member.status | ||
67 | status_change_at = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S') | ||
68 | if game_id != member.game_id: | ||
69 | game_id = member.game_id | ||
70 | if game_id not in games_played: | ||
71 | games_played.append(game_id) | ||
72 | data[username] = { | ||
73 | 'is_afk': is_afk, | ||
74 | 'afk_at': afk_at, | ||
75 | 'status': status, | ||
76 | 'prev_status': prev_status, | ||
77 | 'status_change_at': status_change_at, | ||
78 | 'game_id': game_id, | ||
79 | 'games_played': games_played | ||
80 | } | ||
81 | print('Status Change: %s' % (data,)) | ||
82 | jdata = json.dumps(data, ensure_ascii=False) | ||
83 | except Exception as e: | ||
84 | print('Error saving status change: %s' % (e),) | ||
85 | return | ||
86 | |||
87 | open(member_status, 'wb+').write(jdata.encode('utf8')) | ||
88 | |||
89 | |||
90 | def get_game_names(game_id_list): | ||
91 | json_data=open(games_file).read() | ||
92 | data = json.loads(json_data) | ||
93 | result = [] | ||
94 | for game_id in game_id_list: | ||
95 | for game in data: | ||
96 | if game['id'] == game_id: | ||
97 | result.append(game['name']) | ||
98 | return result | ||
99 | |||
100 | @client.event | ||
101 | def on_message(message): | ||
102 | print message.content | ||
103 | print message.author | ||
104 | print client.user | ||
105 | # we do not want the bot to reply to itself | ||
106 | if message.author == client.user: | ||
107 | return | ||
108 | |||
109 | if message.content.lower().startswith(client.user.name.lower()): | ||
110 | print('Someone is talking to %s' % (client.user.name.lower(),)) | ||
111 | if ' or ' in message.content: | ||
112 | questions = message.content[len(client.user.name)+1:].replace('?', '').split(' or ') | ||
113 | client.send_message(message.channel, '{} I choose: {}'.format(message.author.mention(), random.choice(questions).encode('utf-8',errors='ignore'))) | ||
114 | |||
115 | |||
116 | if message.content.startswith('!help') or message.content.startswith('!commands'): | ||
117 | client.send_message(message.channel, '{} Available Commands:\nYou can ask compound or questions and I will choose. Example: HellsBot Rui is a Faggot or Rui is a faggot?\n!games <username> - Returns a list of games played\n!lastseen <username> - Returns info on when the user was last seen and their status\n!addfortune <fortune>\n!fortune\n!secret\n!bemyirlwaifu'.format(message.author.mention())) | ||
118 | return | ||
119 | |||
120 | if message.content.startswith('!lastseen'): | ||
121 | data = None | ||
122 | try: | ||
123 | json_data=open(member_status).read() | ||
124 | data = json.loads(json_data) | ||
125 | except ValueError: | ||
126 | pass | ||
127 | if not data: | ||
128 | client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention())) | ||
129 | else: | ||
130 | username = message.content[10:].replace('@', '').lower() | ||
131 | if username in data: | ||
132 | out_string = '' | ||
133 | if data[username]['is_afk'] == True: | ||
134 | out_string = 'Went AFK at: {}\n'.format(data[username]['afk_at']) | ||
135 | elif data[username]['status'] == 'offline': | ||
136 | out_string = 'Currently Offline\n' | ||
137 | else: | ||
138 | out_string = 'Currently Online\n' | ||
139 | out_string += 'Last Status: {} at {} which was {}\nPrevious Status: {}\n'.format(data[username]['status'], | ||
140 | data[username]['status_change_at'], | ||
141 | human(datetime.datetime.strptime(data[username]['status_change_at'], '%Y/%m/%d %H:%M:%S')), | ||
142 | data[username]['prev_status']) | ||
143 | |||
144 | client.send_message(message.channel, 'Last Information on {}:\n{}'.format(username, out_string)) | ||
145 | else: | ||
146 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) | ||
147 | |||
148 | if message.content.startswith('!games'): | ||
149 | data = None | ||
150 | try: | ||
151 | json_data=open(member_status).read() | ||
152 | data = json.loads(json_data) | ||
153 | except ValueError: | ||
154 | pass | ||
155 | if not data: | ||
156 | client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention())) | ||
157 | else: | ||
158 | username = message.content[7:].replace('@', '').lower() | ||
159 | if username in data: | ||
160 | games = ', '.join(get_game_names(data[username]['games_played'])) | ||
161 | client.send_message(message.channel, 'I have seen {} playing: {}'.format(username, games)) | ||
162 | else: | ||
163 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) | ||
164 | |||
165 | if message.content.startswith('!addfortune'): | ||
166 | try: | ||
167 | json_data=open(fortune_file).read() | ||
168 | data = json.loads(json_data) | ||
169 | except ValueError: | ||
170 | data = [] | ||
171 | if not data: | ||
172 | data = [] | ||
173 | try: | ||
174 | data.append(byteify(message.content[12:])) | ||
175 | jdata = json.dumps(data, ensure_ascii=False) | ||
176 | except: | ||
177 | client.send_message(message.channel, 'Your shitty fortune has been rejected {}.'.format(message.author.mention())) | ||
178 | return | ||
179 | |||
180 | open(fortune_file, 'wb+').write(jdata.encode('utf8')) | ||
181 | client.send_message(message.channel, 'Your shitty fortune has been added {}.'.format(message.author.mention())) | ||
182 | if message.content.startswith('!fortune'): | ||
183 | data = None | ||
184 | try: | ||
185 | json_data=open(fortune_file).read() | ||
186 | data = json.loads(json_data) | ||
187 | except ValueError: | ||
188 | pass | ||
189 | if not data: | ||
190 | client.send_message(message.channel, 'Try adding a fortune with "!addfortune <fortune>" {}!'.format(message.author.mention())) | ||
191 | else: | ||
192 | client.send_message(message.channel, '{} Your fortune is... {}'.format(message.author.mention(), random.choice(data).encode('utf-8',errors='ignore'))) | ||
193 | |||
194 | if message.content.startswith('!secret'): | ||
195 | client.send_message(message.channel, 'git gud {}!'.format(message.author.mention())) | ||
196 | |||
197 | if message.content.startswith('!bemyirlwaifu'): | ||
198 | client.send_message(message.channel, 'http://orig13.deviantart.net/b25e/f/2014/175/3/d/no_waifu_no_laifu_by_imtheonenexttome-d7nsx3b.gif {}!'.format(message.author.mention())) | ||
199 | |||
200 | |||
201 | if message.content.startswith('!hello'): | ||
202 | client.send_message(message.channel, 'Hello {}!'.format(message.author.mention())) | ||
203 | |||
204 | @client.event | ||
205 | def on_ready(): | ||
206 | print('Logged in as') | ||
207 | print(client.user.name) | ||
208 | print(client.user.id) | ||
209 | print('------') | ||
210 | |||
211 | client.run() | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
members.json
0 → 100644
1 | {"zan": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 02:06:08", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/03 02:06:08"}, "solidsteak": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 02:43:24", "prev_status": "online", "games_played": [248, null], "game_id": null, "afk_at": "2015/12/03 02:43:24"}, "sheik": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/02 22:02:12", "prev_status": "online", "games_played": [283, null], "game_id": null, "afk_at": "2015/12/02 22:02:12"}, "rae": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 00:51:10", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/03 00:51:10"}, "marion": {"status": "offline", "is_afk": false, "status_change_at": "2015/12/03 01:45:24", "prev_status": "online", "games_played": [1, null], "game_id": null, "afk_at": "2015/12/02 08:30:16"}, "shyrith": {"status": "online", "is_afk": false, "status_change_at": "2015/12/02 21:56:19", "prev_status": "idle", "games_played": [1, 644], "game_id": 644, "afk_at": "2015/12/02 21:54:35"}, "rui": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 01:46:23", "prev_status": "idle", "games_played": [], "game_id": null, "afk_at": "2015/12/03 01:35:09"}, "goshzilla": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 01:52:54", "prev_status": "idle", "games_played": [3, null], "game_id": null, "afk_at": "2015/12/03 01:50:54"}, "scoops": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 01:50:36", "prev_status": "offline", "games_played": [347, null, 0], "game_id": 0, "afk_at": "2015/12/02 08:26:41"}, "arka": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 02:21:16", "prev_status": "offline", "games_played": [1, null], "game_id": 1, "afk_at": "2015/12/03 01:04:59"}, "wriggle": {"status": "offline", "is_afk": false, "status_change_at": "2015/12/03 00:23:48", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/02 15:37:49"}, "tim": {"status": "offline", "is_afk": false, "status_change_at": "2015/12/02 09:53:25", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/02 09:23:29"}, "charisma": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 00:31:10", "prev_status": "idle", "games_played": [313], "game_id": 313, "afk_at": "2015/12/03 00:08:06"}, "sig": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 02:37:00", "prev_status": "online", "games_played": [8, null, 7], "game_id": null, "afk_at": "2015/12/03 02:37:00"}, "mr. nelson": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 02:18:48", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/03 02:18:48"}, "skeletonhorn": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 00:36:39", "prev_status": "offline", "games_played": [], "game_id": null, "afk_at": "2015/12/03 00:36:39"}, "azia": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 02:17:32", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/03 02:17:32"}, "projectaria": {"status": "online", "is_afk": false, "status_change_at": "2015/12/02 23:06:07", "prev_status": "idle", "games_played": [1, null], "game_id": null, "afk_at": "2015/12/02 22:31:46"}, "moss": {"status": "online", "is_afk": false, "status_change_at": "2015/12/02 21:56:26", "prev_status": "idle", "games_played": [0, null], "game_id": 0, "afk_at": "2015/12/02 21:53:22"}, "yobi": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 01:27:37", "prev_status": "idle", "games_played": [3], "game_id": 3, "afk_at": "2015/12/03 01:18:27"}, "salt": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 00:55:01", "prev_status": "idle", "games_played": [466, 8, null, 680], "game_id": null, "afk_at": "2015/12/03 00:54:11"}, "grey": {"status": "online", "is_afk": false, "status_change_at": "2015/12/02 20:32:11", "prev_status": "idle", "games_played": [550, null, 1], "game_id": 1, "afk_at": "2015/12/02 20:31:15"}, "hellsbreath": {"status": "online", "is_afk": false, "status_change_at": "2015/12/03 02:05:59", "prev_status": "idle", "games_played": [326, null, 660, 680], "game_id": null, "afk_at": "2015/12/02 22:37:41"}, "green": {"status": "online", "is_afk": false, "status_change_at": "2015/12/02 20:04:13", "prev_status": "offline", "games_played": [4], "game_id": 4, "afk_at": "2015/12/02 09:36:27"}, "xorfos": {"status": "idle", "is_afk": true, "status_change_at": "2015/12/03 02:46:27", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/03 02:46:27"}, "richter": {"status": "offline", "is_afk": false, "status_change_at": "2015/12/03 02:24:25", "prev_status": "online", "games_played": [], "game_id": null, "afk_at": "2015/12/02 20:18:33"}, "cae": {"status": "online", "is_afk": false, "status_change_at": "2015/12/02 23:07:33", "prev_status": "idle", "games_played": [], "game_id": null, "afk_at": "2015/12/02 23:06:53"}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment