Skip to content

Commit

Permalink
🔖 version 0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Dec 14, 2024
1 parent ca48240 commit 35e8d4f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
46 changes: 20 additions & 26 deletions nonebot/adapters/satori/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@
from .config import Config, ClientInfo
from .exception import ApiNotAvailable
from .models import Event as SatoriEvent
from .event import (
EVENT_CLASSES,
Event,
MessageEvent,
LoginAddedEvent,
InteractionEvent,
LoginRemovedEvent,
LoginUpdatedEvent,
)
from .event import EVENT_CLASSES, Event, MessageEvent, LoginAddedEvent, InteractionEvent, LoginRemovedEvent
from .models import (
Opcode,
Payload,
Expand Down Expand Up @@ -240,32 +232,34 @@ async def _loop(self, info: ClientInfo, ws: WebSocket):
e if payload.body["type"] != "internal" else None,
)
else:
if isinstance(event, LoginAddedEvent):
bot = Bot(self, event.login.sn, event.login, info, self.proxys[info.identity])
self._bots[info.identity].add(bot.self_id)
self.bot_connect(bot)
log(
"INFO",
f"<y>Bot {event.login.user.id if event.login.user else event.login.sn}</y> connected",
)
elif isinstance(event, LoginRemovedEvent):
if not (bot := self.bots.get(event.login.sn)):
if isinstance(event, LoginAddedEvent):
bot = Bot(self, event.login.sn, event.login, info, self.proxys[info.identity])
self._bots[info.identity].add(bot.self_id)
self.bot_connect(bot)
log(
"INFO",
f"<y>Bot {event.login.user.id if event.login.user else event.login.sn}</y> connected",
)
else:
log(
"WARNING",
f"Received event for unknown bot "
f"{event.login.user.id if event.login.user else event.login.sn}",
)
continue
if isinstance(event, LoginRemovedEvent):
self.bot_disconnect(self.bots[event.login.sn])
self._bots[info.identity].discard(event.login.sn)
log(
"INFO",
f"<y>Bot {event.login.user.id if event.login.user else event.login.sn}</y> disconnected",
)
continue
elif isinstance(event, LoginUpdatedEvent):
else:
self.bots[event.login.sn]._update(event.login)
self._bots[info.identity].add(event.login.sn)
if not (bot := self.bots.get(event.login.sn)):
log(
"WARNING",
f"Received event for unknown bot "
f"{event.login.user.id if event.login.user else event.login.sn}",
)
continue

if isinstance(event, (MessageEvent, InteractionEvent)):
event = event.convert()
_t = asyncio.create_task(bot.handle_event(event))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nonebot-adapter-satori"
version = "0.13.0"
version = "0.13.1"
description = "Satori Protocol Adapter for Nonebot2"
authors = [
{name = "RF-Tar-Railt",email = "[email protected]"},
Expand Down

0 comments on commit 35e8d4f

Please sign in to comment.