Git Product home page Git Product logo

python-wechaty-puppet-itchat's Introduction

wechaty-puppet-itchat Python 3.7

Powered by Wechaty

Service

Python Puppet for Wechaty

Quick Start

Installation

pip install wechaty-puppet-itchat

Usage

import asyncio
from wechaty_puppet_itchat import PuppetItChat
from wechaty_puppet import PuppetOptions
from wechaty import Wechaty, WechatyOptions


async def main():
    options = WechatyOptions(
        puppet=PuppetItChat(PuppetOptions())
    )
    bot = Wechaty(options)
    await bot.start()

asyncio.run(main())

History

v0.0.6 (Oct 03, 2022)

  1. enable itchat great again by @fangjiyuan
  2. itchat example

v0.0.4 (October 12, 2021)

  1. Fix Bugs
  2. Move src/itchat to src/wechaty_puppet_itchat/itchat
  3. Add examples

v0.0.3 (September 27, 2021)

  1. Fix Bugs

v0.0.2 (September 18, 2021)

  1. Fix Bugs
  2. Add Receive Message

v0.0.1 (September 10, 2021)

  1. Add CI/CD
  2. Add Scan/Login
  3. Add Send Message

v0.0.0 (July 1, 2021)

  1. Init Code

Authors

  • @Lyle - Lyle Shaw (肖良玉)
  • @wj-Mcat - Jingjing WU (吴京京)

Copyright & License

  • Code & Docs © 2020-now Huan LI <[email protected]>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

python-wechaty-puppet-itchat's People

Contributors

dependabot[bot] avatar fangjiyuan avatar huan avatar lyleshaw avatar wj-mcat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-wechaty-puppet-itchat's Issues

Issue templates are meaningful

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?

🐛🐛 Bug Report: 尝试搭建一个发送文字到指定微信用户的API,使用了itchat的search_friends方法,运行非常慢。

requirements

  • version of python-wechaty [0.6.24]
  • version of python-wechaty-puppet-itchat [0.0.4]
  • version of python [3.7.10]

Describe your problem

尝试搭建一个发送文字到指定微信用户的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

Reproduce your problem

Error info

INFO: 127.0.0.1:64207 - "POST /search_friends HTTP/1.1" 200 OK
image

# copy your log info at here from your terminal 

Your experiments

是否是因为好友列表太多,导致查找缓慢,是否有好的解决方法。

wechaty-puppet-service: token not found. please set

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?

当我发送文字 [泽@Home 9]:没问题,发#ding 时,异常退出了。

当我发送文字 [泽@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'

KeyError: 'wxsid'

requirements

  • version of python-wechaty: 0.6.24
  • version of python-wechaty-puppet-itchat: 0.0.4
  • version of wechaty docker image: None

Error, KeyError: 'wxsid'

Error, "KeyError: 'wxsid'", occured after scanning qrcode and confirming on mobile phone.

Reproduce problem

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())

Error info

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'

Your experiments

I didn't use docker (It might be the reason why error occured?)

Fix the linting issue

Description

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

【Feature 💁 💁】CICD is required for opensource project

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.

reference

为什么有的账户可以登陆,但有的账户不能登陆

requirements

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

  • version of python-wechaty [required]
  • version of python-wechaty-puppet-itchat [required]
  • version of wechaty docker image [optional]

Describe your problem

为什么有的账户可以登陆,但有的账户不能登陆,显示错误信息为:
list index out of range

A clear and concise description of what the bug is.

Reproduce your problem

simple code to reproduce your problem

Error info

# copy your log info at here from your terminal 

Your experiments

please tell us your experiments and ideas about this issue. It's valuable for us to help you find the solution.

when i try to run bot.Contact.find,get some error.

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

【todo】Check_box for Features

  • handle Map,Card,Note,Sharing,Picture,Recording,Attachment,Video messages
  • handle Friends,System messages
  • Encapsulate message_send_contact function (itchat doesn't exist this function)
  • Encapsulate message_send_url function (itchat doesn't exist this function)
  • Encapsulate message_send_mini_program function (itchat doesn't exist this function)
  • Encapsulate message_file function
  • Encapsulate message_emoticon function
  • Encapsulate message_contact function
  • Encapsulate message_url function
  • Encapsulate message_mini_program function (itchat doesn't exist this function)
  • Encapsulate contact_alias function
  • Encapsulate contact_payload function
  • Encapsulate contact_avatar function
  • Encapsulate contact_tag_ids function (itchat doesn't exist this function)
  • Encapsulate friendship_search function
  • Encapsulate friendship_add function
  • Encapsulate friendship_accept function
  • Encapsulate room_create function
  • Encapsulate room_search function
  • Encapsulate room_invitation_accept function (itchat doesn't exist this function)
  • Encapsulate room_members function
  • Encapsulate room_add function
  • Encapsulate room_delete function
  • Encapsulate room_quit function (itchat doesn't exist this function)
  • Encapsulate room_topic function
  • Encapsulate room_announce function (itchat doesn't exist this function)
  • Encapsulate room_qr_code function (itchat doesn't exist this function)
  • Encapsulate room_avatar function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.