wechaty / python-wechaty-getting-started

Python Wechaty Starter Project Template that Works Out-of-the-Box
https://gitpod.io/#https://github.com/wechaty/python-wechaty-getting-started
Apache License 2.0
185 stars 55 forks source link

Wechaty - ERROR - internal error <> #88

Open yangningmoojing opened 1 year ago

yangningmoojing commented 1 year ago

这个 wechaty 只能接收文字消息和发送文字消息, 图片,文件,这两个接收能读到类型,但是保存不了,发送也不行,都是报 - Wechaty - ERROR - internal error <> 这个还能用吗?是不是不支持python 了

yangningmoojing commented 1 year ago

import os from wechaty import Wechaty, FileBox, Message import asyncio

class MyBot(Wechaty):

async def on_message(self, msg: Message):

    if msg.type() == Message.Type.MESSAGE_TYPE_TEXT:
        text = msg.text()
        print("收到文本消息:", text)
    elif msg.type() == Message.Type.MESSAGE_TYPE_IMAGE:
        # 发送图片消息
        print('16hang',msg.to_file_box)
        file_box = await msg.to_file_box()
        await file_box.to_file('image.jpg', overwrite=True)
        # file_box = await msg.to_file_box()

        # print('12hang接收图片消息', file_box)
        # await file_box.to_file(file_box.name)

        # await msg.say(file_box)
    elif msg.type() == Message.Type.MESSAGE_TYPE_ATTACHMENT:
        # 转发文件消息
        file_box = await msg.to_file_box()
        contact = await self.Contact.find('7881300811905286')
        await contact.say(file_box)
        # file_box = await msg.to_file_box()
        # print('17hang发送文件消息',file_box)
        # await msg.say(file_box)

async def main(): bot = MyBot() await bot.start()

if name == 'main': try:

填入的还是你前面申请的token

    os.environ["WECHATY_PUPPET_SERVICE_TOKEN"] = "puppet_workpro_***"
    # docker运行的主机地址+端口
    os.environ["WECHATY_PUPPET_SERVICE_ENDPOINT"] = "127.0.0.1:8080"
    asyncio.run(main())
except Exception as e:
    print(e)
shengzhou1216 commented 1 year ago

可以重新扫码试试。手机扫码,如果手机上提示“Windows已登录”或“iPad已登录”,那么应该就可以了。

Pengchengistaken commented 11 months ago

+1,mark

lizihao001 commented 6 months ago

@yangningmoojing 问题解决了嘛 我遇到相似error,文件可以识别出来,但是不能保存到本地