twitch tts
This commit is contained in:
parent
1c3d973edf
commit
6b5683f615
10
config.py
10
config.py
@ -19,18 +19,14 @@ adminUsers_List =["thecuriousnerd", "<@76078763984551936>"]
|
||||
block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels
|
||||
blockAll_TwitchChatChannelsMessaging = False # Blocks the ability to send messages to twitch channels
|
||||
|
||||
autoEnabled_TwitchTTS = False # Enables TTS for ALL
|
||||
autoEnabled_TwitchTTS_SpeakersList_Only = False # Enables TTS for Allowed TTS List Only
|
||||
#OLD CONFIGS WILL BE DELETED SOON
|
||||
#autoEnabled_TwitchChannelsTTS = False
|
||||
#block_TwitchChannelsTTS = [""] # block supersedes the tts_enabled bool
|
||||
#blockAll_TwitchChatChannelsTTS = False # blockAll supersedes the force bool and force list and tts_enabled bool
|
||||
#force_TwitchChannelsTTS = [""] # force supersedes the block list
|
||||
#forceAll_TwitchChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force list
|
||||
|
||||
#OLD CONFIGS WILL BE DELETED SOON
|
||||
#blockAll_TTS_URL_Twitch = True
|
||||
|
||||
autoEnabled_Twitch_rgbLightControl = False
|
||||
|
||||
#OLD CONFIGS WILL BE DELETED SOON
|
||||
#twitch_defaultCommandEnabledState = True
|
||||
#twitch_defaultCommandEnabledState_liveStreamOnly = True # If true this will make commands only available during live streams.
|
||||
@ -48,8 +44,6 @@ blockAll_DiscordChannelsTTS = False # blockAll supersedes the force bool and for
|
||||
force_DiscordChannelsTTS = [""] # force supersedes the block list
|
||||
forceAll_DiscordChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force list
|
||||
|
||||
blockAll_TTS_URL_Discord = True
|
||||
|
||||
#OLD CONFIGS WILL BE DELETED SOON
|
||||
#autoEnabled_Discord_rgbLightControl = False
|
||||
#discord_defaultCommandEnabledState = True
|
||||
|
||||
@ -35,8 +35,6 @@ class Twitch_Module():
|
||||
self.cooldownModule: Cooldown_Module = Cooldown_Module()
|
||||
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
|
||||
|
||||
self.allow_rgbLightControl = config.autoEnabled_Twitch_rgbLightControl
|
||||
|
||||
def join_channel(self, credential: credentials.Twitch_Credential, channel_name: str):
|
||||
channel_name = "#" + channel_name
|
||||
print("Connecting to Channel: " + channel_name + "...")
|
||||
@ -72,6 +70,16 @@ class Twitch_Module():
|
||||
# print("Sent ChatMSG")
|
||||
self.cooldownModule.actionTrigger("twitchChat")
|
||||
|
||||
def eval_command(self, message):
|
||||
command, rest = utility.parse_line(message.text)
|
||||
try:
|
||||
is_actionable = self.is_command(command)
|
||||
if is_actionable:
|
||||
if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
||||
self.exec_command(message ,command, rest)
|
||||
except:
|
||||
print("something went wrong with a command")
|
||||
|
||||
def is_command(self, word: str) -> bool:
|
||||
# todo need to url-escape word
|
||||
clean_param = urlencode({'name': word})
|
||||
@ -100,6 +108,45 @@ class Twitch_Module():
|
||||
# todo handle failed requests
|
||||
pass
|
||||
|
||||
def eval_tts(self, message: twitch.chat.Message):
|
||||
command, rest = utility.parse_line(message.text)
|
||||
try:
|
||||
is_actionable = self.is_command(command)
|
||||
if not is_actionable:
|
||||
self.exec_tts(message)
|
||||
except:
|
||||
print("something went wrong with tts")
|
||||
|
||||
def exec_tts(self, message: twitch.chat.Message):
|
||||
|
||||
if config.autoEnabled_TwitchTTS:
|
||||
if config.autoEnabled_TwitchTTS_SpeakersList_Only:
|
||||
tempName = message.sender.lower()
|
||||
if tempName in config.allowedTTS_List:
|
||||
text_to_say: str = "%s says, %s" % (message.sender, message.text)
|
||||
self.exec_tts_sender("", text_to_say)
|
||||
else:
|
||||
text_to_say: str = "%s says, %s" % (message.sender, message.text)
|
||||
self.exec_tts_sender("", text_to_say)
|
||||
|
||||
|
||||
|
||||
def exec_tts_sender(self, username, message):
|
||||
params = urlencode({'tts_sender': username, 'tts_text': message})
|
||||
#standalone_tts_core
|
||||
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
|
||||
resp = requests.get(url)
|
||||
if resp.status_code == 200:
|
||||
print("Got the following message: %s" % resp.text)
|
||||
data = loads(resp.text)
|
||||
msg = data['message']
|
||||
if msg is not None:
|
||||
return msg
|
||||
# todo send to logger and other relevent services
|
||||
else:
|
||||
# todo handle failed requests
|
||||
pass
|
||||
|
||||
def send_whisper(self, user, message):
|
||||
pass
|
||||
|
||||
@ -110,13 +157,15 @@ class Twitch_Module():
|
||||
|
||||
praxis_logger_obj.log("\n[#" + message.channel + "](" + message.sender + ")> " + message.text)
|
||||
|
||||
try:
|
||||
is_actionable = self.is_command(command)
|
||||
if is_actionable:
|
||||
if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
||||
self.exec_command(message ,command, rest)
|
||||
except:
|
||||
print("something went wrong with a command")
|
||||
self.eval_command(message)
|
||||
self.eval_tts(message)
|
||||
#try:
|
||||
# is_actionable = self.is_command(command)
|
||||
# if is_actionable:
|
||||
# if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
||||
# self.exec_command(message ,command, rest)
|
||||
#except:
|
||||
# print("something went wrong with a command")
|
||||
|
||||
def isChannel_inConfigList(self, selectedChannel, selectedList):
|
||||
# print(channel)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user