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

22
tts.py
View File

@ -20,12 +20,12 @@ class IRC:
def __init__(self):
self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.tts_denied = []
if 'WHITELIST_USER' in conf:
self.tts_allowed = conf['WHITELIST_USER']
else:
self.tts_allowed = []
self.tts_status = True
if 'WHITELIST_USER' in conf:
self.tts_allowed = conf['WHITELIST_USER']
def connect(self, server, port, channel, botnick, botpass):
logging.info("Connecting to: " + server)
try:
@ -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,11 +198,16 @@ class IRC:
return False
if conf['WHITELIST']:
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
logging.info('Valid TTS message, adding to raw queue')
tts = True
@ -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()