From 9254a7500ed508c1f206a911d6d3254f82b4e206 Mon Sep 17 00:00:00 2001 From: Cam Date: Tue, 8 Feb 2022 11:19:04 +0800 Subject: [PATCH] update nothing --- LICENSE | 2 +- app.py | 2 +- blive/core.py | 1 + blive/framework.py | 7 +++++++ requirements.txt | 1 - 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 4379f7a..f3715ee 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) [2020] [yulinfeng] +Copyright (c) 2020 LinFeng Yu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app.py b/app.py index e55b0c9..d4f7042 100644 --- a/app.py +++ b/app.py @@ -14,7 +14,7 @@ app = BLiver(605) async def listen(ctx: BLiverCtx): danmu = DanMuMsg(ctx.body) print( - f"\n{danmu.sender['name']}({danmu.sender['medal']['medal_name']}:{danmu.sender['medal']['medal_level']}): \"{danmu.content}\"\n " + f"\n{danmu.sender['name']}({danmu.sender['medal']['medal_name']}:{danmu.sender['medal']['medal_level']}): \"{danmu.content}\"\n" ) diff --git a/blive/core.py b/blive/core.py index f8b8c9d..6794c3b 100644 --- a/blive/core.py +++ b/blive/core.py @@ -211,6 +211,7 @@ packman = BWS_MsgPackage() class Events(str, enum.Enum): + LIVE = "LIVE" # 主播开播 PREPARING = "PREPARING" # 下播【结束语】 ROOM_CHANGE = "ROOM_CHANGE" # 房间信息改变 ROOM_RANK = "ROOM_RANK" # 排名改变 diff --git a/blive/framework.py b/blive/framework.py index 09f7b3d..f4de1fb 100644 --- a/blive/framework.py +++ b/blive/framework.py @@ -97,6 +97,9 @@ class BLiver: return f_wrapper + def register_handler(self, event: Union[Events, List[Events]], handler): + self.processor.register(event, handler) + def scheduled( self, trigger, @@ -171,3 +174,7 @@ class BLiver: loop = asyncio.get_event_loop() loop.create_task(self.listen()) loop.run_forever() + + def run_as_task(self): + loop = asyncio.get_event_loop() + return loop.create_task(self.listen()) diff --git a/requirements.txt b/requirements.txt index d9b9d7f..20f1586 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ async-timeout==4.0.2 asynctest==0.13.0 attrs==21.4.0 backports.zoneinfo==0.2.1 -black==21.12b0 Brotli==1.0.9 cchardet==2.1.7 certifi==2021.10.8