mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-03-03 12:24:21 +08:00
238 lines
7.6 KiB
Python
238 lines
7.6 KiB
Python
from nonebot.adapters.ding.event import GroupMessageEvent, PrivateMessageEvent
|
|
from nonebot.rule import to_me
|
|
from nonebot.plugin import on_command
|
|
from nonebot.adapters.ding import Bot as DingBot, MessageSegment, MessageEvent
|
|
|
|
helper = on_command("ding_helper", to_me())
|
|
|
|
|
|
@helper.handle()
|
|
async def ding_helper(bot: DingBot, event: MessageEvent):
|
|
message = MessageSegment.markdown(
|
|
"Hello, This is NoneBot",
|
|
"""帮助信息如下:\n
|
|
[ding_helper](dtmd://dingtalkclient/sendMessage?content=ding_helper) 查看帮助\n
|
|
[markdown](dtmd://dingtalkclient/sendMessage?content=markdown) 发送 markdown\n
|
|
[actionCardSingleBtn](dtmd://dingtalkclient/sendMessage?content=actionCardSingleBtn)\n
|
|
[actionCard](dtmd://dingtalkclient/sendMessage?content=actionCard)\n
|
|
[feedCard](dtmd://dingtalkclient/sendMessage?content=feedCard)\n
|
|
[atme](dtmd://dingtalkclient/sendMessage?content=atme)\n
|
|
[image](dtmd://dingtalkclient/sendMessage?content=image)\n
|
|
[t](dtmd://dingtalkclient/sendMessage?content=t)\n
|
|
[code](dtmd://dingtalkclient/sendMessage?content=code) 发送代码\n
|
|
[test_message](dtmd://dingtalkclient/sendMessage?content=test_message)\n
|
|
[hello](dtmd://dingtalkclient/sendMessage?content=hello)\n
|
|
[webhook](dtmd://dingtalkclient/sendMessage?content=webhook)""",
|
|
)
|
|
await markdown.finish(message)
|
|
|
|
|
|
markdown = on_command("markdown", to_me())
|
|
|
|
|
|
@markdown.handle()
|
|
async def markdown_handler(bot: DingBot):
|
|
message = MessageSegment.markdown(
|
|
"Hello, This is NoneBot",
|
|
"#### NoneBot \n> Nonebot 是一款高性能的 Python 机器人框架\n> \n> [GitHub 仓库地址](https://github.com/nonebot/nonebot2) \n"
|
|
)
|
|
await markdown.finish(message)
|
|
|
|
|
|
actionCardSingleBtn = on_command("actionCardSingleBtn", to_me())
|
|
|
|
|
|
@actionCardSingleBtn.handle()
|
|
async def actionCardSingleBtn_handler(bot: DingBot):
|
|
message = MessageSegment.actionCardSingleBtn(
|
|
title="打造一间咖啡厅",
|
|
text=
|
|
" \n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划",
|
|
singleTitle="阅读全文",
|
|
singleURL="https://www.dingtalk.com/")
|
|
await actionCardSingleBtn.finish(message)
|
|
|
|
|
|
actionCard = on_command("actionCard", to_me())
|
|
|
|
|
|
@actionCard.handle()
|
|
async def actionCard_handler(bot: DingBot):
|
|
message = MessageSegment.raw({
|
|
"msgtype": "actionCard",
|
|
"actionCard": {
|
|
"title":
|
|
"乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
|
|
"text":
|
|
" \n\n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划",
|
|
"hideAvatar":
|
|
"0",
|
|
"btnOrientation":
|
|
"0",
|
|
"btns": [{
|
|
"title": "内容不错",
|
|
"actionURL": "https://www.dingtalk.com/"
|
|
}, {
|
|
"title": "不感兴趣",
|
|
"actionURL": "https://www.dingtalk.com/"
|
|
}]
|
|