mirror of https://gitlab.com/gpvkt/twitchtts.git
sendmsg cleanup
This commit is contained in:
parent
573edc5af4
commit
a5cd6ae86d
63
tts.py
63
tts.py
|
@ -640,7 +640,11 @@ class IRC:
|
|||
"timestamp": str(time.time_ns())
|
||||
}
|
||||
msg_queue[raw_msg['timestamp']] = [raw_msg['user'], raw_msg['msg']]
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "@"+str(user), message)
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"@"+str(user),
|
||||
message
|
||||
)
|
||||
|
||||
def __wikicmd(self, tags, msg):
|
||||
""" !wiki command
|
||||
|
@ -657,8 +661,16 @@ class IRC:
|
|||
msg = msg.replace('!wiki', '').strip()
|
||||
wikiresult = wikipedia.summary(msg, sentences=3)
|
||||
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "@"+str(user), wikiresult)
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "@"+str(user), wikipedia.page(msg).url)
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"@"+str(user),
|
||||
wikiresult
|
||||
)
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"@"+str(user),
|
||||
wikipedia.page(msg).url
|
||||
)
|
||||
|
||||
message = wikiresult.replace('==', '')
|
||||
raw_msg = {
|
||||
|
@ -676,10 +688,10 @@ class IRC:
|
|||
|
||||
except wikipedia.exceptions.DisambiguationError:
|
||||
user = f"@{user}"
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], user, CONF['MESSAGE']['WIKI_TOO_MANY'])
|
||||
self.sendmsg(CONF['IRC_CHANNEL'], user, CONF['MESSAGE']['WIKI_TOO_MANY'])
|
||||
except Exception:
|
||||
user = f"@{user}"
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], user, CONF['MESSAGE']['WIKI_NO_RESULT'])
|
||||
self.sendmsg(CONF['IRC_CHANNEL'], user, CONF['MESSAGE']['WIKI_NO_RESULT'])
|
||||
|
||||
def __quotecmd(self, tags, msg = False):
|
||||
""" !smartquote command
|
||||
|
@ -742,7 +754,11 @@ class IRC:
|
|||
if not 'quote' in vars():
|
||||
logging.info('No quote found.')
|
||||
quote = CONF['MESSAGE']['QUOTE_NOT_FOUND']
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "", quote)
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"",
|
||||
quote
|
||||
)
|
||||
return False
|
||||
|
||||
if not isinstance(quote, str):
|
||||
|
@ -761,7 +777,11 @@ class IRC:
|
|||
else:
|
||||
logging.info('Sending quote to TTS')
|
||||
logging.debug("Quote: %s", quote)
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "", quote)
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"",
|
||||
quote
|
||||
)
|
||||
|
||||
message = quote.rsplit('(', 1)[0]
|
||||
raw_msg = {
|
||||
|
@ -876,16 +896,16 @@ class IRC:
|
|||
}
|
||||
msg_queue[raw_msg['timestamp']] = [raw_msg['user'], raw_msg['msg']]
|
||||
|
||||
IRC.sendmsg(self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'], "",
|
||||
CONF['MESSAGE']['PICKRESULT']
|
||||
)
|
||||
IRC.sendmsg(self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'], "*",
|
||||
joined_picks
|
||||
)
|
||||
else:
|
||||
IRC.sendmsg(self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'], "*",
|
||||
CONF['MESSAGE']['PICKNONE']
|
||||
)
|
||||
|
@ -906,7 +926,7 @@ class IRC:
|
|||
|
||||
logging.info("Will pick %s participants", self.pick['number'])
|
||||
|
||||
IRC.sendmsg(self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'], "@chat",
|
||||
CONF['MESSAGE']['PICKSTART']
|
||||
)
|
||||
|
@ -926,14 +946,12 @@ class IRC:
|
|||
|
||||
if self.quickvote['count'] == 0:
|
||||
logging.info("Nobody voted")
|
||||
IRC.sendmsg(
|
||||
self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"@chat",
|
||||
CONF['MESSAGE']['VOTEEND']
|
||||
)
|
||||
IRC.sendmsg(
|
||||
self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"*",
|
||||
CONF['MESSAGE']['VOTENOBODY']
|
||||
|
@ -962,7 +980,11 @@ class IRC:
|
|||
logging.info("Counting votes")
|
||||
count = 0
|
||||
count = Counter(self.quickvote['data'].values()).most_common(5)
|
||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "@chat", CONF['MESSAGE']['VOTEEND'])
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"@chat",
|
||||
CONF['MESSAGE']['VOTEEND']
|
||||
)
|
||||
|
||||
logging.debug(count)
|
||||
|
||||
|
@ -986,8 +1008,7 @@ class IRC:
|
|||
|
||||
for key, value in count:
|
||||
message = f"{key} ({value}) {CONF['MESSAGE']['VOTES']})"
|
||||
IRC.sendmsg(
|
||||
self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'], "*",
|
||||
message
|
||||
)
|
||||
|
@ -1001,14 +1022,12 @@ class IRC:
|
|||
self.quickvote['status'] = True
|
||||
self.quickvote['message'] = msg.split('!quickvote', 1)[1].strip()
|
||||
if self.quickvote['message']:
|
||||
IRC.sendmsg(
|
||||
self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'], "@chat",
|
||||
CONF['MESSAGE']['VOTESTART'] + " (" + str(self.quickvote['message']) + ")"
|
||||
)
|
||||
else:
|
||||
IRC.sendmsg(
|
||||
self,
|
||||
self.sendmsg(
|
||||
CONF['IRC_CHANNEL'],
|
||||
"@chat",
|
||||
CONF['MESSAGE']['VOTESTART']
|
||||
|
|
Loading…
Reference in New Issue