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

不适配最新(2.2.2)urllib3库且降级(1.26.8)后会出现报错

Open kvx07 opened this issue 1 year ago • 1 comments

Environment

- wechaty:
- wechaty-puppet: 
- wechaty-puppet-service: 
- wechaty-plugin-contrib: 
- token type: padlocal|wxwork|xp
- the version of wechaty docker container: [0.65]

Description

ValueError: mutable default <class 'wechaty_puppet.schemas.puppet.PuppetOptions'> for field puppet_options is not allowed: use default_factory

Minimum reproducible code

from wechaty import Wechaty, Contact from wechaty.user import Message, Room

class MyBot(Wechaty):

async def on_message(self, msg: Message):
    """
    监听消息事件
    """
    if msg.self() or msg.type() != Message.Type.MESSAGE_TYPE_TEXT:
        # 如果是自己发的消息或者不是文本消息,则不处理
        return

    # 获取消息文本
    text = msg.text()

    # 判断是否是群聊消息
    room = msg.room()
    if room:
        # 检查是否被@了
        if msg.mention_self():
            await msg.say('你好,我是测试机器人')
    else:
        # 私聊消息直接回复
        await msg.say('你好,我是测试机器人')

async def main(): # 初始化机器人 bot = MyBot() # 启动机器人 await bot.start()

import asyncio

if name == 'main': asyncio.run(main())

kvx07 avatar Aug 06 '24 09:08 kvx07

完善一下环境所使用库的版本信息,方便问题排查。

doublewinter0 avatar Sep 11 '24 07:09 doublewinter0