wechaty / python-wechaty-puppet-itchat Goto Github PK
View Code? Open in Web Editor NEWPython Wechaty Puppet Powered by Itchat
License: Apache License 2.0
Python Wechaty Puppet Powered by Itchat
License: Apache License 2.0
Error, "KeyError: 'wxsid'", occured after scanning qrcode and confirming on mobile phone.
import asyncio
from wechaty import Wechaty
from wechaty_puppet_itchat import PuppetItChat
option = {
'WECHATY_PUPPET': "wechaty-puppet-service",
'WECHATY_PUPPET_SERVICE_ENDPOINT': "127.0.0.1:5000"
}
bot = Wechaty(PuppetItChat(option))
bot.on('message', lambda x: print(x))
asyncio.run(bot.start())
Traceback (most recent call last):
File "wx_bot_itchat.py", line 13, in <module>
asyncio.run(bot.start())
File "C:\XYA\anaconda3\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\XYA\anaconda3\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\XYA\anaconda3\lib\site-packages\wechaty\wechaty.py", line 419, in start
await self.puppet.start()
File "C:\XYA\anaconda3\lib\site-packages\wechaty_puppet_itchat\puppet.py", line 984, in start
await self._listen_for_event()
File "C:\XYA\anaconda3\lib\site-packages\wechaty_puppet_itchat\puppet.py", line 1059, in _listen_for_event
await self.itchat.auto_login(
File "C:\XYA\anaconda3\lib\site-packages\wechaty_puppet_itchat\itchat\components\register.py", line 32, in auto_login
await self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback, EventScanPayload=EventScanPayload, ScanStatus=ScanStatus, event_stream=event_stream,
File "C:\XYA\anaconda3\lib\site-packages\wechaty_puppet_itchat\itchat\components\login.py", line 65, in login
status = await self.check_login()
File "C:\XYA\anaconda3\lib\site-packages\wechaty_puppet_itchat\itchat\components\login.py", line 181, in check_login
if await process_login_info(self, r.text):
File "C:\XYA\anaconda3\lib\site-packages\wechaty_puppet_itchat\itchat\components\login.py", line 223, in process_login_info
core.loginInfo['wxsid'] = core.loginInfo['BaseRequest']['Sid'] = cookies["wxsid"]
KeyError: 'wxsid'
I didn't use docker (It might be the reason why error occured?)
CI (Continuous integration) is the key tools that can keep the quality of project. It will create the strict rule for all of developers . It's only when pr pass the CI test, it will be merged into master branch. Please refer to: Makefile to add CI test to this repo. I will review the new pr.
CD(continuous delivery) will delivery the new version of package when it arises the new change. Eg, when the new pr is merged into the python-wechaty repo, it will automatically deploy the new wechaty by CD.
CICD is the base structure for the good opensource project, this repo should add it.
itchat 1.3.10
itchat-uos 1.5.0.dev0
wechaty 0.10.7
wechaty-grpc 0.20.19
wechaty-puppet 0.4.23
wechaty-puppet-itchat 0.0.6
wechaty-puppet-service 0.8.10
为什么有的账户可以登陆,但有的账户不能登陆,显示错误信息为:
list index out of range
A clear and concise description of what the bug is.
simple code to reproduce your problem
# copy your log info at here from your terminal
please tell us your experiments and ideas about this issue. It's valuable for us to help you find the solution.
If there are any improvements, we should feedback to the upper stream to keep the community and ecosystem as healthy as they can.
My suggestion would be that we should switch to use the dependency of itchat
before we release this project officially.
Related discussion:
尝试搭建一个发送文字到指定微信用户的API,使用了itchat的search_friends方法,运行非常慢。
async def friendship_search(self, weixin: Optional[str] = None,
name : Optional[str] = None,
phone: Optional[str] = None) -> Optional[str]:
"""
search friendship by wexin/phone
:param weixin:
:param phone:
:return:
"""
# TODO: itchat can't get contact's phone number, so phone search can't be used.
if weixin is not None:
weixin_response = await self.contact_payload(contact_id=weixin)
if weixin_response is not None:
return weixin_response.id
elif name is not None:
weixin_response = self.itchat.search_friends(nickName= name)
if weixin_response is not None:
return weixin_response
return weixin_response
INFO: 127.0.0.1:64207 - "POST /search_friends HTTP/1.1" 200 OK
# copy your log info at here from your terminal
是否是因为好友列表太多,导致查找缓慢,是否有好的解决方法。
wechaty_puppet.exceptions.WechatyPuppetConfigurationError: WechatyPuppetConfigurationError('wechaty-puppet-service: token not found. please set environment<WECHATY_PUPPET_SERVICE_TOKEN|TOKEN|token> as token', None, None)
Please tell me where to set the token?
Because the Core
object is the interface of async components
, it will lead to many linting issues. We should make some changes in itchat-uos project to make the puppet-itchat pass the linting test.
Related to: why2lyj/ItChat-UOS#3
2021-09-28 16:42:08,275 - RoomBot - ERROR - should ready() the ContactSelf payload before get it, please call the <ready()> method
Traceback (most recent call last):
File "d:\github\python-wechaty-puppet-itchat\examples\hotreload_bot.py", line 140, in send_report
contact = await bot.Contact.find(query=ContactQueryFilter(name=str3))
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty\user\contact.py", line 110, in find
contact_list = await cls.find_all(query)
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty\user\contact.py", line 158, in find_all
contacts
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty\user\contact.py", line 152, in
lambda x: x.payload and (
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty\accessory.py", line 80, in payload
type(self).name
ValueError: should ready() the ContactSelf payload before get it, please call the <ready()> method
A beautiful image for Itchat would be great if we can find one.
Issue template can help developer post clear problem description at here, so that we can get the key info from it with less conversation.
You can refer to issue templates from python-wechaty. @lyleshaw how do you think about it?
使用示例中的room-bot时,获取不到room,一直为空;私聊可正常使用。
当我发送文字 [泽@Home 9]:没问题,发#ding 时,异常退出了。
Traceback (most recent call last):
File "d:/github/python-wechaty-puppet-itchat/examples/ding-dong-bot.py", line 17, in
asyncio.run(main())
File "D:\ProgramData\Anaconda3\envs\py37\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "D:\ProgramData\Anaconda3\envs\py37\lib\asyncio\base_events.py", line 587, in run_until_complete
return future.result()
File "d:/github/python-wechaty-puppet-itchat/examples/ding-dong-bot.py", line 16, in main
await bot.start()
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty\wechaty.py", line 419, in start
await self.puppet.start()
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddict_major_.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 913, in start
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddict_major_.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 1089, in listen_for_event
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddict_major.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 1086, in run
File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddict_major_.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 1078, in reply_fn
File "d:/github/python-wechaty-puppet-itchat\src\itchat\components\register.py", line 48, in configured_reply
message_container[msg['MsgId']] = msg
File "d:/github/python-wechaty-puppet-itchat\src\itchat\storage\messagequeue.py", line 26, in getitem
return super(Message, self).getitem(value)
KeyError: 'MsgId'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.