python-wechaty icon indicating copy to clipboard operation
python-wechaty copied to clipboard

如何获得一个可用的Wechaty对象

Open r-hou opened this issue 5 years ago • 1 comments

Describe the desired 你好,我读了example里面的代码发现机器人都是继承Wechaty基类来通过自定义回调函数来实现各种功能。利用回调函数这样是很被动的,我想得到一个可直接调用的Wechaty对象,不通过start()进入循环监听, 而可以主动的发送信息,请问应该怎么实现? 需求伪代码:

bot = Wechaty()
room = await bot.Room.find({"topic":"xxxx"})
await room.say("hello")

期待得到您的帮助!

r-hou avatar Mar 29 '21 16:03 r-hou

I think this is a simple question. You only just set the bot as the global accessible variable to say something to room/contact. But you should say something after on_ready event.

I hope it can help you to fix your problem.

wj-Mcat avatar Apr 17 '21 14:04 wj-Mcat