Skip to content

Commit 6e56756

Browse files
committed
revert: "feat(bilibili): dynamic at propagation"
This reverts commit 909033f.
1 parent 909033f commit 6e56756

File tree

2 files changed

+16
-41
lines changed

2 files changed

+16
-41
lines changed

src/plugins/bilibili/plugins/dynamic/__init__.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -146,43 +146,26 @@ async def get_dynamics(page: int = 1) -> Dynamics:
146146

147147

148148
async def broadcast(dynamic: Dynamic):
149-
uids = {str(dynamic["modules"]["module_author"]["mid"])}
150-
151-
if dynamic["type"] in (
152-
"DYNAMIC_TYPE_DRAW",
153-
"DYNAMIC_TYPE_WORD",
154-
"DYNAMIC_TYPE_FORWARD",
155-
):
156-
if dynamic["type"] == "DYNAMIC_TYPE_FORWARD":
157-
nodes = dynamic["modules"]["module_dynamic"]["desc"]["rich_text_nodes"]
158-
else:
159-
nodes = dynamic["modules"]["module_dynamic"]["major"]["opus"]["summary"][
160-
"rich_text_nodes"
161-
]
162-
163-
for node in nodes:
164-
if node["type"] == "RICH_TEXT_NODE_TYPE_AT":
165-
uids.add(node["rid"])
166-
167-
sessions = {sub.session for uid in uids for sub in dynamic_subs.get(uid, ())}
168-
169-
if not sessions:
170-
return
171-
172149
screenshot, url = await gather(
173150
render_screenshot(dynamic),
174151
get_share_click(dynamic["id_str"], "dynamic", "dt.dt-detail.0.0.pv"),
175152
)
176-
message = plugin_config.template.format(
177-
name=dynamic["modules"]["module_author"]["name"],
178-
action=dynamic["modules"]["module_author"]["pub_action"]
179-
or plugin_config.types[dynamic["type"]],
180-
screenshot=Image(raw=screenshot),
181-
url=url,
153+
await gather(
154+
*[
155+
send_message(
156+
sub.session.session,
157+
plugin_config.template.format(
158+
name=dynamic["modules"]["module_author"]["name"],
159+
action=dynamic["modules"]["module_author"]["pub_action"]
160+
or plugin_config.types[dynamic["type"]],
161+
screenshot=Image(raw=screenshot),
162+
url=url,
163+
),
164+
)
165+
for sub in dynamic_subs[str(dynamic["modules"]["module_author"]["mid"])]
166+
]
182167
)
183168

184-
await gather(*(send_message(sess.session, message) for sess in sessions))
185-
186169

187170
@backoff.on_exception(backoff.constant, TimeoutError, max_tries=3)
188171
async def render_screenshot(dynamic: Dynamic) -> bytes:

src/plugins/bilibili/plugins/dynamic/models.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, TypedDict
1+
from typing import TypedDict
22

33
from nonebot_plugin_orm import Model
44
from nonebot_plugin_session_orm import SessionModel
@@ -12,17 +12,9 @@ class ModuleAuthor(TypedDict):
1212
pub_action: str
1313

1414

15-
type ModuleDynamic = dict[str, Any]
16-
17-
18-
class Modules(TypedDict):
19-
module_author: ModuleAuthor
20-
module_dynamic: ModuleDynamic
21-
22-
2315
class Dynamic(TypedDict):
2416
id_str: str
25-
modules: Modules
17+
modules: dict[{"module_author": ModuleAuthor}]
2618
type: str
2719

2820

0 commit comments

Comments
 (0)