mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 19:37:36 +08:00
fix: forward msg send fail in lark and discord
This commit is contained in:
@@ -9,30 +9,8 @@ from ....core import entities as core_entities
|
|||||||
from ....platform.types import message as platform_message
|
from ....platform.types import message as platform_message
|
||||||
|
|
||||||
|
|
||||||
class ForwardMessageDiaplay(pydantic.BaseModel):
|
ForwardMessageDiaplay = platform_message.ForwardMessageDiaplay
|
||||||
title: str = "群聊的聊天记录"
|
Forward = platform_message.Forward
|
||||||
brief: str = "[聊天记录]"
|
|
||||||
source: str = "聊天记录"
|
|
||||||
preview: typing.List[str] = []
|
|
||||||
summary: str = "查看x条转发消息"
|
|
||||||
|
|
||||||
|
|
||||||
class Forward(platform_message.MessageComponent):
|
|
||||||
"""合并转发。"""
|
|
||||||
type: str = "Forward"
|
|
||||||
"""消息组件类型。"""
|
|
||||||
display: ForwardMessageDiaplay
|
|
||||||
"""显示信息"""
|
|
||||||
node_list: typing.List[platform_message.ForwardMessageNode]
|
|
||||||
"""转发消息节点列表。"""
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
if len(args) == 1:
|
|
||||||
self.node_list = args[0]
|
|
||||||
super().__init__(**kwargs)
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '[聊天记录]'
|
|
||||||
|
|
||||||
|
|
||||||
@strategy_model.strategy_class("forward")
|
@strategy_model.strategy_class("forward")
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ class DiscordMessageConverter(adapter.MessageConverter):
|
|||||||
image_files.append(discord.File(fp=image_bytes, filename=f"{uuid.uuid4()}.png"))
|
image_files.append(discord.File(fp=image_bytes, filename=f"{uuid.uuid4()}.png"))
|
||||||
elif isinstance(ele, platform_message.Plain):
|
elif isinstance(ele, platform_message.Plain):
|
||||||
text_string += ele.text
|
text_string += ele.text
|
||||||
|
elif isinstance(ele, platform_message.Forward):
|
||||||
|
for node in ele.node_list:
|
||||||
|
text_string, image_files = await DiscordMessageConverter.yiri2target(node.message_chain)
|
||||||
|
text_string += text_string
|
||||||
|
image_files.extend(image_files)
|
||||||
|
|
||||||
return text_string, image_files
|
return text_string, image_files
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ class LarkMessageConverter(adapter.MessageConverter):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
pending_paragraph = []
|
pending_paragraph = []
|
||||||
|
elif isinstance(msg, platform_message.Forward):
|
||||||
|
for node in msg.node_list:
|
||||||
|
message_elements.extend(await LarkMessageConverter.yiri2target(node.message_chain, api_client))
|
||||||
|
|
||||||
if pending_paragraph:
|
if pending_paragraph:
|
||||||
message_elements.append(pending_paragraph)
|
message_elements.append(pending_paragraph)
|
||||||
|
|||||||
@@ -785,10 +785,20 @@ class ForwardMessageNode(pydantic.BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ForwardMessageDiaplay(pydantic.BaseModel):
|
||||||
|
title: str = "群聊的聊天记录"
|
||||||
|
brief: str = "[聊天记录]"
|
||||||
|
source: str = "聊天记录"
|
||||||
|
preview: typing.List[str] = []
|
||||||
|
summary: str = "查看x条转发消息"
|
||||||
|
|
||||||
|
|
||||||
class Forward(MessageComponent):
|
class Forward(MessageComponent):
|
||||||
"""合并转发。"""
|
"""合并转发。"""
|
||||||
type: str = "Forward"
|
type: str = "Forward"
|
||||||
"""消息组件类型。"""
|
"""消息组件类型。"""
|
||||||
|
display: ForwardMessageDiaplay
|
||||||
|
"""显示信息"""
|
||||||
node_list: typing.List[ForwardMessageNode]
|
node_list: typing.List[ForwardMessageNode]
|
||||||
"""转发消息节点列表。"""
|
"""转发消息节点列表。"""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
"max": 0
|
"max": 0
|
||||||
},
|
},
|
||||||
"long-text-process": {
|
"long-text-process": {
|
||||||
"threshold": 256,
|
"threshold": 2560,
|
||||||
"strategy": "forward",
|
"strategy": "forward",
|
||||||
"font-path": ""
|
"font-path": ""
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user