fix isqueryclient and connection errors

This commit is contained in:
Lukas 2021-09-27 14:24:49 +02:00
parent 71a6aa71ca
commit 35c64cea14
1 changed files with 18 additions and 22 deletions

View File

@ -48,26 +48,22 @@ class TSbot:
self.pipeOut(f"Trying to connect to: {self.host}:{self.port}")
try:
with ts3.query.TS3Connection(self.host, self.port) as self.bot:
try:
self.bot.login(client_login_name=self.user, client_login_password=self.pwd)
self.bot.use(sid=self.sid)
except ts3.query.TS3QueryError:
self.pipeOut("Invalid login credentials, please check your '.toml' file.", lvl="CRITICAL")
try:
self.bot.clientupdate(client_nickname=self.nickname)
except ts3.query.TS3QueryError:
self.pipeOut("Nickname already in use", lvl="WARNING")
pass
with ts3.query.TS3Connection(self.host, self.port) as self.bot:
try:
self.bot.login(client_login_name=self.user, client_login_password=self.pwd)
self.bot.use(sid=self.sid)
except ts3.query.TS3QueryError:
self.pipeOut("Invalid login credentials, please check your '.toml' file.", lvl="CRITICAL")
try:
self.bot.clientupdate(client_nickname=self.nickname)
except ts3.query.TS3QueryError as e:
self.pipeOut("Nickname is already in use", lvl="WARNING")
pass
self.pipeOut(f"Successfully connected as: {self.nickname}")
self.pipeOut(f"Successfully connected as: {self.nickname}")
# Start the Bot
self.loop()
except ts3.query.TS3QueryError as e:
self.pipeOut(e, lvl="CRITICAL")
# Start the Bot
self.loop()
def loop(self):
"""
@ -150,7 +146,7 @@ class TSbot:
self.pipeOut(f"Client [{displayname}] connected.")
# Check if the connector is a ServerQuery or not
if not self.isqueryclient(event[0]["client_unique_identifier"]):
if not self.isqueryclient(event[0]["clid"]):
self.pipeOut(f"* {event[0]}", lvl="debug")
# Check if the connector is an Admin
if self.isadmin(event[0]["client_database_id"]):
@ -195,9 +191,9 @@ class TSbot:
self.log.log(lvln, msg)
if reprint:
print(f"[{time.strftime('%H:%M:%S')}][{lvl}] {msg}")
print(f"[{time.strftime('%H:%M:%S')}]{f'[{lvl}]':10s} {msg}")
if lvl == "CRITICAL" or lvl == "ERROR":
if lvl == "CRITICAL":
exit(1)
def stop(self, invkr_id):
@ -337,7 +333,7 @@ class TSbot:
"""
client = self.bot.clientinfo(clid=clid)
if client["client_type"] == "1":
if client[0]["client_type"] == "1":
self.pipeOut(f"[{clid}] ISQUERY: True")
return True
else: