parent
3e6c5d92a4
commit
cf5f5f508e
@ -2,17 +2,13 @@ import logging
|
|||||||
from asyncio import Queue, QueueFull
|
from asyncio import Queue, QueueFull
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
|
from ..bili.danmaku_client import DanmakuClient, DanmakuCommand, DanmakuListener
|
||||||
from .models import DanmuMsg, GiftSendMsg, GuardBuyMsg, SuperChatMsg
|
|
||||||
from .typing import DanmakuMsg
|
|
||||||
from ..bili.danmaku_client import (
|
|
||||||
DanmakuClient, DanmakuListener, DanmakuCommand
|
|
||||||
)
|
|
||||||
from ..bili.typing import Danmaku
|
from ..bili.typing import Danmaku
|
||||||
from ..utils.mixins import StoppableMixin
|
from ..utils.mixins import StoppableMixin
|
||||||
|
from .models import DanmuMsg, GiftSendMsg, GuardBuyMsg, SuperChatMsg
|
||||||
|
from .typing import DanmakuMsg
|
||||||
|
|
||||||
|
__all__ = ('DanmakuReceiver',)
|
||||||
__all__ = 'DanmakuReceiver',
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -39,10 +35,10 @@ class DanmakuReceiver(DanmakuListener, StoppableMixin):
|
|||||||
return await self._queue.get()
|
return await self._queue.get()
|
||||||
|
|
||||||
async def on_danmaku_received(self, danmu: Danmaku) -> None:
|
async def on_danmaku_received(self, danmu: Danmaku) -> None:
|
||||||
cmd = danmu['cmd']
|
cmd: str = danmu['cmd']
|
||||||
msg: DanmakuMsg
|
msg: DanmakuMsg
|
||||||
|
|
||||||
if cmd == DanmakuCommand.DANMU_MSG.value:
|
if cmd.startswith(DanmakuCommand.DANMU_MSG.value):
|
||||||
msg = DanmuMsg.from_danmu(danmu)
|
msg = DanmuMsg.from_danmu(danmu)
|
||||||
elif cmd == DanmakuCommand.SEND_GIFT.value:
|
elif cmd == DanmakuCommand.SEND_GIFT.value:
|
||||||
msg = GiftSendMsg.from_danmu(danmu)
|
msg = GiftSendMsg.from_danmu(danmu)
|
||||||
|
Loading…
Reference in New Issue
Block a user