Initial commit
This commit is contained in:
commit
359eabe4c8
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
env/
|
||||||
|
.vscode/
|
||||||
59
tbot.py
Normal file
59
tbot.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import twitch
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
UserID = "oauth:9yymca9k3o4okc40lgc67q9u9x3dqe"
|
||||||
|
PREFIX = '!'
|
||||||
|
BOTID = '[BOT]'
|
||||||
|
|
||||||
|
#User limits
|
||||||
|
TIMEOUT = 10
|
||||||
|
MSG_LIMIT = 10
|
||||||
|
|
||||||
|
userstats = {}
|
||||||
|
|
||||||
|
def handle_message(message: twitch.chat.Message) -> None:
|
||||||
|
print(message.text)
|
||||||
|
if message.text.startswith(PREFIX + 'views'):
|
||||||
|
message.chat.send(f'{BOTID} @{message.user.display_name}, you have {message.user.view_count} views.')
|
||||||
|
|
||||||
|
if message.text.startswith(PREFIX + "hello"):
|
||||||
|
message.chat.send(f"{BOTID} Hello @{message.user.display_name}, how are you?")
|
||||||
|
|
||||||
|
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')}")
|
||||||
|
|
||||||
|
# User limits
|
||||||
|
if message.user.display_name not in userstats:
|
||||||
|
timeOut = int(datetime.datetime.now().timestamp())
|
||||||
|
userstats[message.user.display_name] = [0, timeOut, timeOut + TIMEOUT]
|
||||||
|
userstats[message.user.display_name][0] += 1
|
||||||
|
else:
|
||||||
|
userstats[message.user.display_name][0] += 1
|
||||||
|
currTime = int(datetime.datetime.now().timestamp())
|
||||||
|
if currTime >= userstats[message.user.display_name][1]:
|
||||||
|
userstats[message.user.display_name][1] = currTime
|
||||||
|
userstats[message.user.display_name][1] = currTime + TIMEOUT
|
||||||
|
userstats[message.user.display_name][0] = 0
|
||||||
|
if currTime < userstats[message.user.display_name][2] and userstats[message.user.display_name][0] > MSG_LIMIT:
|
||||||
|
message.chat.send(f"{BOTID} Timing out {message.user.display_name} for 15 seconds, please no spam :(")
|
||||||
|
message.chat.send(f"/timeout {message.user.display_name} 15")
|
||||||
|
print(f"{userstats[message.user.display_name][2]}:{currTime}")
|
||||||
|
|
||||||
|
print(userstats)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
chat = twitch.Chat(channel='#aztecdude1',
|
||||||
|
nickname='AzBot',
|
||||||
|
oauth=UserID,
|
||||||
|
helix=twitch.Helix(client_id='brxmkiwb7y8f2zec55m5oom5xu0tgo', use_cache=True))
|
||||||
|
|
||||||
|
chat.subscribe(handle_message)
|
||||||
|
chat.send(f"{BOTID} I am online now")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Loading…
x
Reference in New Issue
Block a user