Setup Cooldowns & Msg Clean Up

This commit is contained in:
Alex Orid 2020-10-20 04:44:52 -04:00
parent 323a5b1e9e
commit b0169ec68d
3 changed files with 19 additions and 7 deletions

View File

@ -24,7 +24,8 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
#twitch_message.chat.send("test acknowledged")
diceRoll: str = ""
await discord_message.channel.send("Rolling Dice...")
await bot.send_message(discord_message, "Rolling Dice...")
#await discord_message.channel.send("Rolling Dice...")
print("Rolling Dice...")
temp_preParsedMessage = discord_message.content.split("+")
@ -70,4 +71,5 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
diceRoll = discord_message.author.mention + " rolled: " + diceRoll
print(diceRoll)
await discord_message.channel.send(diceRoll)
await bot.send_message(discord_message, diceRoll)
#await discord_message.channel.send(diceRoll)

View File

@ -17,12 +17,17 @@ import discord
import discord.message
import discord.channel
from cooldowns import Cooldown_Module
class Discord_Module(discord.Client):
def __init__(self):
super().__init__()
self.dbCredential: credentials.DB_Credential
self.discordCredential: credentials.Discord_Credential
self.cooldownModule:Cooldown_Module = Cooldown_Module()
self.cooldownModule.setupCooldown("discordRateLimit", 10, 1)
self.commands = command_loader.load_commands()
self.tts_enabled: bool = False
@ -69,6 +74,11 @@ class Discord_Module(discord.Client):
except Exception as e:
print(e)
pass # we don't care
async def send_message(self, message, response):
if self.cooldownModule.isCooldownActive("discordRateLimit") == False:
await message.channel.send(response)
self.cooldownModule.actionTrigger("discordRateLimit")

View File

@ -34,8 +34,8 @@ 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:Cooldown_Module = Cooldown_Module()
self.twitchChat_cooldown.setupCooldown("twitchChat", 20, 32)
self.cooldownModule:Cooldown_Module = Cooldown_Module()
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str):
channel_name = "#" + channel_name
@ -60,9 +60,9 @@ class Twitch_Module():
self.chat.irc.socket.close()
def send_message(self, message):
if self.twitchChat_cooldown.isCooldownActive("twitchChat") == False:
if self.cooldownModule.isCooldownActive("twitchChat") == False:
self.chat.send(message)
self.twitchChat_cooldown.actionTrigger("twitchChat")
self.cooldownModule.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("twitchChat") == False:
if self.cooldownModule.isCooldownActive("twitchChat") == False:
self.eval_commands(message)
#elif message.channel == message.sender:
#self.eval_commands(message)