improve code quality
This commit is contained in:
		
							parent
							
								
									55665db5bb
								
							
						
					
					
						commit
						49e3de14a5
					
				
							
								
								
									
										22
									
								
								myTS3.py
								
								
								
								
							
							
						
						
									
										22
									
								
								myTS3.py
								
								
								
								
							|  | @ -4,7 +4,7 @@ TBD | |||
| 
 | ||||
| __author__ = "Lukas Mahler" | ||||
| __version__ = "0.0.0" | ||||
| __date__ = "06.10.2021" | ||||
| __date__ = "07.10.2021" | ||||
| __email__ = "m@hler.eu" | ||||
| __status__ = "Development" | ||||
| 
 | ||||
|  | @ -44,9 +44,8 @@ class TSbot: | |||
|         self.log = log | ||||
|         self.myid = None | ||||
|         self.running = True | ||||
|         self.intro = "<Keep this chat open to use commands>" | ||||
|         self.started = time.time() | ||||
|         self.last_crypto_update = self.started - 1800 | ||||
|         self.crypto_update = self.started - 1800 | ||||
| 
 | ||||
|         self.pipeOut(f"Trying to connect to: {self.host}:{self.port}") | ||||
| 
 | ||||
|  | @ -60,7 +59,7 @@ class TSbot: | |||
|             try: | ||||
|                 self.bot.clientupdate(client_nickname=self.nickname) | ||||
|             except ts3.query.TS3QueryError as e: | ||||
|                 self.pipeOut("Nickname is already in use", lvl="WARNING") | ||||
|                 self.pipeOut(e, lvl="WARNING") | ||||
|                 pass | ||||
| 
 | ||||
|             self.pipeOut(f"Successfully connected as: {self.nickname}") | ||||
|  | @ -117,8 +116,8 @@ class TSbot: | |||
|             self.bot.version() | ||||
| 
 | ||||
|             # Auto-update crypto price channels every 30 minutes | ||||
|             if self.last_crypto_update + 1800 < time.time(): | ||||
|                 self.last_crypto_update = time.time() | ||||
|             if self.crypto_update + 1800 < time.time(): | ||||
|                 self.crypto_update = time.time() | ||||
| 
 | ||||
|                 self.lookupcommand(".btc", self.myid) | ||||
|                 self.lookupcommand(".dot", self.myid) | ||||
|  | @ -148,7 +147,7 @@ class TSbot: | |||
|                         displayname = event[0]['clid'] | ||||
|                     else: | ||||
|                         self.pipeOut(event[0]) | ||||
|                         displayname = "Unresolved" | ||||
|                         # displayname = "Unresolved" | ||||
|                         continue  # can't resolve no clid | ||||
| 
 | ||||
|                     self.pipeOut(f"Client [{displayname}] connected.") | ||||
|  | @ -158,7 +157,8 @@ class TSbot: | |||
|                         self.pipeOut(f"* {event[0]}", lvl="debug") | ||||
|                         # Check if the connector is an Admin | ||||
|                         if self.isadmin(event[0]["client_database_id"]): | ||||
|                             self.bot.sendtextmessage(targetmode=1, target=event[0]["clid"], msg=self.intro) | ||||
|                             msg = "<Keep this chat open to use commands>" | ||||
|                             self.bot.sendtextmessage(targetmode=1, target=event[0]["clid"], msg=msg) | ||||
|                         else: | ||||
|                             pass | ||||
|                     else: | ||||
|  | @ -225,7 +225,8 @@ class TSbot: | |||
|             cldbid = client["client_database_id"] | ||||
|             clid = client["clid"] | ||||
|             if self.isadmin(cldbid): | ||||
|                 self.bot.sendtextmessage(targetmode=1, target=clid, msg=self.intro) | ||||
|                 msg = "<Keep this chat open to use commands>" | ||||
|                 self.bot.sendtextmessage(targetmode=1, target=clid, msg=msg) | ||||
| 
 | ||||
|             if not self.whitelisted: | ||||
|                 time.sleep(1) | ||||
|  | @ -238,11 +239,8 @@ class TSbot: | |||
|         clients = self.bot.clientlist() | ||||
|         clients = [client["clid"] for client in clients if client["client_type"] != "1"] | ||||
|         for clid in clients: | ||||
|             try: | ||||
|             self.bot.clientpoke(msg=msg, clid=clid) | ||||
|             # TODO | ||||
|             except: | ||||
|                 pass | ||||
| 
 | ||||
|     def poke(self, msg=None, n=10, delay=0.2, usr='all'): | ||||
|         """ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue