mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 08:46:02 +00:00
style: standardized component names
This commit is contained in:
@@ -47,16 +47,16 @@ class GewechatMessageConverter(adapter.MessageConverter):
|
|||||||
if not component.url:
|
if not component.url:
|
||||||
pass
|
pass
|
||||||
content_list.append({"type": "image", "image": component.url})
|
content_list.append({"type": "image", "image": component.url})
|
||||||
elif isinstance(component, platform_message.MiniPrograms):
|
elif isinstance(component, platform_message.WeChatMiniPrograms):
|
||||||
content_list.append({"type": 'MiniPrograms', 'mini_app_id': component.mini_app_id, 'display_name': component.display_name,
|
content_list.append({"type": 'WeChatMiniPrograms', 'mini_app_id': component.mini_app_id, 'display_name': component.display_name,
|
||||||
'page_path': component.page_path, 'cover_img_url': component.image_url, 'title': component.title,
|
'page_path': component.page_path, 'cover_img_url': component.image_url, 'title': component.title,
|
||||||
'user_name': component.user_name})
|
'user_name': component.user_name})
|
||||||
elif isinstance(component, platform_message.ForwardMiniPrograms):
|
elif isinstance(component, platform_message.WeChatForwardMiniPrograms):
|
||||||
content_list.append({"type": 'ForwardMiniPrograms', 'xml_data': component.xml_data, 'image_url': component.image_url})
|
content_list.append({"type": 'WeChatForwardMiniPrograms', 'xml_data': component.xml_data, 'image_url': component.image_url})
|
||||||
elif isinstance(component, platform_message.Emoji):
|
elif isinstance(component, platform_message.WeChatEmoji):
|
||||||
content_list.append({'type': 'emoji', 'emoji_md5': component.emoji_md5, 'emoji_size': component.emoji_size})
|
content_list.append({'type': 'WeChatEmoji', 'emoji_md5': component.emoji_md5, 'emoji_size': component.emoji_size})
|
||||||
elif isinstance(component, platform_message.Link):
|
elif isinstance(component, platform_message.WeChatLink):
|
||||||
content_list.append({'type': 'Link', 'link_title': component.link_title, 'link_desc': component.link_desc,
|
content_list.append({'type': 'WeChatLink', 'link_title': component.link_title, 'link_desc': component.link_desc,
|
||||||
'link_thumb_url': component.link_thumb_url, 'link_url': component.link_url})
|
'link_thumb_url': component.link_thumb_url, 'link_url': component.link_url})
|
||||||
|
|
||||||
|
|
||||||
@@ -372,16 +372,16 @@ class GeWeChatAdapter(adapter.MessagePlatformAdapter):
|
|||||||
elif msg['type'] == 'image':
|
elif msg['type'] == 'image':
|
||||||
|
|
||||||
self.bot.post_image(app_id=self.config['app_id'], to_wxid=target_id, img_url=msg["image"])
|
self.bot.post_image(app_id=self.config['app_id'], to_wxid=target_id, img_url=msg["image"])
|
||||||
elif msg['type'] == 'MiniPrograms':
|
elif msg['type'] == 'WeChatMiniPrograms':
|
||||||
self.bot.post_mini_app(app_id=self.config['app_id'], to_wxid=target_id, mini_app_id=msg['mini_app_id']
|
self.bot.post_mini_app(app_id=self.config['app_id'], to_wxid=target_id, mini_app_id=msg['mini_app_id']
|
||||||
, display_name=msg['display_name'], page_path=msg['page_path']
|
, display_name=msg['display_name'], page_path=msg['page_path']
|
||||||
, cover_img_url=msg['cover_img_url'], title=msg['title'], user_name=msg['user_name'])
|
, cover_img_url=msg['cover_img_url'], title=msg['title'], user_name=msg['user_name'])
|
||||||
elif msg['type'] == 'ForwardMiniPrograms':
|
elif msg['type'] == 'WeChatForwardMiniPrograms':
|
||||||
self.bot.forward_mini_app(app_id=self.config['app_id'], to_wxid=target_id, xml=msg['xml_data'], cover_img_url=msg['image_url'])
|
self.bot.forward_mini_app(app_id=self.config['app_id'], to_wxid=target_id, xml=msg['xml_data'], cover_img_url=msg['image_url'])
|
||||||
elif msg['type'] == 'emoji':
|
elif msg['type'] == 'WeChatEmoji':
|
||||||
self.bot.post_emoji(app_id=self.config['app_id'], to_wxid=target_id,
|
self.bot.post_emoji(app_id=self.config['app_id'], to_wxid=target_id,
|
||||||
emoji_md5=msg['emoji_md5'], emoji_size=msg['emoji_size'])
|
emoji_md5=msg['emoji_md5'], emoji_size=msg['emoji_size'])
|
||||||
elif msg['type'] == 'Link':
|
elif msg['type'] == 'WeChatLink':
|
||||||
self.bot.post_link(app_id=self.config['app_id'], to_wxid=target_id
|
self.bot.post_link(app_id=self.config['app_id'], to_wxid=target_id
|
||||||
,title=msg['link_title'], desc=msg['link_desc']
|
,title=msg['link_title'], desc=msg['link_desc']
|
||||||
, link_url=msg['link_url'], thumb_url=msg['link_thumb_url'])
|
, link_url=msg['link_url'], thumb_url=msg['link_thumb_url'])
|
||||||
@@ -421,16 +421,16 @@ class GeWeChatAdapter(adapter.MessagePlatformAdapter):
|
|||||||
elif msg['type'] == 'image':
|
elif msg['type'] == 'image':
|
||||||
|
|
||||||
self.bot.post_image(app_id=self.config['app_id'], to_wxid=target_id, img_url=msg["image"])
|
self.bot.post_image(app_id=self.config['app_id'], to_wxid=target_id, img_url=msg["image"])
|
||||||
elif msg['type'] == 'MiniPrograms':
|
elif msg['type'] == 'WeChatMiniPrograms':
|
||||||
self.bot.post_mini_app(app_id=self.config['app_id'], to_wxid=target_id, mini_app_id=msg['mini_app_id']
|
self.bot.post_mini_app(app_id=self.config['app_id'], to_wxid=target_id, mini_app_id=msg['mini_app_id']
|
||||||
, display_name=msg['display_name'], page_path=msg['page_path']
|
, display_name=msg['display_name'], page_path=msg['page_path']
|
||||||
, cover_img_url=msg['cover_img_url'], title=msg['title'], user_name=msg['user_name'])
|
, cover_img_url=msg['cover_img_url'], title=msg['title'], user_name=msg['user_name'])
|
||||||
elif msg['type'] == 'ForwardMiniPrograms':
|
elif msg['type'] == 'WeChatForwardMiniPrograms':
|
||||||
self.bot.forward_mini_app(app_id=self.config['app_id'], to_wxid=target_id, xml=msg['xml_data'], cover_img_url=msg['image_url'])
|
self.bot.forward_mini_app(app_id=self.config['app_id'], to_wxid=target_id, xml=msg['xml_data'], cover_img_url=msg['image_url'])
|
||||||
elif msg['type'] == 'emoji':
|
elif msg['type'] == 'WeChatEmoji':
|
||||||
self.bot.post_emoji(app_id=self.config['app_id'], to_wxid=target_id,
|
self.bot.post_emoji(app_id=self.config['app_id'], to_wxid=target_id,
|
||||||
emoji_md5=msg['emoji_md5'], emoji_size=msg['emoji_size'])
|
emoji_md5=msg['emoji_md5'], emoji_size=msg['emoji_size'])
|
||||||
elif msg['type'] == 'Link':
|
elif msg['type'] == 'WeChatLink':
|
||||||
self.bot.post_link(app_id=self.config['app_id'], to_wxid=target_id
|
self.bot.post_link(app_id=self.config['app_id'], to_wxid=target_id
|
||||||
, title=msg['link_title'], desc=msg['link_desc']
|
, title=msg['link_title'], desc=msg['link_desc']
|
||||||
, link_url=msg['link_url'], thumb_url=msg['link_thumb_url'])
|
, link_url=msg['link_url'], thumb_url=msg['link_thumb_url'])
|
||||||
|
|||||||
@@ -644,57 +644,6 @@ class Unknown(MessageComponent):
|
|||||||
"""文本。"""
|
"""文本。"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MiniPrograms(MessageComponent):
|
|
||||||
"""小程序"""
|
|
||||||
type: str = 'MiniPrograms'
|
|
||||||
"""小程序id"""
|
|
||||||
mini_app_id: str
|
|
||||||
"""小程序归属用户id"""
|
|
||||||
user_name: str
|
|
||||||
"""小程序名称"""
|
|
||||||
display_name: typing.Optional[str] = ''
|
|
||||||
"""打开地址"""
|
|
||||||
page_path: typing.Optional[str] = ''
|
|
||||||
"""小程序标题"""
|
|
||||||
title: typing.Optional[str] = ''
|
|
||||||
"""首页图片"""
|
|
||||||
image_url: typing.Optional[str] = ''
|
|
||||||
|
|
||||||
|
|
||||||
class ForwardMiniPrograms(MessageComponent):
|
|
||||||
"""转发小程序"""
|
|
||||||
type: str = 'ForwardMiniPrograms'
|
|
||||||
"""xml数据"""
|
|
||||||
xml_data: str
|
|
||||||
"""首页图片"""
|
|
||||||
image_url: typing.Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class Emoji(MessageComponent):
|
|
||||||
"""emoji表情"""
|
|
||||||
type: str = 'EmoJi'
|
|
||||||
"""emojimd5"""
|
|
||||||
emoji_md5: str
|
|
||||||
"""emoji大小"""
|
|
||||||
emoji_size: int
|
|
||||||
|
|
||||||
|
|
||||||
class Link(MessageComponent):
|
|
||||||
"""发送链接"""
|
|
||||||
type: str = 'Link'
|
|
||||||
"""标题"""
|
|
||||||
link_title: str = ''
|
|
||||||
"""链接描述"""
|
|
||||||
link_desc: str = ''
|
|
||||||
"""链接地址"""
|
|
||||||
link_url: str = ''
|
|
||||||
"""链接略缩图"""
|
|
||||||
link_thumb_url: str = ''
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Voice(MessageComponent):
|
class Voice(MessageComponent):
|
||||||
"""语音。"""
|
"""语音。"""
|
||||||
type: str = "Voice"
|
type: str = "Voice"
|
||||||
@@ -862,3 +811,52 @@ class File(MessageComponent):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'[文件]{self.name}'
|
return f'[文件]{self.name}'
|
||||||
|
|
||||||
|
# ================ 个人微信专用组件 ================
|
||||||
|
|
||||||
|
class WeChatMiniPrograms(MessageComponent):
|
||||||
|
"""小程序。个人微信专用组件。"""
|
||||||
|
type: str = 'WeChatMiniPrograms'
|
||||||
|
"""小程序id"""
|
||||||
|
mini_app_id: str
|
||||||
|
"""小程序归属用户id"""
|
||||||
|
user_name: str
|
||||||
|
"""小程序名称"""
|
||||||
|
display_name: typing.Optional[str] = ''
|
||||||
|
"""打开地址"""
|
||||||
|
page_path: typing.Optional[str] = ''
|
||||||
|
"""小程序标题"""
|
||||||
|
title: typing.Optional[str] = ''
|
||||||
|
"""首页图片"""
|
||||||
|
image_url: typing.Optional[str] = ''
|
||||||
|
|
||||||
|
|
||||||
|
class WeChatForwardMiniPrograms(MessageComponent):
|
||||||
|
"""转发小程序。个人微信专用组件。"""
|
||||||
|
type: str = 'WeChatForwardMiniPrograms'
|
||||||
|
"""xml数据"""
|
||||||
|
xml_data: str
|
||||||
|
"""首页图片"""
|
||||||
|
image_url: typing.Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
class WeChatEmoji(MessageComponent):
|
||||||
|
"""emoji表情。个人微信专用组件。"""
|
||||||
|
type: str = 'WeChatEmoji'
|
||||||
|
"""emojimd5"""
|
||||||
|
emoji_md5: str
|
||||||
|
"""emoji大小"""
|
||||||
|
emoji_size: int
|
||||||
|
|
||||||
|
|
||||||
|
class WeChatLink(MessageComponent):
|
||||||
|
"""发送链接。个人微信专用组件。"""
|
||||||
|
type: str = 'WeChatLink'
|
||||||
|
"""标题"""
|
||||||
|
link_title: str = ''
|
||||||
|
"""链接描述"""
|
||||||
|
link_desc: str = ''
|
||||||
|
"""链接地址"""
|
||||||
|
link_url: str = ''
|
||||||
|
"""链接略缩图"""
|
||||||
|
link_thumb_url: str = ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user