Skip to content

Commit 3b0895e

Browse files
committed
added new op "disconnect".
1 parent fbb0f10 commit 3b0895e

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

rpc_client.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,14 @@ def fix_characters(text: str, limit=30):
139139
class RpcClient:
140140

141141
def __init__(self, autostart: int = 0):
142-
self.version = 2.5
142+
self.version = 2.6
143143
self.last_data = {}
144144
self.tasks = []
145145
self.main_task = None
146146
self.config = config
147147
self.langs = langs
148148
self.session: Optional[aiohttp.ClientSession] = None
149+
self.closing = False
149150

150151
if os.path.isdir("./langs"):
151152

@@ -607,8 +608,10 @@ async def handle_socket(self, uri):
607608

608609
try:
609610
if not data['op']:
611+
print(data)
610612
continue
611613
except:
614+
traceback.print_exc()
612615
continue
613616

614617
bot_id = data.pop("bot_id", None)
@@ -618,6 +621,13 @@ async def handle_socket(self, uri):
618621

619622
bot_name = data.pop("bot_name", None)
620623

624+
if data['op'] == "disconnect":
625+
self.gui.update_log(f"op: {data['op']} | {uri} | reason: {data.get('reason')}",
626+
log_type="error")
627+
self.closing = True
628+
await ws.close()
629+
return
630+
621631
if bot_id:
622632
try:
623633
self.bots_socket[uri].add(bot_id)
@@ -671,6 +681,9 @@ async def handle_socket(self, uri):
671681

672682
await self.clear_users_presences(uri)
673683

684+
if self.closing:
685+
return
686+
674687
self.gui.update_log(
675688
f"Conexão perdida com o servidor: {uri} | Reconectando em {time_format(backoff)} seg. {repr(ws.exception())}",
676689
tooltip=True, log_type="error")

0 commit comments

Comments
 (0)