refactor of code
This commit is contained in:
0
jeevesbot/__init__.py
Normal file
0
jeevesbot/__init__.py
Normal file
BIN
jeevesbot/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
jeevesbot/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
jeevesbot/__pycache__/bothelp.cpython-38.pyc
Normal file
BIN
jeevesbot/__pycache__/bothelp.cpython-38.pyc
Normal file
Binary file not shown.
BIN
jeevesbot/__pycache__/env.cpython-38.pyc
Normal file
BIN
jeevesbot/__pycache__/env.cpython-38.pyc
Normal file
Binary file not shown.
BIN
jeevesbot/__pycache__/functions.cpython-38.pyc
Normal file
BIN
jeevesbot/__pycache__/functions.cpython-38.pyc
Normal file
Binary file not shown.
20
jeevesbot/bothelp.py
Normal file
20
jeevesbot/bothelp.py
Normal file
@@ -0,0 +1,20 @@
|
||||
keywords = ['gifbot']
|
||||
|
||||
def help(keyword=''):
|
||||
"""Filter for general help or specific keyword help."""
|
||||
if not keyword:
|
||||
file = open('help/help.md')
|
||||
contents = file.read()
|
||||
return (contents)
|
||||
if keyword[0]:
|
||||
keyword = str.lower(keyword)
|
||||
if keyword in keywords:
|
||||
document = 'help/help_' + keyword + '.md'
|
||||
print(document)
|
||||
file = open(document, 'r')
|
||||
contents = file.read()
|
||||
return (contents)
|
||||
else:
|
||||
file = open('help/help.md')
|
||||
contents = file.read()
|
||||
return (contents)
|
||||
5
jeevesbot/env.py.dist
Normal file
5
jeevesbot/env.py.dist
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
TOKEN = 'discord-bot-token-here'
|
||||
ADMIN_ROLE = 'role-to-exclude-from-gifbot'
|
||||
GIFCHANNELS = 'add-channel-ids-for-bot-to-work-in'
|
||||
26
jeevesbot/functions.py
Normal file
26
jeevesbot/functions.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python 3
|
||||
|
||||
from jeevesbot import env
|
||||
import urllib
|
||||
import dice
|
||||
|
||||
# This function is necessary for tenor, because they do not allow linking directly to the gif and need resolving.
|
||||
def resolve(url):
|
||||
return urllib.request.urlopen(url).url
|
||||
|
||||
# use the dice module for rolling
|
||||
def roll(notation):
|
||||
roll = dice.roll(notation)
|
||||
result = int(roll)
|
||||
return roll,result
|
||||
|
||||
def checkrole(roles):
|
||||
for role in roles:
|
||||
if str(role) == env.ADMIN_ROLE:
|
||||
return True
|
||||
|
||||
def checkchannel(channelid):
|
||||
if channelid in env.GIFCHANNELS:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
Reference in New Issue
Block a user