Added in mod privs

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

35
tbot.py
View File

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