Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Barry
/
discordbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6c38afa3
authored
2016-01-24 10:20:17 +0000
by
Barry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fixed whoplayed.
1 parent
8c05f710
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
28 deletions
db.sqlite3
hellsbot.py
members.json
db.sqlite3
View file @
6c38afa
No preview for this file type
hellsbot.py
View file @
6c38afa
...
...
@@ -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
:]
...
...
members.json
View file @
6c38afa
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to post a comment