mirror of
				https://gitlab.com/gpvkt/twitchtts.git
				synced 2025-10-31 00:57:35 +01:00 
			
		
		
		
	Bugfix: Whitelist config values, Added favicon
This commit is contained in:
		
							parent
							
								
									aaecb44df2
								
							
						
					
					
						commit
						496a0f5a18
					
				
					 2 changed files with 21 additions and 7 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								favicon.ico
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								favicon.ico
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 318 B | 
							
								
								
									
										28
									
								
								tts.py
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								tts.py
									
										
									
									
									
								
							|  | @ -20,11 +20,11 @@ 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 = [] | ||||||
|  |         self.tts_allowed = [] | ||||||
|  |         self.tts_status = True | ||||||
|  | 
 | ||||||
|         if 'WHITELIST_USER' in conf: |         if 'WHITELIST_USER' in conf: | ||||||
|             self.tts_allowed = conf['WHITELIST_USER'] |             self.tts_allowed = conf['WHITELIST_USER'] | ||||||
|         else: |  | ||||||
|             self.tts_allowed = [] |  | ||||||
|         self.tts_status = True |  | ||||||
| 
 | 
 | ||||||
|     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) | ||||||
|  | @ -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,9 +198,14 @@ class IRC: | ||||||
|                         return False |                         return False | ||||||
| 
 | 
 | ||||||
|                 if conf['WHITELIST']: |                 if conf['WHITELIST']: | ||||||
|                     if not user in self.tts_allowed: |                     if self.tts_allowed: | ||||||
|                         logging.info('User is not on whitelist') |                         if not user in self.tts_allowed: | ||||||
|                         logging.info(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']) |                         self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['WHITELISTONLY']) | ||||||
|                         return False |                         return False | ||||||
| 
 | 
 | ||||||
|  | @ -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…
	
	Add table
		
		Reference in a new issue