Bugfix: Whitelist config values, Added favicon

This commit is contained in:
gpkvt 2022-08-11 12:14:58 +02:00
parent aaecb44df2
commit 496a0f5a18
2 changed files with 21 additions and 7 deletions

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

28
tts.py
View File

@ -20,11 +20,11 @@ class IRC:
def __init__(self):
self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.tts_denied = []
self.tts_allowed = []
self.tts_status = True
if 'WHITELIST_USER' in conf:
self.tts_allowed = conf['WHITELIST_USER']
else:
self.tts_allowed = []
self.tts_status = True
def connect(self, server, port, channel, botnick, botpass):
logging.info("Connecting to: " + server)
@ -144,6 +144,7 @@ class IRC:
logging.debug('Removing "@" from username')
user = user.replace('@', '')
logging.info("Adding "+str(user)+" to whitelist")
self.tts_allowed.append(user)
if user in self.tts_denied:
@ -197,9 +198,14 @@ class IRC:
return False
if conf['WHITELIST']:
if not user in self.tts_allowed:
logging.info('User is not on whitelist')
logging.info(self.tts_allowed)
if self.tts_allowed:
if not user in self.tts_allowed:
logging.info('User is not on whitelist')
logging.info(self.tts_allowed)
self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['WHITELISTONLY'])
return False
else:
logging.info('Nobody is on the whitelist.')
self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['WHITELISTONLY'])
return False
@ -225,6 +231,14 @@ class HTTPserv(BaseHTTPRequestHandler):
html = fh.read()
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':
self.send_response(200)
self.send_header('Content-type', 'text/javascript')
@ -368,7 +382,7 @@ msg_queue_raw = []
msg_queue = {}
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s')
sys.tracebacklimit = 0
sys.tracebacklimit = 1
def main():
conf = load_config()