Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c688c1c9b | ||
|
|
9d93dadae0 |
+10
-1
@@ -34,15 +34,20 @@ class Bot:
|
||||
self.joined = set()
|
||||
|
||||
async def run(self, reconnect=True):
|
||||
|
||||
while True:
|
||||
|
||||
try:
|
||||
await self.run_once()
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
if not reconnect:
|
||||
break
|
||||
|
||||
|
||||
|
||||
def has_joined(self, channel_uid):
|
||||
return channel_uid in self.joined
|
||||
|
||||
@@ -71,6 +76,9 @@ class Bot:
|
||||
pass
|
||||
|
||||
data = await rpc.receive()
|
||||
|
||||
if data is None:
|
||||
break
|
||||
|
||||
try:
|
||||
message = data.message.strip()
|
||||
@@ -97,6 +105,7 @@ class Bot:
|
||||
await self.on_message(data.username, data.user_nick, data.channel_uid, data.message)
|
||||
except AttributeError as ex:
|
||||
logger.exception(ex)
|
||||
raise
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
raise ex
|
||||
|
||||
|
||||
+1
-4
@@ -61,10 +61,7 @@ class RPC:
|
||||
async def method(*args, **kwargs):
|
||||
self.current_call_id = str(uuid.uuid4())
|
||||
payload = dict(method=name, args=args, kwargs=kwargs, callId=self.current_call_id)
|
||||
try:
|
||||
await self.ws.send_json(payload)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
await self.ws.send_json(payload)
|
||||
|
||||
async def returner():
|
||||
while True:
|
||||
|
||||
Reference in New Issue
Block a user