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

每次都是报这个错

Open Lny-nice opened this issue 4 years ago • 13 comments

Traceback (most recent call last): File "E:/python-wechaty/examples/ding-dong-bot-oop.py", line 7, in from wechaty_puppet import FileBox # type: ignore File "E:\python-wechaty\venv\lib\site-packages\wechaty_puppet_init_.py", line 6, in from .schemas.types import ( # type: ignore File "E:\python-wechaty\venv\lib\site-packages\wechaty_puppet\schemas\types.py", line 23, in from chatie_grpc.wechaty import ( # type: ignore File "E:\python-wechaty\venv\lib\site-packages\chatie_grpc\wechaty_init_.py", line 7, in import betterproto File "E:\python-wechaty\venv\lib\site-packages\betterproto_init_.py", line 27, in import grpclib.client File "E:\python-wechaty\venv\lib\site-packages\grpclib\client.py", line 26, in from .protocol import H2Protocol, AbstractHandler, Stream as _Stream, Peer File "E:\python-wechaty\venv\lib\site-packages\grpclib\protocol.py", line 22, in from h2.events import StreamReset, PriorityUpdated, PingAcknowledged ImportError: cannot import name 'PingAcknowledged' from 'h2.events' (E:\python-wechaty\venv\lib\site-packages\h2\events.py)

Lny-nice avatar Mar 06 '21 09:03 Lny-nice

You should upgrade the version of wechaty: wechaty~=0.7dev15

Please tell me more if you have try it.

wj-Mcat avatar Mar 06 '21 10:03 wj-Mcat

Your service token has no available endpoint, is your token correct?' wechaty_puppet.exceptions.WechatyPuppetGrpcError: WechatyPuppetGrpcError('Your service token has no available endpoint, is your token correct?', None, None)

Lny-nice avatar Mar 06 '21 12:03 Lny-nice

First, you should get the endpoint from https://api.chatie.io/v0/hosties/--your-token--. If it is not accessible, you should contact the token provider to check the status of your token. If you use Padlocal token, you should learn to start local server to provide local protocol service. Please refer to: https://github.com/wechaty/wechaty/discussions/1985

Second, if your endpoint is accessiable, please check the server grpc service status, so you can connect it with more happy.

If you also can't resolve your problem, you can try to restart your network, and provide more details info(token type, wechaty related package version, python version, os version, more ...) so we can help you resolve your problem.

wj-Mcat avatar Mar 06 '21 15:03 wj-Mcat

thank you.

Lny-nice avatar Mar 07 '21 03:03 Lny-nice

How to pull friends into WeChat group?

Lny-nice avatar Mar 07 '21 06:03 Lny-nice

How to pull friends into WeChat group?

There are a lot of common Add, Delete features in Room, Contact, Friendship, Tag modules, and all of api name is same. You can refer to this issue, and try to write add friend into WeChat Group.

Hope you can have more compression about wechaty. If you have any problems, please feel free to tell us.

wj-Mcat avatar Mar 07 '21 07:03 wj-Mcat

python-wechaty好像文档也没有太完善 可以添加好友,但是不知道怎么拉入群,能给一段代码示例吗?

Lny-nice avatar Mar 07 '21 07:03 Lny-nice

python-wechaty好像文档也没有太完善 可以添加好友,但是不知道怎么拉入群,能给一段代码示例吗?

https://github.com/wechaty/python-wechaty-getting-started/blob/master/examples/advanced/room_bot.py

why2lyj avatar Mar 07 '21 07:03 why2lyj

Of course, there are a lot of on going improvements in wechaty.js.org website, which we are writing for polyglot wechaty.

Anyway, you can refer to this code: https://github.com/wechaty/python-wechaty-getting-started/blob/master/examples/advanced/room-member-bot.py

As you can see, there are a lot example bots in python-wechaty-getting-started. It's a great place you can learn.

wj-Mcat avatar Mar 07 '21 08:03 wj-Mcat

你好,我运行这个文件结果就是把所有群的群成员打印在了控制台

Lny-nice avatar Mar 07 '21 08:03 Lny-nice

async def on_ready(self, payload):
        """all of initialization jobs shoule be done here.
        """
        log.info('ready event<%s>', payload)
        # search contact and add them to the specific room
        room: Optional[Room] = await self.Room.find(query=RoomQueryFilter(topic='room-topic-name'))
        if not room:
            return
        contacts: List[Contact] = await self.Contact.find_all()

        for contact in contacts:
            await contact.ready()
            if contact.name == 'your-friend-name':    
                await room.add(contact)

'your-friend-name': 这个是填写朋友备注呢还是什么 room-topic-name是群名称吗?

Lny-nice avatar Mar 07 '21 08:03 Lny-nice

@lccnidaye your-friend-name and room-topic-name you can print the data of your friends & Room, so you will know the meaning of them. This is a basic skill that developers must master, you should have a try. Good luck to you.

wj-Mcat avatar Mar 08 '21 04:03 wj-Mcat

@lccnidaye your-friend-nameroom-topic-name您可以打印朋友和房间的数据,因此您将了解它们的含义。这是开发人员必须掌握的一项基本技能,您应该尝试一下。祝你好运。

Room find() confirm room[#0] with id=17761739330@chatroom is valid result, return it.

Lny-nice avatar Mar 29 '21 14:03 Lny-nice