Top Related Projects
A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt
Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
网页版微信API,包含终端版微信及微信机器人
Quick Overview
wxpy is a Python library that provides a simple and efficient way to control WeChat through the WeChat Web API. It allows developers to automate WeChat operations, build chatbots, and create custom WeChat applications using Python.
Pros
- Easy to use with a Pythonic API
- Supports both personal and official WeChat accounts
- Provides comprehensive documentation and examples
- Actively maintained with regular updates
Cons
- Relies on the WeChat Web API, which may have limitations compared to the mobile app
- Potential risk of account suspension if used improperly
- Limited support for some advanced WeChat features
- May be affected by changes in WeChat's policies or API
Code Examples
- Sending a message to a friend:
from wxpy import *
bot = Bot()
friend = bot.friends().search('Friend Name')[0]
friend.send('Hello from wxpy!')
- Responding to messages automatically:
from wxpy import *
bot = Bot()
@bot.register()
def reply_message(msg):
return 'I received: ' + msg.text
embed()
- Creating a group chat and inviting friends:
from wxpy import *
bot = Bot()
friend1 = bot.friends().search('Friend1')[0]
friend2 = bot.friends().search('Friend2')[0]
group = bot.create_group([friend1, friend2], 'New Group')
group.send('Welcome to the new group!')
Getting Started
To get started with wxpy, follow these steps:
-
Install wxpy using pip:
pip install -U wxpy
-
Import the library and create a Bot instance:
from wxpy import * bot = Bot()
-
Use the bot instance to interact with WeChat:
# Send a message to yourself bot.self.send('Hello, wxpy!') # Listen for new messages @bot.register() def print_messages(msg): print(msg) # Keep the bot running embed()
Note: When running the script for the first time, you'll need to scan a QR code with your WeChat mobile app to log in.
Competitor Comparisons
A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
Pros of ItChat
- More comprehensive documentation and examples
- Supports both personal and enterprise WeChat accounts
- Better handling of complex message types (e.g., voice messages, files)
Cons of ItChat
- Less active development and maintenance
- Slightly more complex API compared to wxpy
- May have compatibility issues with newer WeChat versions
Code Comparison
ItChat:
import itchat
@itchat.msg_register(itchat.content.TEXT)
def text_reply(msg):
return msg.text
itchat.auto_login()
itchat.run()
wxpy:
from wxpy import *
bot = Bot()
@bot.register()
def reply_message(msg):
return msg.text
bot.join()
Both libraries provide similar functionality for interacting with WeChat, but wxpy offers a more streamlined and Pythonic API. ItChat provides more detailed control over message types and account types, while wxpy focuses on simplicity and ease of use.
ItChat's documentation is more extensive, making it easier for beginners to get started. However, wxpy's active development and maintenance may make it a better choice for long-term projects.
In terms of performance, both libraries are comparable, with slight variations depending on specific use cases. The choice between the two often comes down to personal preference and specific project requirements.
Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt
Pros of Wechaty
- Multi-platform support (Web, Pad, Windows, Mac)
- Supports multiple messaging protocols beyond just WeChat
- More active development and larger community
Cons of Wechaty
- Steeper learning curve due to more complex architecture
- Requires more setup and configuration
- Potentially higher resource usage due to broader feature set
Code Comparison
Wechaty example:
const { Wechaty } = require('wechaty')
const bot = new Wechaty()
bot.on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
bot.on('login', user => console.log(`User ${user} logged in`))
bot.on('message', message => console.log(`Message: ${message}`))
bot.start()
Wxpy example:
from wxpy import *
bot = Bot()
@bot.register()
def print_messages(msg):
print(msg)
bot.join()
Both libraries provide similar functionality for creating WeChat bots, but Wechaty offers a more comprehensive solution with broader platform support and protocol compatibility. Wxpy, on the other hand, provides a simpler, Python-specific implementation focused solely on WeChat. The choice between the two depends on the specific requirements of your project and your preferred programming language.
Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
Pros of python-wechaty
- Multi-platform support (WeChat, WhatsApp, etc.)
- More active development and larger community
- Better documentation and examples
Cons of python-wechaty
- Steeper learning curve
- Requires more setup and configuration
- Potentially slower performance due to its cross-platform nature
Code Comparison
wxpy:
from wxpy import Bot, Friend
bot = Bot()
my_friend = bot.friends().search('friend_name')[0]
my_friend.send('Hello, friend!')
python-wechaty:
from wechaty import Wechaty, Contact
async def on_message(msg):
if msg.text() == 'ding':
await msg.say('dong')
bot = Wechaty()
bot.on('message', on_message)
bot.start()
Key Differences
- wxpy is specifically designed for WeChat, while python-wechaty supports multiple platforms
- python-wechaty uses an asynchronous programming model, while wxpy is synchronous
- wxpy has a simpler API for basic tasks, but python-wechaty offers more flexibility and features
Use Cases
- Choose wxpy for quick WeChat-specific projects with simple requirements
- Opt for python-wechaty for cross-platform chatbot development or more complex applications
Community and Support
- python-wechaty has a larger and more active community, with regular updates and contributions
- wxpy has a smaller but dedicated user base, primarily focused on WeChat automation
网页版微信API,包含终端版微信及微信机器人
Pros of WeixinBot
- More comprehensive documentation and examples
- Supports a wider range of WeChat features and functionalities
- Actively maintained with regular updates and bug fixes
Cons of WeixinBot
- More complex setup and configuration process
- Steeper learning curve for beginners
- Requires more system resources due to its extensive feature set
Code Comparison
WeixinBot:
from WeixinBot import WeixinBot
bot = WeixinBot()
bot.login()
bot.send_msg('Hello, WeChat!', 'Friend_Name')
wxpy:
from wxpy import Bot
bot = Bot()
friend = bot.friends().search('Friend_Name')[0]
friend.send('Hello, WeChat!')
Summary
WeixinBot offers more advanced features and comprehensive documentation, making it suitable for complex WeChat automation tasks. However, it may be overkill for simpler use cases and can be more challenging for beginners to set up and use.
wxpy, on the other hand, provides a more straightforward and user-friendly approach, making it ideal for those who need basic WeChat bot functionality without the added complexity. It's easier to get started with wxpy, but it may lack some of the more advanced features found in WeixinBot.
Choose WeixinBot for more complex projects requiring extensive WeChat integration, and wxpy for simpler, more straightforward WeChat bot development.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
wxpy: ç¨ Python ç©å¾®ä¿¡
.. image:: https://badge.fury.io/py/wxpy.svg :target: https://badge.fury.io/py/wxpy
.. image:: https://img.shields.io/pypi/pyversions/wxpy.svg :target: https://github.com/youfou/wxpy
.. image:: https://readthedocs.org/projects/wxpy/badge/?version=latest :target: http://wxpy.readthedocs.io/zh/latest/?badge=latest
微信æºå¨äºº / å¯è½æ¯æä¼é çå¾®ä¿¡ä¸ªäººå· API wxpy å¨ itchat çåºç¡ä¸ï¼éè¿å¤§éæ¥å£ä¼åæåäºæ¨¡åçæç¨æ§ï¼å¹¶è¿è¡ä¸°å¯çåè½æ©å±
.. attention::
| **强ç建议ä»
使ç¨å°å·è¿è¡æºå¨äººï¼**
| ä»è¿æ (17å¹´6æä¸æ¬) åé¦æ¥çï¼ä½¿ç¨æºå¨äººåå¨ä¸å®æ¦ç被éå¶ç»å½çå¯è½æ§ã
| 主è¦è¡¨ç°ä¸ºæ æ³ç»é Web 微信 (ä½ä¸å½±åææºçå
¶ä»å¹³å°)ã
ç¨æ¥å¹²å¥
ä¸äºå¸¸è§çåºæ¯
- æ§å¶è·¯ç±å¨ãæºè½å®¶å± çå ·æå¼æ¾æ¥å£çç©æå¿
- è¿è¡èæ¬æ¶èªå¨ææ¥å¿åéå°ä½ ç微信
- å 群主为好åï¼èªå¨æè¿ç¾¤ä¸
- è·¨å·æ跨群转åæ¶æ¯
- èªå¨éªäººè天
- é人ç©
- ...
æ»èè¨ä¹ï¼å¯ç¨æ¥å®ç°åç§å¾®ä¿¡ä¸ªäººå·çèªå¨åæä½
.. ä½éªä¸ä¸ ----------------
**è¿æä¸ä¸ªç°æç微信æºå¨äººï¼æ³ä¸æ³è°æä¸ä¸ï¼**
è®°å¾å¡«åå
¥ç¾¤å£ä»¤ ð [ **wxpy** ]ï¼ä¸ç¾¤éç大ç¥ä»¬è°ç¬é£ç ð
.. image:: https://github.com/youfou/wxpy/raw/master/docs/wechat-group.png
è½»æ¾å®è£
wxpy æ¯æ Python 3.4-3.6ï¼ä»¥å 2.7 çæ¬
å°ä¸æ¹å½ä»¤ä¸ç "pip" æ¿æ¢ä¸º "pip3" æ "pip2"ï¼å¯ç¡®ä¿å®è£ å°å¯¹åºç Python çæ¬ä¸
- ä» PYPI å®æ¹æºä¸è½½å®è£ (å¨å½å å¯è½æ¯è¾æ ¢æä¸ç¨³å®):
.. code:: shell
pip install -U wxpy
2. ä»è±ç£ PYPI éåæºä¸è½½å®è£ (æ¨èå½å ç¨æ·éç¨):
.. code:: shell
pip install -U wxpy -i "https://pypi.doubanio.com/simple/"
ç®åä¸æ
ç»é微信:
.. code:: python
# 导å
¥æ¨¡å
from wxpy import *
# åå§åæºå¨äººï¼æ«ç ç»é
bot = Bot()
æ¾å°å¥½å:
.. code:: python
# æç´¢å称å«æ "游å¦" çç·æ§æ·±å³å¥½å
my_friend = bot.friends().search('游å¦', sex=MALE, city="æ·±å³")[0]
åéæ¶æ¯:
.. code:: python
# åéææ¬ç»å¥½å
my_friend.send('Hello WeChat!')
# åéå¾ç
my_friend.send_image('my_picture.jpg')
èªå¨ååºåç±»æ¶æ¯:
.. code:: python
# æå°æ¥èªå
¶ä»å¥½åã群èåå
¬ä¼å·çæ¶æ¯
@bot.register()
def print_others(msg):
print(msg)
# åå¤ my_friend çæ¶æ¯ (ä¼å
å¹é
å注åçå½æ°!)
@bot.register(my_friend)
def reply_my_friend(msg):
return 'received: {} ({})'.format(msg.text, msg.type)
# èªå¨æ¥åæ°ç好å请æ±
@bot.register(msg_types=FRIENDS)
def auto_accept_friends(msg):
# æ¥å好å请æ±
new_friend = msg.card.accept()
# åæ°ç好ååéæ¶æ¯
new_friend.send('ååï¼æèªå¨æ¥åäºä½ ç好å请æ±')
ä¿æç»é/è¿è¡:
.. code:: python
# è¿å
¥ Python å½ä»¤è¡ã让ç¨åºä¿æè¿è¡
embed()
# æè
ä»
ä»
å µå¡çº¿ç¨
# bot.join()
模åç¹è²
-
å ¨é¢å¯¹è±¡åæ¥å£ï¼è°ç¨æ´ä¼é
-
é»è®¤å¤çº¿ç¨ååºæ¶æ¯ï¼åå¤æ´å¿«
-
å å« è天æºå¨äººãå ±å好å ç
å®ç¨ç»ä»¶ <http://wxpy.readthedocs.io/zh/latest/utils.html>
_ -
åªé两è¡ä»£ç ï¼å¨å ¶ä»é¡¹ç®ä¸ç¨å¾®ä¿¡æ¥æ¶è¦å
-
æå¿«çæ¢ç´¢åè°è¯ <http://wxpy.readthedocs.io/zh/latest/console.html>
_ï¼æ éæ¶æ¶æ¹æ¹ -
å¯æ··åä½¿ç¨ itchat çåæ¥å£
-
å½ç¶ï¼è¿è¦çäºå类常è§åºæ¬åè½:
- åéææ¬ãå¾çãè§é¢ãæ件
- éè¿å ³é®è¯æç¨æ·å±æ§æç´¢ 好åã群èã群æåç
- è·å好å/群æåçæµç§°ãå¤æ³¨ãæ§å«ãå°åºçä¿¡æ¯
- å 好åï¼å»ºç¾¤ï¼éè¯·å ¥ç¾¤ï¼ç§»åºç¾¤
说æææ¡£
æ´æ°æ¥å¿
https://github.com/youfou/wxpy/releases
项ç®ä¸»é¡µ
Top Related Projects
A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt
Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
网页版微信API,包含终端版微信及微信机器人
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot