Compare commits
No commits in common. "0e0456ca9ef85d443726fcd3002321e0633008a9" and "5f3b3bb7757ea07ef3a0b4ae6c439dcdecb95ffc" have entirely different histories.
0e0456ca9e
...
5f3b3bb775
@ -1,30 +0,0 @@
|
|||||||
from abc import ABCMeta
|
|
||||||
|
|
||||||
from commands.command_base import AbstractCommand
|
|
||||||
|
|
||||||
import discord
|
|
||||||
import discord.message
|
|
||||||
|
|
||||||
class CommandTTS(AbstractCommand, metaclass=ABCMeta):
|
|
||||||
command = "!tts"
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__(CommandTTS.command, n_args=1, command_type=AbstractCommand.CommandType.DISCORD)
|
|
||||||
|
|
||||||
async def do_command(self, bot, discord_message: discord.message):
|
|
||||||
args = self.get_args(discord_message.content)
|
|
||||||
if args[1] == "start":
|
|
||||||
print(discord_message.author.top_role)
|
|
||||||
print("start detected")
|
|
||||||
if str(discord_message.author.top_role) == "Admin":
|
|
||||||
print("Admin Check")
|
|
||||||
response = str("tts activated on %s" % discord_message.guild.name)
|
|
||||||
await bot.send_message(discord_message, response)
|
|
||||||
bot.tts_enabled = True
|
|
||||||
elif args[1] == "stop":
|
|
||||||
print("stop detected")
|
|
||||||
if str(discord_message.author.top_role) == "Admin":
|
|
||||||
print("Admin Check")
|
|
||||||
response = str("tts deactivated on %s" % discord_message.guild.name)
|
|
||||||
await bot.send_message(discord_message, response)
|
|
||||||
bot.tts_enabled = False
|
|
||||||
@ -74,7 +74,7 @@ class PollyVoices(Enum):
|
|||||||
Zhiyu = "Zhiyu"
|
Zhiyu = "Zhiyu"
|
||||||
|
|
||||||
|
|
||||||
botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy")
|
botList = ("Nightbot", "StreamElements", "Moobot", "praxis_bot")
|
||||||
|
|
||||||
slurList = ("fag", "faggot", "niga", "nigga", "nigger", "retard", "tard", "rtard", "coon")
|
slurList = ("fag", "faggot", "niga", "nigga", "nigger", "retard", "tard", "rtard", "coon")
|
||||||
|
|
||||||
|
|||||||
@ -48,11 +48,7 @@ class Discord_Module(discord.Client):
|
|||||||
if message.content == "//test":
|
if message.content == "//test":
|
||||||
await message.channel.send('test response')
|
await message.channel.send('test response')
|
||||||
|
|
||||||
if not await self.isSenderBot(message):
|
await self.eval_commands(message)
|
||||||
if self.cooldownModule.isCooldownActive("discordRateLimit") == False:
|
|
||||||
await self.eval_commands(message)
|
|
||||||
await self.tts_message(message)
|
|
||||||
|
|
||||||
|
|
||||||
async def eval_commands(self, message: discord.Message):
|
async def eval_commands(self, message: discord.Message):
|
||||||
# containsURL: bool = self.contains_url(message)
|
# containsURL: bool = self.contains_url(message)
|
||||||
@ -76,8 +72,7 @@ class Discord_Module(discord.Client):
|
|||||||
if command is not None and command.command_type is AbstractCommand.CommandType.DISCORD:
|
if command is not None and command.command_type is AbstractCommand.CommandType.DISCORD:
|
||||||
await command.do_command(self, message)
|
await command.do_command(self, message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Undo the following for debug stuff
|
print(e)
|
||||||
#print(e)
|
|
||||||
pass # we don't care
|
pass # we don't care
|
||||||
|
|
||||||
async def send_message(self, message, response):
|
async def send_message(self, message, response):
|
||||||
@ -85,49 +80,6 @@ class Discord_Module(discord.Client):
|
|||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
self.cooldownModule.actionTrigger("discordRateLimit")
|
self.cooldownModule.actionTrigger("discordRateLimit")
|
||||||
|
|
||||||
async def tts_message(self, message: discord.Message):
|
|
||||||
if not await self.contains_slur(message):
|
|
||||||
if self.tts_enabled:
|
|
||||||
if not message.content.startswith('!'):
|
|
||||||
text_to_say: str = "%s says, %s" % (message.author.display_name, message.content)
|
|
||||||
channel_text = "%s user msg" % message.channel
|
|
||||||
|
|
||||||
tts.tts(text_to_say)
|
|
||||||
|
|
||||||
# Checks for basic slurs.
|
|
||||||
async def contains_slur(self, message: discord.Message):
|
|
||||||
containsSlur: bool = False
|
|
||||||
|
|
||||||
if await self.slur_check(message.content) or await self.slur_check(message.author.display_name):
|
|
||||||
containsSlur = True
|
|
||||||
|
|
||||||
return containsSlur
|
|
||||||
|
|
||||||
async def slur_check(self, text):
|
|
||||||
containsSlur: bool = False
|
|
||||||
parsedMessage = text.split(" ")
|
|
||||||
for word in parsedMessage:
|
|
||||||
for slur in config.slurList:
|
|
||||||
if word.lower() == slur:
|
|
||||||
containsSlur = True
|
|
||||||
break # we want to immediately escape if we found a slur
|
|
||||||
if containsSlur:
|
|
||||||
break
|
|
||||||
|
|
||||||
if containsSlur:
|
|
||||||
print("<{ slur detected! }>")
|
|
||||||
#print("<{ slur detected! }> " + " [#" + message.channel + "](" + message.author.display_name + ") used a slur in chat")
|
|
||||||
return containsSlur
|
|
||||||
|
|
||||||
# Checks if Sender is bot.
|
|
||||||
async def isSenderBot(self, message: discord.Message):
|
|
||||||
isBot = False
|
|
||||||
for bot in config.botList:
|
|
||||||
if message.author.display_name.lower() == bot.lower():
|
|
||||||
isBot = True
|
|
||||||
print("<{ bot detected! }> ")
|
|
||||||
return isBot
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -75,10 +75,11 @@ class Twitch_Module():
|
|||||||
if not self.isSenderBot(message):
|
if not self.isSenderBot(message):
|
||||||
if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
||||||
self.eval_commands(message)
|
self.eval_commands(message)
|
||||||
|
#elif message.channel == message.sender:
|
||||||
|
#self.eval_commands(message)
|
||||||
self.tts_message(message)
|
self.tts_message(message)
|
||||||
|
|
||||||
def eval_commands(self, message: twitch.chat.Message):
|
def eval_commands(self, message: twitch.chat.Message):
|
||||||
print("evaling command")
|
|
||||||
# containsURL: bool = self.contains_url(message)
|
# containsURL: bool = self.contains_url(message)
|
||||||
try:
|
try:
|
||||||
#first_space_idx = message.text.index(' ')
|
#first_space_idx = message.text.index(' ')
|
||||||
@ -98,12 +99,9 @@ class Twitch_Module():
|
|||||||
|
|
||||||
command = self.commands[command_text]
|
command = self.commands[command_text]
|
||||||
if command is not None and command.command_type is AbstractCommand.CommandType.TWITCH:
|
if command is not None and command.command_type is AbstractCommand.CommandType.TWITCH:
|
||||||
print("evaling command")
|
|
||||||
command.do_command(self, message)
|
command.do_command(self, message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Undo the following for debug stuff
|
print(e)
|
||||||
#print(e)
|
|
||||||
print("failed command")
|
|
||||||
pass # we don't care
|
pass # we don't care
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +112,11 @@ class Twitch_Module():
|
|||||||
text_to_say: str = "%s says, %s" % (message.sender, message.text)
|
text_to_say: str = "%s says, %s" % (message.sender, message.text)
|
||||||
channel_text = "%s user msg" % message.channel
|
channel_text = "%s user msg" % message.channel
|
||||||
|
|
||||||
tts.tts(text_to_say)
|
if message.sender.lower() == message.channel:
|
||||||
|
tts.tts(text_to_say)
|
||||||
|
else:
|
||||||
|
# tts.tts(message.sender + " says, " + message.text)
|
||||||
|
tts.tts(text_to_say, channel_text)
|
||||||
|
|
||||||
def contains_url(self, message: twitch.chat.Message):
|
def contains_url(self, message: twitch.chat.Message):
|
||||||
containsURL = re.search(self._urlMatcher, message.text.lower()) is not None
|
containsURL = re.search(self._urlMatcher, message.text.lower()) is not None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user