Closed ghost closed 1 year ago
from wechaty import Wechaty, FileBox, UrlLink, MiniProgram
import asyncio
class MyBot(Wechaty):
async def on_login(self, contact: Contact):
# 等待登入
room = await bot.Room.find('wechaty') # 可以根据 room 的 topic 和 id 进行查找
# 1. 向房间发送文本
await room.say('Hello world!')
文档里的 bot.Room.find 好像用不了,没有定义 bot
Ok, it's a stupid error in the document, we will fix it later.
If you use oop style to write your code, self
is the bot
, you can help yourself to fix it.
可不可以写一个在群里被@时,根据内容返回一个定义好的文本内容呢 的例子呀 谢谢
可不可以写一个在群里被@时,根据内容返回一个定义好的文本内容呢 的例子呀 谢谢
async def on_message(self, msg: Message) -> None:
if msg.is_self():
return
if (await msg.mention_self()):
# 获取艾特机器人后面的内容
keyword = await msg.mention_text()
text = '一些你定义好的语句'
await msg.say(text)
return
谢谢 xinxinyihao的帮助
作者你好,作为python小白,想请教一个问题,如何实现 在群里被@时,根据消息内容回复一个定义好的文本内容呀,我看了ding——dong 的机器人实现,好像只可以私聊的时候实现自动回复的。谢谢啦!!