Added in mod privs

This commit is contained in:
Benjamyn Love 2019-12-24 20:31:42 +11:00
parent caa3d48cd3
commit c2b86263a4

41
tbot.py
View File

@ -1,26 +1,29 @@
import twitch
import datetime
import re
import json
UserID = "OAUTH:TOKEN"
with open(".twitchcreds") as file:
botSettings = json.loads(file.read())
UserID = botSettings[0]['OAUTH']
PREFIX = '!'
BOTID = '[BOT]'
#User limits
TIMEOUT = 10
MSG_LIMIT = 10
TIMEOUT = 30
MSG_LIMIT = 5
userstats = {}
permitURL = []
def isURL(message):
rule = re.compile("http(|s):\/\/.*\..*")
rule = re.compile("http(|s)[;:]\/\/.*\..*")
if rule.findall(message):
return True
return False
def handle_message(message: twitch.chat.Message) -> None:
#print(message.chat
if message.text.startswith(PREFIX + 'views'):
@ -31,18 +34,25 @@ def handle_message(message: twitch.chat.Message) -> None:
if message.text.startswith(PREFIX + "author"):
message.chat.send(f"{BOTID} I am written by an idiot who knows enough to cause trouble ;)")
if message.text.startswith(PREFIX + "setgame"):
# Do logic for setting the game
message.chat.send(f"{BOTID} Changing game to {message.text.strip(PREFIX + 'setgame').strip()}")
if message.text.startswith(PREFIX + "permit"):
message.chat.send(f"permitting {message.text.strip(PREFIX + 'permit')}")
permitURL.append(message.text.strip(PREFIX + 'permit').strip())
if message.text.startswith(PREFIX + "uptime"):
pass # FIND WAY TO DO THIS WHEN ITS NOT 7AM
if message.user.display_name in botSettings[1]["MODS"]:
if message.text.startswith(PREFIX + "setgame"):
# Do logic for setting the game
message.chat.send(f"{BOTID} Changing game to {message.text.strip(PREFIX + 'setgame').strip()}")
if message.text.startswith(PREFIX + "permit"):
print(message.text)
msg = message.text.replace(PREFIX + "permit","").strip()
print(msg)
if '@' in message.text:
msg = msg.replace('@','')
message.chat.send(f"permitting {msg}")
permitURL.append(msg)
print(permitURL)
# User limits
if message.user.display_name not in userstats:
timeOut = int(datetime.datetime.now().timestamp())
@ -76,7 +86,7 @@ def main():
chat = twitch.Chat(channel='#aztecdude1',
nickname='AzBot',
oauth=UserID,
helix=twitch.Helix(client_id='TWITCHCLIENTID', use_cache=True))
helix=twitch.Helix(client_id=botSettings[0]['CLIENTID'], use_cache=True))
chat.subscribe(handle_message)
chat.send(f"{BOTID} I am online now")
@ -84,4 +94,5 @@ def main():
if __name__ == '__main__':
main()
print(isURL("https://google.com"))
print(botSettings)
#print(isURL("https://google.com"))