Comments (5)
这里的文档不是这个意思,内置消息类是一个抽象基类(abstract base class),文档中的代码只是一个例子,这里的文档不是很清晰,我之后改一下。
还有确实不支持文本中内嵌CQ码,因为AliceBot对此进行了封装,通过消息和消息段来实现富文本。
这里是使用CQHTTP适配器的发送富文本的例子:
from alicebot.plugin import Plugin
from alicebot.adapter.cqhttp.event import MessageEvent
from alicebot.adapter.cqhttp.message import CQHTTPMessage, CQHTTPMessageSegment
class Test(Plugin[MessageEvent, None]): # 这里的泛型参数参考插件进阶篇的插件类的泛型支持
async def handle(self) -> None:
msg = CQHTTPMessage()
for i in ["a", "b", "c"]:
msg += CQHTTPMessageSegment.text(i)
msg += CQHTTPMessageSegment.image("file:///path/temp.png")
await self.event.reply(msg)
async def rule(self) -> bool:
if self.event.adapter.name != "cqhttp":
return False
if self.event.type != "message":
return False
return True
from alicebot.
那么那个MessageSegment
类实际上有什么用途呢
from alicebot.
作为抽象类给其他具体的消息段类进行继承吗
from alicebot.
是的,它是提供给适配器开发者继承用的基类,不应该直接实例化,应该使用适配器提供的Message和MessageSegment
from alicebot.
好的,了解
from alicebot.
Related Issues (20)
- 请问怎么发送多张图片 HOT 2
- 有没有交流群 HOT 5
- 同一个插件内定义两个类会导致启动时不导入包 HOT 8
- 指南笔误? HOT 2
- 功能建议 HOT 1
- mirai适配器成功连接,但似乎接受不到消息 HOT 3
- 拼写错误 HOT 1
- 使用mirai http方式无法返回消息 HOT 2
- cqhttp适配器中PokeNotifyEvent、GroupLuckyKingNotifyEvent等事件缺失重要成员变量 HOT 2
- 添加bot退出时插件一次性执行的函数 HOT 1
- cqhttp的call_api方法获取内容可能为list HOT 1
- MiraiMessage 富文本组合时出现错误 HOT 5
- 这是一个小建议 HOT 1
- cqhttp无法将收到的消息转化成原生消息段数组 HOT 1
- AliceBot 插件商店实现计划
- 用于插件中的自定义配置在插件执行过程中被修改应如何保存? HOT 2
- Re: Adding the Footer into the AliceBot Website HOT 1
- 更新后错误 HOT 3
- [BugFix] 热重载在文件存在语法问题加载失败后再次更改文件不会进行热重载 HOT 1
- 关于pypi HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alicebot.