mirror of https://gitlab.com/gpvkt/twitchtts.git
Bugfix: Whitelist config values, Added favicon
This commit is contained in:
parent
7f9c057b05
commit
d4075bd0e7
Binary file not shown.
After Width: | Height: | Size: 318 B |
22
tts.py
22
tts.py
|
@ -20,12 +20,12 @@ class IRC:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.tts_denied = []
|
self.tts_denied = []
|
||||||
if 'WHITELIST_USER' in conf:
|
|
||||||
self.tts_allowed = conf['WHITELIST_USER']
|
|
||||||
else:
|
|
||||||
self.tts_allowed = []
|
self.tts_allowed = []
|
||||||
self.tts_status = True
|
self.tts_status = True
|
||||||
|
|
||||||
|
if 'WHITELIST_USER' in conf:
|
||||||
|
self.tts_allowed = conf['WHITELIST_USER']
|
||||||
|
|
||||||
def connect(self, server, port, channel, botnick, botpass):
|
def connect(self, server, port, channel, botnick, botpass):
|
||||||
logging.info("Connecting to: " + server)
|
logging.info("Connecting to: " + server)
|
||||||
try:
|
try:
|
||||||
|
@ -144,6 +144,7 @@ class IRC:
|
||||||
logging.debug('Removing "@" from username')
|
logging.debug('Removing "@" from username')
|
||||||
user = user.replace('@', '')
|
user = user.replace('@', '')
|
||||||
|
|
||||||
|
logging.info("Adding "+str(user)+" to whitelist")
|
||||||
self.tts_allowed.append(user)
|
self.tts_allowed.append(user)
|
||||||
|
|
||||||
if user in self.tts_denied:
|
if user in self.tts_denied:
|
||||||
|
@ -197,11 +198,16 @@ class IRC:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if conf['WHITELIST']:
|
if conf['WHITELIST']:
|
||||||
|
if self.tts_allowed:
|
||||||
if not user in self.tts_allowed:
|
if not user in self.tts_allowed:
|
||||||
logging.info('User is not on whitelist')
|
logging.info('User is not on whitelist')
|
||||||
logging.info(self.tts_allowed)
|
logging.info(self.tts_allowed)
|
||||||
self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['WHITELISTONLY'])
|
self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['WHITELISTONLY'])
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
logging.info('Nobody is on the whitelist.')
|
||||||
|
self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['WHITELISTONLY'])
|
||||||
|
return False
|
||||||
|
|
||||||
logging.info('Valid TTS message, adding to raw queue')
|
logging.info('Valid TTS message, adding to raw queue')
|
||||||
tts = True
|
tts = True
|
||||||
|
@ -225,6 +231,14 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
html = fh.read()
|
html = fh.read()
|
||||||
self.wfile.write(html)
|
self.wfile.write(html)
|
||||||
|
|
||||||
|
elif self.path == '/favicon.ico':
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-type', 'image/x-icon')
|
||||||
|
self.end_headers()
|
||||||
|
with open("favicon.ico", "rb") as fh:
|
||||||
|
icon = fh.read()
|
||||||
|
self.wfile.write(icon)
|
||||||
|
|
||||||
elif self.path == '/tts.js':
|
elif self.path == '/tts.js':
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/javascript')
|
self.send_header('Content-type', 'text/javascript')
|
||||||
|
@ -368,7 +382,7 @@ msg_queue_raw = []
|
||||||
msg_queue = {}
|
msg_queue = {}
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s')
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s')
|
||||||
sys.tracebacklimit = 0
|
sys.tracebacklimit = 1
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
conf = load_config()
|
conf = load_config()
|
||||||
|
|
Loading…
Reference in New Issue