mirror of https://gitlab.com/gpvkt/twitchtts.git
Set methods to private
This commit is contained in:
parent
290a09be5d
commit
573edc5af4
76
tts.py
76
tts.py
|
@ -117,7 +117,7 @@ class IRC:
|
||||||
"""
|
"""
|
||||||
self.irc.send(bytes("PRIVMSG "+channel+" :"+user+" "+msg+"\r\n", "UTF-8"))
|
self.irc.send(bytes("PRIVMSG "+channel+" :"+user+" "+msg+"\r\n", "UTF-8"))
|
||||||
|
|
||||||
def resp_ping(self):
|
def __resp_ping(self):
|
||||||
""" Respond to PING
|
""" Respond to PING
|
||||||
|
|
||||||
Respond to PING messages, to keep the connection alive.
|
Respond to PING messages, to keep the connection alive.
|
||||||
|
@ -125,7 +125,7 @@ class IRC:
|
||||||
logging.debug('PING received')
|
logging.debug('PING received')
|
||||||
self.irc.send(bytes('PONG :tmi.twitch.tv\r\n', "UTF-8"))
|
self.irc.send(bytes('PONG :tmi.twitch.tv\r\n', "UTF-8"))
|
||||||
|
|
||||||
def resp_notice(self, resp):
|
def __resp_notice(self, resp):
|
||||||
""" Respond to NOTICE
|
""" Respond to NOTICE
|
||||||
|
|
||||||
:param str resp: IRC Server message (in response to command)
|
:param str resp: IRC Server message (in response to command)
|
||||||
|
@ -137,7 +137,7 @@ class IRC:
|
||||||
logging.exception('Login failed, please check your credentials and try again.')
|
logging.exception('Login failed, please check your credentials and try again.')
|
||||||
sys.exit(251)
|
sys.exit(251)
|
||||||
|
|
||||||
def resp_clearmsg(self, resp):
|
def __resp_clearmsg(self, resp):
|
||||||
""" Respond to CLEARMSG
|
""" Respond to CLEARMSG
|
||||||
|
|
||||||
:param str resp: IRC Server message
|
:param str resp: IRC Server message
|
||||||
|
@ -163,20 +163,20 @@ class IRC:
|
||||||
|
|
||||||
MSG_QUEUE_RAW = filtered_msg_queue
|
MSG_QUEUE_RAW = filtered_msg_queue
|
||||||
|
|
||||||
def resp_privmsg(self, resp):
|
def __resp_privmsg(self, resp):
|
||||||
""" Respond to PRIVMSG
|
""" Respond to PRIVMSG
|
||||||
|
|
||||||
:param str resp: IRC Server message
|
:param str resp: IRC Server message
|
||||||
"""
|
"""
|
||||||
logging.debug('PRIVMSG received')
|
logging.debug('PRIVMSG received')
|
||||||
|
|
||||||
tags = self.get_tags(resp)
|
tags = self.__get_tags(resp)
|
||||||
message = self.get_message(resp)
|
message = self.__get_message(resp)
|
||||||
|
|
||||||
self.priviledged_commands(message, tags)
|
self.__priviledged_commands(message, tags)
|
||||||
self.unpriviledged_commands(message, tags)
|
self.__unpriviledged_commands(message, tags)
|
||||||
|
|
||||||
def get_tags(self, resp):
|
def __get_tags(self, resp):
|
||||||
""" Strip tags from response
|
""" Strip tags from response
|
||||||
|
|
||||||
:param str resp: IRC Server message
|
:param str resp: IRC Server message
|
||||||
|
@ -206,7 +206,7 @@ class IRC:
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
def get_message(self, resp):
|
def __get_message(self, resp):
|
||||||
""" Transform IRC server message and determine length
|
""" Transform IRC server message and determine length
|
||||||
|
|
||||||
:param str resp: IRC Server message
|
:param str resp: IRC Server message
|
||||||
|
@ -220,7 +220,7 @@ class IRC:
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def unpriviledged_commands(self, message, tags):
|
def __unpriviledged_commands(self, message, tags):
|
||||||
""" Process unpriviledged commands
|
""" Process unpriviledged commands
|
||||||
|
|
||||||
:param dict message: Message
|
:param dict message: Message
|
||||||
|
@ -246,26 +246,26 @@ class IRC:
|
||||||
|
|
||||||
if msg.startswith('!tts'):
|
if msg.startswith('!tts'):
|
||||||
logging.info('!tts command detected')
|
logging.info('!tts command detected')
|
||||||
self.ttscmd(message, tags)
|
self.__ttscmd(message, tags)
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg.startswith('!wiki') and CONF['FEATURE']['WIKI']:
|
if msg.startswith('!wiki') and CONF['FEATURE']['WIKI']:
|
||||||
logging.debug("!wiki command detected")
|
logging.debug("!wiki command detected")
|
||||||
self.wiki(tags, msg)
|
self.__wikicmd(tags, msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
if CONF['FEATURE']['QUOTE']:
|
if CONF['FEATURE']['QUOTE']:
|
||||||
if msg.startswith('!addquote'):
|
if msg.startswith('!addquote'):
|
||||||
logging.debug("!addquote command detected")
|
logging.debug("!addquote command detected")
|
||||||
self.addquote(tags, msg)
|
self.__addquotecmd(tags, msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg.startswith('!smartquote') or msg.startswith('!sq'):
|
if msg.startswith('!smartquote') or msg.startswith('!sq'):
|
||||||
logging.debug("!smartquote command detected")
|
logging.debug("!smartquote command detected")
|
||||||
self.quote(tags, msg)
|
self.__quotecmd(tags, msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
def priviledged_commands(self, message, tags):
|
def __priviledged_commands(self, message, tags):
|
||||||
""" Process priviledged commands
|
""" Process priviledged commands
|
||||||
|
|
||||||
:param dict message: Message
|
:param dict message: Message
|
||||||
|
@ -317,31 +317,31 @@ class IRC:
|
||||||
|
|
||||||
elif msg.startswith('!pick') and CONF['FEATURE']['PICK']:
|
elif msg.startswith('!pick') and CONF['FEATURE']['PICK']:
|
||||||
logging.debug("!pick command detected")
|
logging.debug("!pick command detected")
|
||||||
self.pickcmd(msg)
|
self.__pickcmd(msg)
|
||||||
|
|
||||||
elif msg.startswith('!random') and CONF['FEATURE']['RANDOM']:
|
elif msg.startswith('!random') and CONF['FEATURE']['RANDOM']:
|
||||||
logging.info('!random command detected')
|
logging.info('!random command detected')
|
||||||
self.random(msg)
|
self.__randomcmd(msg)
|
||||||
|
|
||||||
elif msg.startswith('!quickvote') and CONF['FEATURE']['QUOTE']:
|
elif msg.startswith('!quickvote') and CONF['FEATURE']['QUOTE']:
|
||||||
logging.info("!quickvote command detected")
|
logging.info("!quickvote command detected")
|
||||||
self.quickvotecmd(msg)
|
self.__quickvotecmd(msg)
|
||||||
|
|
||||||
elif msg.startswith('!ptts'):
|
elif msg.startswith('!ptts'):
|
||||||
logging.debug("!ptts command detected")
|
logging.debug("!ptts command detected")
|
||||||
self.ptts(msg)
|
self.__ptts(msg)
|
||||||
|
|
||||||
elif msg.startswith('!dtts'):
|
elif msg.startswith('!dtts'):
|
||||||
logging.debug("!dtts command detected")
|
logging.debug("!dtts command detected")
|
||||||
self.dtts(msg)
|
self.__dtts(msg)
|
||||||
|
|
||||||
elif msg.startswith('!usermap'):
|
elif msg.startswith('!usermap'):
|
||||||
logging.info('!usermap command detected')
|
logging.info('!usermap command detected')
|
||||||
self.usermap(msg)
|
self.__usermap(msg)
|
||||||
|
|
||||||
elif msg.startswith('!delay'):
|
elif msg.startswith('!delay'):
|
||||||
logging.info('!delay command detected')
|
logging.info('!delay command detected')
|
||||||
self.delay(msg)
|
self.__delay(msg)
|
||||||
|
|
||||||
def check_subonly(self, tags):
|
def check_subonly(self, tags):
|
||||||
""" Check if subonly mode is enabled and sender is sub
|
""" Check if subonly mode is enabled and sender is sub
|
||||||
|
@ -525,18 +525,18 @@ class IRC:
|
||||||
sys.exit(255)
|
sys.exit(255)
|
||||||
|
|
||||||
if resp.find('PING') != -1:
|
if resp.find('PING') != -1:
|
||||||
self.resp_ping()
|
self.__resp_ping()
|
||||||
|
|
||||||
if resp.find('CLEARMSG') != -1:
|
if resp.find('CLEARMSG') != -1:
|
||||||
self.resp_clearmsg(resp)
|
self.__resp_clearmsg(resp)
|
||||||
|
|
||||||
if resp.find('NOTICE') != -1:
|
if resp.find('NOTICE') != -1:
|
||||||
self.resp_notice(resp)
|
self.__resp_notice(resp)
|
||||||
|
|
||||||
if resp.find('PRIVMSG') != -1:
|
if resp.find('PRIVMSG') != -1:
|
||||||
self.resp_privmsg(resp)
|
self.__resp_privmsg(resp)
|
||||||
|
|
||||||
def ttscmd(self, msg, tags):
|
def __ttscmd(self, msg, tags):
|
||||||
""" !tts command
|
""" !tts command
|
||||||
|
|
||||||
Check if message is valid and send it to queue
|
Check if message is valid and send it to queue
|
||||||
|
@ -563,7 +563,7 @@ class IRC:
|
||||||
logging.info('Sending TTS message to raw_queue')
|
logging.info('Sending TTS message to raw_queue')
|
||||||
IRC.send_tts_msg(self, msg, tags)
|
IRC.send_tts_msg(self, msg, tags)
|
||||||
|
|
||||||
def addquote(self, tags, msg):
|
def __addquotecmd(self, tags, msg):
|
||||||
""" !addquote command
|
""" !addquote command
|
||||||
|
|
||||||
Adds a newline to quotes.txt
|
Adds a newline to quotes.txt
|
||||||
|
@ -642,7 +642,7 @@ 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, CONF['IRC_CHANNEL'], "@"+str(user), message)
|
IRC.sendmsg(self, CONF['IRC_CHANNEL'], "@"+str(user), message)
|
||||||
|
|
||||||
def wiki(self, tags, msg):
|
def __wikicmd(self, tags, msg):
|
||||||
""" !wiki command
|
""" !wiki command
|
||||||
|
|
||||||
Search for wikipedia articles and return the first 3 sentences
|
Search for wikipedia articles and return the first 3 sentences
|
||||||
|
@ -681,7 +681,7 @@ class IRC:
|
||||||
user = f"@{user}"
|
user = f"@{user}"
|
||||||
IRC.sendmsg(self, CONF['IRC_CHANNEL'], user, CONF['MESSAGE']['WIKI_NO_RESULT'])
|
IRC.sendmsg(self, CONF['IRC_CHANNEL'], user, CONF['MESSAGE']['WIKI_NO_RESULT'])
|
||||||
|
|
||||||
def quote(self, tags, msg = False):
|
def __quotecmd(self, tags, msg = False):
|
||||||
""" !smartquote command
|
""" !smartquote command
|
||||||
|
|
||||||
Gets a line from quotes.txt. If a number if given as msg
|
Gets a line from quotes.txt. If a number if given as msg
|
||||||
|
@ -779,7 +779,7 @@ class IRC:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def delay(self, msg):
|
def __delay(self, msg):
|
||||||
""" !delay command
|
""" !delay command
|
||||||
|
|
||||||
Adjust the delay setting in config.yml
|
Adjust the delay setting in config.yml
|
||||||
|
@ -803,7 +803,7 @@ class IRC:
|
||||||
load_config()
|
load_config()
|
||||||
|
|
||||||
|
|
||||||
def usermap(self, msg):
|
def __usermap(self, msg):
|
||||||
""" !usermap command
|
""" !usermap command
|
||||||
|
|
||||||
Adds a new entry to usermapping in config.yml
|
Adds a new entry to usermapping in config.yml
|
||||||
|
@ -830,7 +830,7 @@ class IRC:
|
||||||
yaml.safe_dump(cur_yaml, yamlfile)
|
yaml.safe_dump(cur_yaml, yamlfile)
|
||||||
load_config()
|
load_config()
|
||||||
|
|
||||||
def pickcmd(self, msg):
|
def __pickcmd(self, msg):
|
||||||
""" !pick command
|
""" !pick command
|
||||||
|
|
||||||
Pick a number of users who typed #pickme in the chat
|
Pick a number of users who typed #pickme in the chat
|
||||||
|
@ -912,7 +912,7 @@ class IRC:
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
def quickvotecmd(self, msg):
|
def __quickvotecmd(self, msg):
|
||||||
""" !quickvote command
|
""" !quickvote command
|
||||||
|
|
||||||
Starts or stops the !quickvote function. On stop calculates the 5 most casted
|
Starts or stops the !quickvote function. On stop calculates the 5 most casted
|
||||||
|
@ -1016,7 +1016,7 @@ class IRC:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def random(self, msg):
|
def __randomcmd(self, msg):
|
||||||
""" !random command
|
""" !random command
|
||||||
|
|
||||||
Read a random line from randomfile and put it into msg_queue
|
Read a random line from randomfile and put it into msg_queue
|
||||||
|
@ -1057,7 +1057,7 @@ class IRC:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def ptts(self, msg):
|
def __ptts(self, msg):
|
||||||
""" !ptts command
|
""" !ptts command
|
||||||
|
|
||||||
Add user to tts_allowed list and remove user from tts_denied list
|
Add user to tts_allowed list and remove user from tts_denied list
|
||||||
|
@ -1078,7 +1078,7 @@ class IRC:
|
||||||
logging.info("Removing %s from deny list", user)
|
logging.info("Removing %s from deny list", user)
|
||||||
self.tts['blacklist'].remove(user)
|
self.tts['blacklist'].remove(user)
|
||||||
|
|
||||||
def dtts(self, msg):
|
def __dtts(self, msg):
|
||||||
""" !dtts command
|
""" !dtts command
|
||||||
|
|
||||||
Add user to tts_denied list and remove user from tts_allowed list
|
Add user to tts_denied list and remove user from tts_allowed list
|
||||||
|
|
Loading…
Reference in New Issue