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
|
block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels
|
||||||
blockAll_TwitchChatChannelsMessaging = False # 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
|
#OLD CONFIGS WILL BE DELETED SOON
|
||||||
#autoEnabled_TwitchChannelsTTS = False
|
|
||||||
#block_TwitchChannelsTTS = [""] # block supersedes the tts_enabled bool
|
#block_TwitchChannelsTTS = [""] # block supersedes the tts_enabled bool
|
||||||
#blockAll_TwitchChatChannelsTTS = False # blockAll supersedes the force bool and force list and 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
|
#force_TwitchChannelsTTS = [""] # force supersedes the block list
|
||||||
#forceAll_TwitchChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force 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
|
#OLD CONFIGS WILL BE DELETED SOON
|
||||||
#twitch_defaultCommandEnabledState = True
|
#twitch_defaultCommandEnabledState = True
|
||||||
#twitch_defaultCommandEnabledState_liveStreamOnly = True # If true this will make commands only available during live streams.
|
#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
|
force_DiscordChannelsTTS = [""] # force supersedes the block list
|
||||||
forceAll_DiscordChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force 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
|
#OLD CONFIGS WILL BE DELETED SOON
|
||||||
#autoEnabled_Discord_rgbLightControl = False
|
#autoEnabled_Discord_rgbLightControl = False
|
||||||
#discord_defaultCommandEnabledState = True
|
#discord_defaultCommandEnabledState = True
|
||||||
|
|||||||
@ -35,8 +35,6 @@ class Twitch_Module():
|
|||||||
self.cooldownModule: Cooldown_Module = Cooldown_Module()
|
self.cooldownModule: Cooldown_Module = Cooldown_Module()
|
||||||
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
|
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
|
||||||
|
|
||||||
self.allow_rgbLightControl = config.autoEnabled_Twitch_rgbLightControl
|
|
||||||
|
|
||||||
def join_channel(self, credential: credentials.Twitch_Credential, channel_name: str):
|
def join_channel(self, credential: credentials.Twitch_Credential, channel_name: str):
|
||||||
channel_name = "#" + channel_name
|
channel_name = "#" + channel_name
|
||||||
print("Connecting to Channel: " + channel_name + "...")
|
print("Connecting to Channel: " + channel_name + "...")
|
||||||
@ -72,6 +70,16 @@ class Twitch_Module():
|
|||||||
# print("Sent ChatMSG")
|
# print("Sent ChatMSG")
|
||||||
self.cooldownModule.actionTrigger("twitchChat")
|
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:
|
def is_command(self, word: str) -> bool:
|
||||||
# todo need to url-escape word
|
# todo need to url-escape word
|
||||||
clean_param = urlencode({'name': word})
|
clean_param = urlencode({'name': word})
|
||||||
@ -100,6 +108,45 @@ class Twitch_Module():
|
|||||||
# todo handle failed requests
|
# todo handle failed requests
|
||||||
pass
|
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):
|
def send_whisper(self, user, message):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -110,13 +157,15 @@ class Twitch_Module():
|
|||||||
|
|
||||||
praxis_logger_obj.log("\n[#" + message.channel + "](" + message.sender + ")> " + message.text)
|
praxis_logger_obj.log("\n[#" + message.channel + "](" + message.sender + ")> " + message.text)
|
||||||
|
|
||||||
try:
|
self.eval_command(message)
|
||||||
is_actionable = self.is_command(command)
|
self.eval_tts(message)
|
||||||
if is_actionable:
|
#try:
|
||||||
if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
# is_actionable = self.is_command(command)
|
||||||
self.exec_command(message ,command, rest)
|
# if is_actionable:
|
||||||
except:
|
# if self.cooldownModule.isCooldownActive("twitchChat") == False:
|
||||||
print("something went wrong with a command")
|
# self.exec_command(message ,command, rest)
|
||||||
|
#except:
|
||||||
|
# print("something went wrong with a command")
|
||||||
|
|
||||||
def isChannel_inConfigList(self, selectedChannel, selectedList):
|
def isChannel_inConfigList(self, selectedChannel, selectedList):
|
||||||
# print(channel)
|
# print(channel)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user