diff --git a/tts.py b/tts.py index ce2c2a3..c9adfef 100644 --- a/tts.py +++ b/tts.py @@ -117,7 +117,7 @@ class IRC: """ 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 messages, to keep the connection alive. @@ -125,7 +125,7 @@ class IRC: logging.debug('PING received') 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 :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.') sys.exit(251) - def resp_clearmsg(self, resp): + def __resp_clearmsg(self, resp): """ Respond to CLEARMSG :param str resp: IRC Server message @@ -163,20 +163,20 @@ class IRC: MSG_QUEUE_RAW = filtered_msg_queue - def resp_privmsg(self, resp): + def __resp_privmsg(self, resp): """ Respond to PRIVMSG :param str resp: IRC Server message """ logging.debug('PRIVMSG received') - tags = self.get_tags(resp) - message = self.get_message(resp) + tags = self.__get_tags(resp) + message = self.__get_message(resp) - self.priviledged_commands(message, tags) - self.unpriviledged_commands(message, tags) + self.__priviledged_commands(message, tags) + self.__unpriviledged_commands(message, tags) - def get_tags(self, resp): + def __get_tags(self, resp): """ Strip tags from response :param str resp: IRC Server message @@ -206,7 +206,7 @@ class IRC: return tags - def get_message(self, resp): + def __get_message(self, resp): """ Transform IRC server message and determine length :param str resp: IRC Server message @@ -220,7 +220,7 @@ class IRC: return msg - def unpriviledged_commands(self, message, tags): + def __unpriviledged_commands(self, message, tags): """ Process unpriviledged commands :param dict message: Message @@ -246,26 +246,26 @@ class IRC: if msg.startswith('!tts'): logging.info('!tts command detected') - self.ttscmd(message, tags) + self.__ttscmd(message, tags) return if msg.startswith('!wiki') and CONF['FEATURE']['WIKI']: logging.debug("!wiki command detected") - self.wiki(tags, msg) + self.__wikicmd(tags, msg) return if CONF['FEATURE']['QUOTE']: if msg.startswith('!addquote'): logging.debug("!addquote command detected") - self.addquote(tags, msg) + self.__addquotecmd(tags, msg) return if msg.startswith('!smartquote') or msg.startswith('!sq'): logging.debug("!smartquote command detected") - self.quote(tags, msg) + self.__quotecmd(tags, msg) return - def priviledged_commands(self, message, tags): + def __priviledged_commands(self, message, tags): """ Process priviledged commands :param dict message: Message @@ -317,31 +317,31 @@ class IRC: elif msg.startswith('!pick') and CONF['FEATURE']['PICK']: logging.debug("!pick command detected") - self.pickcmd(msg) + self.__pickcmd(msg) elif msg.startswith('!random') and CONF['FEATURE']['RANDOM']: logging.info('!random command detected') - self.random(msg) + self.__randomcmd(msg) elif msg.startswith('!quickvote') and CONF['FEATURE']['QUOTE']: logging.info("!quickvote command detected") - self.quickvotecmd(msg) + self.__quickvotecmd(msg) elif msg.startswith('!ptts'): logging.debug("!ptts command detected") - self.ptts(msg) + self.__ptts(msg) elif msg.startswith('!dtts'): logging.debug("!dtts command detected") - self.dtts(msg) + self.__dtts(msg) elif msg.startswith('!usermap'): logging.info('!usermap command detected') - self.usermap(msg) + self.__usermap(msg) elif msg.startswith('!delay'): logging.info('!delay command detected') - self.delay(msg) + self.__delay(msg) def check_subonly(self, tags): """ Check if subonly mode is enabled and sender is sub @@ -525,18 +525,18 @@ class IRC: sys.exit(255) if resp.find('PING') != -1: - self.resp_ping() + self.__resp_ping() if resp.find('CLEARMSG') != -1: - self.resp_clearmsg(resp) + self.__resp_clearmsg(resp) if resp.find('NOTICE') != -1: - self.resp_notice(resp) + self.__resp_notice(resp) 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 Check if message is valid and send it to queue @@ -563,7 +563,7 @@ class IRC: logging.info('Sending TTS message to raw_queue') IRC.send_tts_msg(self, msg, tags) - def addquote(self, tags, msg): + def __addquotecmd(self, tags, msg): """ !addquote command Adds a newline to quotes.txt @@ -642,7 +642,7 @@ class IRC: msg_queue[raw_msg['timestamp']] = [raw_msg['user'], raw_msg['msg']] IRC.sendmsg(self, CONF['IRC_CHANNEL'], "@"+str(user), message) - def wiki(self, tags, msg): + def __wikicmd(self, tags, msg): """ !wiki command Search for wikipedia articles and return the first 3 sentences @@ -681,7 +681,7 @@ class IRC: user = f"@{user}" 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 Gets a line from quotes.txt. If a number if given as msg @@ -779,7 +779,7 @@ class IRC: return True - def delay(self, msg): + def __delay(self, msg): """ !delay command Adjust the delay setting in config.yml @@ -803,7 +803,7 @@ class IRC: load_config() - def usermap(self, msg): + def __usermap(self, msg): """ !usermap command Adds a new entry to usermapping in config.yml @@ -830,7 +830,7 @@ class IRC: yaml.safe_dump(cur_yaml, yamlfile) load_config() - def pickcmd(self, msg): + def __pickcmd(self, msg): """ !pick command Pick a number of users who typed #pickme in the chat @@ -912,7 +912,7 @@ class IRC: ) return - def quickvotecmd(self, msg): + def __quickvotecmd(self, msg): """ !quickvote command Starts or stops the !quickvote function. On stop calculates the 5 most casted @@ -1016,7 +1016,7 @@ class IRC: return - def random(self, msg): + def __randomcmd(self, msg): """ !random command Read a random line from randomfile and put it into msg_queue @@ -1057,7 +1057,7 @@ class IRC: return True - def ptts(self, msg): + def __ptts(self, msg): """ !ptts command 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) self.tts['blacklist'].remove(user) - def dtts(self, msg): + def __dtts(self, msg): """ !dtts command Add user to tts_denied list and remove user from tts_allowed list