Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wechaty - ERROR - internal error <> #88

Open
yangningmoojing opened this issue Apr 13, 2023 · 4 comments
Open

Wechaty - ERROR - internal error <> #88

yangningmoojing opened this issue Apr 13, 2023 · 4 comments

Comments

@yangningmoojing
Copy link

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

@yangningmoojing
Copy link
Author

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
Copy link

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

@Pengchengistaken
Copy link

+1,mark

@lizihao001
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants