From 541ad25af24c26430aad3db3a30d43e12494365a Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 14 Oct 2020 04:33:33 -0400 Subject: [PATCH 01/11] Changed Message Sending I changed the send message function I use for the twitch commands. --- commands/implemented/command_roll.py | 4 ++-- commands/implemented/command_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/implemented/command_roll.py b/commands/implemented/command_roll.py index 97bcfbb..48a87cb 100644 --- a/commands/implemented/command_roll.py +++ b/commands/implemented/command_roll.py @@ -18,7 +18,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): #twitch_message.chat.send("test acknowledged") diceRoll: str = "" - twitch_message.chat.send("Rolling Dice...") + bot.send_message("Rolling Dice...") print("Rolling Dice...") temp_preParsedMessage = twitch_message.text.split("+") @@ -63,4 +63,4 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll print(diceRoll) - twitch_message.chat.send(diceRoll) \ No newline at end of file + bot.send_message(diceRoll) \ No newline at end of file diff --git a/commands/implemented/command_test.py b/commands/implemented/command_test.py index d6fb5a5..1432e14 100644 --- a/commands/implemented/command_test.py +++ b/commands/implemented/command_test.py @@ -14,4 +14,4 @@ class CommandTest(AbstractCommand, metaclass=ABCMeta): def do_command(self, bot, twitch_message): print("!test Detected") - twitch_message.chat.send("test acknowledged") + bot.send_message("testing acknowledged") From 5f5496c9189e7dc1f3c3364679b61d634c034087 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 01:27:51 -0400 Subject: [PATCH 02/11] added cooldowns class --- cooldowns.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ twitch_script.py | 11 +++++-- 2 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 cooldowns.py diff --git a/cooldowns.py b/cooldowns.py new file mode 100644 index 0000000..5764024 --- /dev/null +++ b/cooldowns.py @@ -0,0 +1,81 @@ +from os import name +import random +import re + +import datetime +from datetime import timedelta + +import time +from time import sleep +from typing import Optional + +class Cooldown_Action: + def __init__(self): + self.name:str = "" + self.time = datetime.datetime.now() + +class Cooldowns_Module: + def __init__(self): + super().__init__() + self.coolDownName:str = "" + self.coolDownActionLimit:int = 0 + self.coolDownDuration:int = 0 #Seconds + + self.actionList:list = [] + + + def setupCooldown(self, name, limit, duration): + self.coolDownName = name + self.coolDownActionLimit = limit + self.coolDownDuration = duration + + + def isCooldownActive(self): + isCoolDownActivated:bool = False + + timenow = datetime.datetime.now() + timepast = timenow.fromtimestamp + + if len(self.actionList) > self.coolDownActionLimit: + actionCount = len(self.actionList) + + maxTmpIndex = actionCount - self.coolDownActionLimit - 1 + maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex] + + minTmpIndex = actionCount - 1 + mostRecentAction:Cooldown_Action = self.actionList[minTmpIndex] + + timeDiff = mostRecentAction.time - maxRecentAction.time + + maxTimeAllowed = timedelta(seconds = self.coolDownDuration) + if timeDiff >= maxTimeAllowed: + isCoolDownActivated = True + + return isCoolDownActivated + + def actionTrigger(self, name:str = ""): + newAction = Cooldown_Action() + newAction.name = name + self.actionList.append(newAction) + +if __name__ == "__main__": + testCD = Cooldowns_Module() + testCD.setupCooldown("test", 20, 1) + + print("CD Test 1: ") + for x in range(10): + testCD.actionTrigger() + sleep(0) + print(testCD.isCooldownActive()) + + print("CD Test 2: ") + for x in range(21): + testCD.actionTrigger() + sleep(0.08) + print(testCD.isCooldownActive()) + + print("CD Test 3: ") + for x in range(40): + testCD.actionTrigger() + sleep(0.02) + print(testCD.isCooldownActive()) \ No newline at end of file diff --git a/twitch_script.py b/twitch_script.py index 50e1bce..6b8676b 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -1,3 +1,4 @@ +from typing import Sequence import random import re @@ -12,6 +13,7 @@ import commands.loader as command_loader import credentials from commands.command_base import AbstractCommand +from cooldowns import Cooldowns_Module class Twitch_Module(): def __init__(self): @@ -30,6 +32,9 @@ class Twitch_Module(): self._urlMatcher = re.compile( "(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))") + self.twitchChat_cooldown:Cooldowns_Module = Cooldowns_Module() + self.twitchChat_cooldown.setupCooldown("twitchChat", 20, 30) + def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str): channel_name = "#" + channel_name print("Connecting to Channel: " + channel_name) @@ -53,7 +58,9 @@ class Twitch_Module(): self.chat.irc.socket.close() def send_message(self, message): - self.chat.send(message) + if self.twitchChat_cooldown.isCooldownActive() == False: + self.chat.send(message) + self.twitchChat_cooldown.actionTrigger() def send_whisper(self, user, message): pass @@ -74,7 +81,7 @@ class Twitch_Module(): #first_space_idx = message.text.index(' ') # This fixes a error where if you send a command without arguments it fails because - # it cant find the substring. + # it cant find the substring. if message.text.find(" ") != -1: first_space_idx = message.text.index(' ') else: From e7d9ecb2737e55ed7e0ebfbae177db1ee2353819 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 01:58:00 -0400 Subject: [PATCH 03/11] Fixed Cooldowns Bug --- cooldowns.py | 18 +++++++----------- twitch_script.py | 8 ++++++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cooldowns.py b/cooldowns.py index 5764024..abbd5be 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -34,21 +34,17 @@ class Cooldowns_Module: isCoolDownActivated:bool = False timenow = datetime.datetime.now() - timepast = timenow.fromtimestamp - if len(self.actionList) > self.coolDownActionLimit: + if len(self.actionList) >= self.coolDownActionLimit: actionCount = len(self.actionList) maxTmpIndex = actionCount - self.coolDownActionLimit - 1 maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex] - minTmpIndex = actionCount - 1 - mostRecentAction:Cooldown_Action = self.actionList[minTmpIndex] - - timeDiff = mostRecentAction.time - maxRecentAction.time + timeDiff = timenow - maxRecentAction.time maxTimeAllowed = timedelta(seconds = self.coolDownDuration) - if timeDiff >= maxTimeAllowed: + if timeDiff < maxTimeAllowed: isCoolDownActivated = True return isCoolDownActivated @@ -60,7 +56,7 @@ class Cooldowns_Module: if __name__ == "__main__": testCD = Cooldowns_Module() - testCD.setupCooldown("test", 20, 1) + testCD.setupCooldown("test", 20, 5) print("CD Test 1: ") for x in range(10): @@ -71,11 +67,11 @@ if __name__ == "__main__": print("CD Test 2: ") for x in range(21): testCD.actionTrigger() - sleep(0.08) + sleep(0.05) print(testCD.isCooldownActive()) print("CD Test 3: ") - for x in range(40): + for x in range(20): testCD.actionTrigger() - sleep(0.02) + sleep(0.6) print(testCD.isCooldownActive()) \ No newline at end of file diff --git a/twitch_script.py b/twitch_script.py index 6b8676b..84bf138 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -32,8 +32,10 @@ class Twitch_Module(): self._urlMatcher = re.compile( "(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))") + # Default Twitch Chat limit is 20 per 30 seconds + # If Mod or Op, Twitch Chat limit is 100 per 30 seconds self.twitchChat_cooldown:Cooldowns_Module = Cooldowns_Module() - self.twitchChat_cooldown.setupCooldown("twitchChat", 20, 30) + self.twitchChat_cooldown.setupCooldown("twitchChat", 20, 32) def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str): channel_name = "#" + channel_name @@ -71,8 +73,10 @@ class Twitch_Module(): if message.channel == "thecuriousnerd": if not self.isSenderBot(message): - if message.sender.lower() == "thecuriousnerd": + if self.twitchChat_cooldown.isCooldownActive() == False: self.eval_commands(message) + #elif message.channel == message.sender: + #self.eval_commands(message) self.tts_message(message) def eval_commands(self, message: twitch.chat.Message): From bbe77195ac5251e6d400f6a5a3e834e5d7a939f5 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 02:48:26 -0400 Subject: [PATCH 04/11] Fixed Cooldowns Bug --- cooldowns.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/cooldowns.py b/cooldowns.py index abbd5be..3b2647c 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -38,12 +38,12 @@ class Cooldowns_Module: if len(self.actionList) >= self.coolDownActionLimit: actionCount = len(self.actionList) - maxTmpIndex = actionCount - self.coolDownActionLimit - 1 + maxTmpIndex = actionCount - self.coolDownActionLimit maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex] timeDiff = timenow - maxRecentAction.time - maxTimeAllowed = timedelta(seconds = self.coolDownDuration) + if timeDiff < maxTimeAllowed: isCoolDownActivated = True @@ -56,22 +56,35 @@ class Cooldowns_Module: if __name__ == "__main__": testCD = Cooldowns_Module() - testCD.setupCooldown("test", 20, 5) + testCD.setupCooldown("test", 20, 2) print("CD Test 1: ") + for x in range(20): + testCD.actionTrigger() + sleep(0) + print(testCD.isCooldownActive()) + print("//Test Done//") + sleep(2) + + print("CD Test 2: ") for x in range(10): testCD.actionTrigger() sleep(0) print(testCD.isCooldownActive()) - - print("CD Test 2: ") - for x in range(21): - testCD.actionTrigger() - sleep(0.05) - print(testCD.isCooldownActive()) + print("//Test Done//") + sleep(2) print("CD Test 3: ") + for x in range(20): + testCD.actionTrigger() + sleep(0.05) + print(testCD.isCooldownActive()) + print("//Test Done//") + sleep(2) + + print("CD Test 4: ") for x in range(20): testCD.actionTrigger() sleep(0.6) - print(testCD.isCooldownActive()) \ No newline at end of file + print(testCD.isCooldownActive()) + print("//Test Done//") \ No newline at end of file From d88871abef72d2dc1a60491d51bd68936c9be95e Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 02:57:19 -0400 Subject: [PATCH 05/11] Fixed Import --- cooldowns.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cooldowns.py b/cooldowns.py index 3b2647c..e7acab8 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -1,4 +1,3 @@ -from os import name import random import re @@ -7,7 +6,6 @@ from datetime import timedelta import time from time import sleep -from typing import Optional class Cooldown_Action: def __init__(self): From 202d8e5891ac1845febe278bd6a734596ce86eae Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 06:00:49 -0400 Subject: [PATCH 06/11] Updated Mains. --- db.py | 8 ++++++-- twitch_script.py | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/db.py b/db.py index cb1aef3..7df35e8 100644 --- a/db.py +++ b/db.py @@ -69,5 +69,9 @@ class db_module(): if __name__ == "__main__": - db_connection = db_module() - db_connection.setup_engine() + testModule = db_module() + + credentials_manager = credentials.Credentials_Module() + credentials_manager.load_credentials() + testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot") + testModule.setup_engine() diff --git a/twitch_script.py b/twitch_script.py index 84bf138..15dd366 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -163,5 +163,10 @@ def main_chat_commands_check(channel, sender, text): if __name__ == "__main__": - testChat = Twitch_Module() - testChat.join_channel("thecuriousnerd") + testModule = Twitch_Module() + + credentials_manager = credentials.Credentials_Module() + credentials_manager.load_credentials() + testModule.twitchCredential = credentials_manager.find_Twitch_Credential("praxis_bot") + testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot") + testModule.join_channel(None ,"thecuriousnerd") From 5d88861b8ca287be27c4a1fc7e23a052764d4a73 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 06:40:42 -0400 Subject: [PATCH 07/11] Expanded Cooldowns --- cooldowns.py | 86 ++++++++++++++++++++++++++++++------------------ twitch_script.py | 6 ++-- 2 files changed, 57 insertions(+), 35 deletions(-) diff --git a/cooldowns.py b/cooldowns.py index e7acab8..c1aeb1e 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -9,80 +9,102 @@ from time import sleep class Cooldown_Action: def __init__(self): - self.name:str = "" + self.tag:str = "" self.time = datetime.datetime.now() +class Cooldown: + def __init__(self): + self.cooldownName:str = "" + self.cooldownActionLimit:int = 0 + self.cooldownDuration:int = 0 #Seconds + + self.actionList:list = [] + + def setupCooldown(self, name, limit, duration): + self.cooldownName = name + self.cooldownActionLimit = limit + self.cooldownDuration = duration + class Cooldowns_Module: def __init__(self): super().__init__() - self.coolDownName:str = "" - self.coolDownActionLimit:int = 0 - self.coolDownDuration:int = 0 #Seconds - - self.actionList:list = [] - + self.cooldownList:list = [] def setupCooldown(self, name, limit, duration): - self.coolDownName = name - self.coolDownActionLimit = limit - self.coolDownDuration = duration - + newCD:Cooldown = Cooldown() + newCD.setupCooldown(name, limit, duration) + self.cooldownList.append(newCD) - def isCooldownActive(self): - isCoolDownActivated:bool = False + + def getCooldown(self, name:str): + returnCD:bool = False + for cd in self.cooldownList: + if cd.cooldownName == name: + returnCD = True + return cd + if returnCD == False: + return None + + def isCooldownActive(self, name:str): + isCooldownActivated:bool = False + + selectedCooldown:Cooldown = self.getCooldown(name) timenow = datetime.datetime.now() - if len(self.actionList) >= self.coolDownActionLimit: - actionCount = len(self.actionList) + if len(selectedCooldown.actionList) >= selectedCooldown.cooldownActionLimit: + actionCount = len(selectedCooldown.actionList) - maxTmpIndex = actionCount - self.coolDownActionLimit - maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex] + maxTmpIndex = actionCount - selectedCooldown.cooldownActionLimit + maxRecentAction:Cooldown_Action = selectedCooldown.actionList[maxTmpIndex] timeDiff = timenow - maxRecentAction.time - maxTimeAllowed = timedelta(seconds = self.coolDownDuration) + maxTimeAllowed = timedelta(seconds = selectedCooldown.cooldownDuration) if timeDiff < maxTimeAllowed: - isCoolDownActivated = True + isCooldownActivated = True - return isCoolDownActivated + return isCooldownActivated - def actionTrigger(self, name:str = ""): + def actionTrigger(self, name:str = "", tag:str = ""): newAction = Cooldown_Action() - newAction.name = name - self.actionList.append(newAction) + newAction.tag = tag + targetCD = self.getCooldown(name) + if targetCD != None: + targetCD.actionList.append(newAction) if __name__ == "__main__": testCD = Cooldowns_Module() - testCD.setupCooldown("test", 20, 2) + cdName = "test" + testCD.setupCooldown(cdName, 20, 2) print("CD Test 1: ") for x in range(20): - testCD.actionTrigger() + testCD.actionTrigger(cdName) sleep(0) - print(testCD.isCooldownActive()) + print(testCD.isCooldownActive(cdName)) print("//Test Done//") sleep(2) print("CD Test 2: ") for x in range(10): - testCD.actionTrigger() + testCD.actionTrigger(cdName) sleep(0) - print(testCD.isCooldownActive()) + print(testCD.isCooldownActive(cdName)) print("//Test Done//") sleep(2) print("CD Test 3: ") for x in range(20): - testCD.actionTrigger() + testCD.actionTrigger(cdName) sleep(0.05) - print(testCD.isCooldownActive()) + print(testCD.isCooldownActive(cdName)) print("//Test Done//") sleep(2) print("CD Test 4: ") for x in range(20): - testCD.actionTrigger() + testCD.actionTrigger(cdName) sleep(0.6) - print(testCD.isCooldownActive()) + print(testCD.isCooldownActive(cdName)) print("//Test Done//") \ No newline at end of file diff --git a/twitch_script.py b/twitch_script.py index 15dd366..b1db0fc 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -60,9 +60,9 @@ class Twitch_Module(): self.chat.irc.socket.close() def send_message(self, message): - if self.twitchChat_cooldown.isCooldownActive() == False: + if self.twitchChat_cooldown.isCooldownActive("twitchChat") == False: self.chat.send(message) - self.twitchChat_cooldown.actionTrigger() + self.twitchChat_cooldown.actionTrigger("twitchChat") def send_whisper(self, user, message): pass @@ -73,7 +73,7 @@ class Twitch_Module(): if message.channel == "thecuriousnerd": if not self.isSenderBot(message): - if self.twitchChat_cooldown.isCooldownActive() == False: + if self.twitchChat_cooldown.isCooldownActive("twitchChat") == False: self.eval_commands(message) #elif message.channel == message.sender: #self.eval_commands(message) From 7b5b648e97d7a6662822b00d3267dc386ff5e775 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 06:45:00 -0400 Subject: [PATCH 08/11] Fixed Missing Cooldown --- cooldowns.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cooldowns.py b/cooldowns.py index c1aeb1e..919afae 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -50,6 +50,9 @@ class Cooldowns_Module: selectedCooldown:Cooldown = self.getCooldown(name) + if selectedCooldown == None: + return None + timenow = datetime.datetime.now() if len(selectedCooldown.actionList) >= selectedCooldown.cooldownActionLimit: @@ -78,6 +81,14 @@ if __name__ == "__main__": cdName = "test" testCD.setupCooldown(cdName, 20, 2) + print("CD Test 0: ") + for x in range(20): + testCD.actionTrigger("cdName") + sleep(0) + print(testCD.isCooldownActive("cdName")) + print("//Test Done//") + sleep(2) + print("CD Test 1: ") for x in range(20): testCD.actionTrigger(cdName) From 7aa6c558632dd5cf1f57d92e31bcc9dad1a82b90 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 15:32:17 -0400 Subject: [PATCH 09/11] Fixed TTS Setting command --- commands/implemented/command_tts.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/commands/implemented/command_tts.py b/commands/implemented/command_tts.py index 4392cc5..305e1cf 100644 --- a/commands/implemented/command_tts.py +++ b/commands/implemented/command_tts.py @@ -13,8 +13,10 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) if args[1] == "start": - bot.send_message("tts activated on #%s" % twitch_message.channel) - bot.tts_enabled = True + if twitch_message.sender.lower() == twitch_message.channel: + bot.send_message("tts activated on #%s" % twitch_message.channel) + bot.tts_enabled = True elif args[1] == "stop": - bot.send_message("tts deactivated") - bot.tts_enabled = False + if twitch_message.sender.lower() == twitch_message.channel: + bot.send_message("tts activated on #%s" % twitch_message.channel) + bot.tts_enabled = False From 6d8b8b2928fbde3f4ab6172042d4733f11170897 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 19 Oct 2020 17:14:19 -0400 Subject: [PATCH 10/11] another test --- cooldowns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cooldowns.py b/cooldowns.py index 919afae..cc7fba8 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -93,7 +93,7 @@ if __name__ == "__main__": for x in range(20): testCD.actionTrigger(cdName) sleep(0) - print(testCD.isCooldownActive(cdName)) + print(testCD.isCooldownActive("test")) print("//Test Done//") sleep(2) From d836752e2954f9ef068e27f7a747e0608874d165 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 19 Oct 2020 17:21:05 -0400 Subject: [PATCH 11/11] Renamed Module --- cooldowns.py | 2 +- twitch_script.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cooldowns.py b/cooldowns.py index cc7fba8..68b1431 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -25,7 +25,7 @@ class Cooldown: self.cooldownActionLimit = limit self.cooldownDuration = duration -class Cooldowns_Module: +class Cooldown_Module: def __init__(self): super().__init__() self.cooldownList:list = [] diff --git a/twitch_script.py b/twitch_script.py index b1db0fc..bf4ef2c 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -13,7 +13,7 @@ import commands.loader as command_loader import credentials from commands.command_base import AbstractCommand -from cooldowns import Cooldowns_Module +from cooldowns import Cooldown_Module class Twitch_Module(): def __init__(self): @@ -34,7 +34,7 @@ class Twitch_Module(): # Default Twitch Chat limit is 20 per 30 seconds # If Mod or Op, Twitch Chat limit is 100 per 30 seconds - self.twitchChat_cooldown:Cooldowns_Module = Cooldowns_Module() + self.twitchChat_cooldown:Cooldown_Module = Cooldown_Module() self.twitchChat_cooldown.setupCooldown("twitchChat", 20, 32) def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str):