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