mirror of
				https://gitlab.com/gpvkt/twitchtts.git
				synced 2025-10-31 17:17:35 +01:00 
			
		
		
		
	Minor changes
This commit is contained in:
		
							parent
							
								
									fa4e28a1ff
								
							
						
					
					
						commit
						ab9ae82984
					
				
					 3 changed files with 15 additions and 15 deletions
				
			
		|  | @ -32,7 +32,7 @@ By using Javascript for the actual TTS part it's not only very easy to access th | ||||||
| 
 | 
 | ||||||
| ### Configuration | ### Configuration | ||||||
| 
 | 
 | ||||||
| Adapt `config.yml` to your needs. Example: | Adapt `config.yml` to your needs. Please use `UTF-8` as encoding. Example: | ||||||
| 
 | 
 | ||||||
| ``` lang=yaml | ``` lang=yaml | ||||||
| irc: | irc: | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								bootstrap.min.css
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								bootstrap.min.css
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										19
									
								
								tts.py
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								tts.py
									
										
									
									
									
								
							|  | @ -821,17 +821,18 @@ def get_url(path=False): | ||||||
| 
 | 
 | ||||||
|     return url |     return url | ||||||
| 
 | 
 | ||||||
| def check_oauth_token(conf): | def check_oauth_token(): | ||||||
|     """ Check for valid authentication via Twitch API """ |     """ Check for valid authentication via Twitch API """ | ||||||
|  |     global conf # pylint: disable=global-statement,invalid-name | ||||||
|     logging.debug('Checking OAuth Token') |     logging.debug('Checking OAuth Token') | ||||||
|  | 
 | ||||||
|     try: |     try: | ||||||
|         url = 'https://id.twitch.tv/oauth2/validate' |         url = 'https://id.twitch.tv/oauth2/validate' | ||||||
|         oauth = "OAuth %s" % conf['IRC_OAUTH_TOKEN'].replace('oauth:','') |         oauth = "OAuth "+str(conf['IRC_OAUTH_TOKEN'].replace('oauth:','')) | ||||||
|         request = urllib.request.Request(url) |         request = urllib.request.Request(url) | ||||||
|         request.add_header('Authorization', oauth) |         request.add_header('Authorization', oauth) | ||||||
|         urllib.request.urlopen(request) |         urllib.request.urlopen(request) | ||||||
|     except HTTPError: |     except HTTPError: | ||||||
|         conf['IRC_OAUTH_TOKEN'] == "Invalid" |  | ||||||
|         logging.fatal('Twitch rejected your OAuth Token. Please check and generate a new one.') |         logging.fatal('Twitch rejected your OAuth Token. Please check and generate a new one.') | ||||||
|         logging.info('Please open http://%s:%s/token to generate your OAuth-Token.', conf['HTTP_BIND'], conf['HTTP_PORT']) |         logging.info('Please open http://%s:%s/token to generate your OAuth-Token.', conf['HTTP_BIND'], conf['HTTP_PORT']) | ||||||
| 
 | 
 | ||||||
|  | @ -842,12 +843,13 @@ def check_oauth_token(conf): | ||||||
|         conf = load_config() |         conf = load_config() | ||||||
|         check_oauth_token() |         check_oauth_token() | ||||||
| 
 | 
 | ||||||
|     logging.info('OAuth Token is valid \o/') |     logging.info('OAuth Token is valid.') | ||||||
|     return |     return conf | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
|     """Main loop""" |     """Main loop""" | ||||||
| 
 | 
 | ||||||
|  |     global conf # pylint: disable=global-statement,invalid-name | ||||||
|     conf = load_config() |     conf = load_config() | ||||||
| 
 | 
 | ||||||
|     lastreload = datetime.datetime.now() |     lastreload = datetime.datetime.now() | ||||||
|  | @ -862,7 +864,7 @@ def main(): | ||||||
| 
 | 
 | ||||||
|     http_thread = Thread(target=http_serve_forever, daemon=True, args=(httpd, )) |     http_thread = Thread(target=http_serve_forever, daemon=True, args=(httpd, )) | ||||||
|     http_thread.start() |     http_thread.start() | ||||||
|     check_oauth_token(conf) |     check_oauth_token() | ||||||
| 
 | 
 | ||||||
|     logging.info("Starting IRC bot") |     logging.info("Starting IRC bot") | ||||||
|     irc = IRC() |     irc = IRC() | ||||||
|  | @ -901,15 +903,14 @@ def main(): | ||||||
|             sys.exit() |             sys.exit() | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|  |     logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s') | ||||||
|  |     sys.tracebacklimit = 3 | ||||||
| 
 | 
 | ||||||
|     conf = {} |     conf = {} | ||||||
|     tts_done = [] |     tts_done = [] | ||||||
|     msg_queue_raw = [] |     msg_queue_raw = [] | ||||||
|     msg_queue = {} |     msg_queue = {} | ||||||
| 
 | 
 | ||||||
|     logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s') |  | ||||||
|     sys.tracebacklimit = 3 |  | ||||||
| 
 |  | ||||||
|     if sys.argv[1:]: |     if sys.argv[1:]: | ||||||
|         if sys.argv[1] == "--version": |         if sys.argv[1] == "--version": | ||||||
|             print('Simple TTS Bot') |             print('Simple TTS Bot') | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue