You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from wechaty.plugin import WechatyPlugin
from wechaty import Contact, Message, Room, Wechaty
from wechaty.wechaty import WechatyOptions
from wechaty_puppet import get_logger
logger = get_logger("wechaty_robot_py")
class WechatyRobotPlugin(WechatyPlugin):
def init(self):
super().init()
async def init_plugin(self, wechaty: Wechaty) -> None:
return await super().init_plugin(wechaty)
async def on_message(self, msg: Message) -> None:
is_mention_robot = await msg.mention_self()
is_self = msg.talker().is_self()
conversation :Union[Room, Contact] = msg.talker() if msg.room() is None else msg.room()
mention_users = None
if is_mention_robot:
mention_users = [msg.talker().contact_id]
is_room = msg.room()
if is_room is None and conversation.get_id().__eq__("weixin"):
return
if "HandOffMaster" in msg.text():
return
if "weixin://dl/feedback?from=" in msg.text():
return
if is_self is not True and (
(is_room is not None and is_mention_robot and "#" not in msg.text()) or
(is_room is None and "#" not in msg.text())
):
logger.info(f"开始处理对话, 对话内容为 {msg.text()}")
await msg.say("hello!")
Environment
Description
Minimum reproducible code
import asyncio
from typing import Union
from wechaty.plugin import WechatyPlugin
from wechaty import Contact, Message, Room, Wechaty
from wechaty.wechaty import WechatyOptions
from wechaty_puppet import get_logger
logger = get_logger("wechaty_robot_py")
class WechatyRobotPlugin(WechatyPlugin):
def init(self):
super().init()
async def main():
import os
os.environ["WECHATY_PUPPET"] = "wechaty-puppet-service"
os.environ["WECHATY_PUPPET_SERVICE_TOKEN"] = "7be027c2-4376-49e3-9853-462f69eee0c2"
os.environ["WECHATY_PUPPET_SERVICE_ENDPOINT"] = "192.168.x.x:8788"
options = WechatyOptions(port=8788, host="192.168.x.x", token="7be027c2-4376-49e3-9853-462f69eee0c2")
if name == "main":
asyncio.run(main())
The text was updated successfully, but these errors were encountered: