mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-04 21:06:03 +00:00
add support for markdown card in dingtalk & tg
This commit is contained in:
@@ -10,7 +10,7 @@ import traceback
|
||||
|
||||
|
||||
class DingTalkClient:
|
||||
def __init__(self, client_id: str, client_secret: str,robot_name:str,robot_code:str):
|
||||
def __init__(self, client_id: str, client_secret: str,robot_name:str,robot_code:str,markdown_card:bool):
|
||||
"""初始化 WebSocket 连接并自动启动"""
|
||||
self.credential = dingtalk_stream.Credential(client_id, client_secret)
|
||||
self.client = dingtalk_stream.DingTalkStreamClient(self.credential)
|
||||
@@ -26,6 +26,7 @@ class DingTalkClient:
|
||||
self.robot_name = robot_name
|
||||
self.robot_code = robot_code
|
||||
self.access_token_expiry_time = ''
|
||||
self.markdown_card = markdown_card
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +129,10 @@ class DingTalkClient:
|
||||
|
||||
|
||||
async def send_message(self,content:str,incoming_message):
|
||||
self.EchoTextHandler.reply_text(content,incoming_message)
|
||||
if self.markdown_card:
|
||||
self.EchoTextHandler.reply_markdown(title=self.robot_name+'的回答',text=content,incoming_message=incoming_message)
|
||||
else:
|
||||
self.EchoTextHandler.reply_text(content,incoming_message)
|
||||
|
||||
|
||||
async def get_incoming_message(self):
|
||||
|
||||
@@ -131,7 +131,8 @@ class DingTalkAdapter(adapter.MessagePlatformAdapter):
|
||||
client_id=config["client_id"],
|
||||
client_secret=config["client_secret"],
|
||||
robot_name = config["robot_name"],
|
||||
robot_code=config["robot_code"]
|
||||
robot_code=config["robot_code"],
|
||||
markdown_card=config["markdown_card"]
|
||||
)
|
||||
|
||||
async def reply_message(
|
||||
|
||||
@@ -207,6 +207,9 @@ class TelegramAdapter(adapter.MessagePlatformAdapter):
|
||||
"text": component['text'],
|
||||
}
|
||||
|
||||
if self.config['markdown_card'] is True:
|
||||
args["parse_mode"] = "MarkdownV2"
|
||||
|
||||
if quote_origin:
|
||||
args['reply_to_message_id'] = message_source.source_platform_object.message.id
|
||||
|
||||
|
||||
@@ -88,12 +88,14 @@
|
||||
"client_id":"",
|
||||
"client_secret":"",
|
||||
"robot_code":"",
|
||||
"robot_name":""
|
||||
"robot_name":"",
|
||||
"markdown_card":false
|
||||
},
|
||||
{
|
||||
"adapter":"telegram",
|
||||
"enable": false,
|
||||
"token":""
|
||||
"token":"",
|
||||
"markdown_card":false
|
||||
},
|
||||
{
|
||||
"adapter":"slack",
|
||||
|
||||
Reference in New Issue
Block a user