File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
astrbot/core/platform/sources/dingtalk Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,28 @@ async def send_with_client(
2525 client : dingtalk_stream .ChatbotHandler ,
2626 message : MessageChain ,
2727 ):
28+ icm = cast (dingtalk_stream .ChatbotMessage , self .message_obj .raw_message )
29+ ats = []
30+ # fixes: #4218
31+ # 钉钉 at 机器人需要使用 sender_staff_id 而不是 sender_id
32+ for i in message .chain :
33+ if isinstance (i , Comp .At ):
34+ print (i .qq , icm .sender_id , icm .sender_staff_id )
35+ if str (i .qq ) in str (icm .sender_id or "" ):
36+ # 适配器会将开头的 $:LWCP_v1:$ 去掉,因此我们用 in 判断
37+ ats .append (f"@{ icm .sender_staff_id } " )
38+ else :
39+ ats .append (f"@{ i .qq } " )
40+ at_str = " " .join (ats )
41+
2842 for segment in message .chain :
2943 if isinstance (segment , Comp .Plain ):
3044 segment .text = segment .text .strip ()
3145 await asyncio .get_event_loop ().run_in_executor (
3246 None ,
3347 client .reply_markdown ,
3448 segment .text ,
35- segment .text ,
49+ f" { at_str } { segment .text } " . strip () ,
3650 cast (dingtalk_stream .ChatbotMessage , self .message_obj .raw_message ),
3751 )
3852 elif isinstance (segment , Comp .Image ):
You can’t perform that action at this time.
0 commit comments