Play WeChat with Python


Possible application scenarios

Message forwarding between multiple groups WeChat group limit (500 people)

Customer Service Robot

Social & Fun

Automatic clock-in and clock-out calendar reminders, etc.

Information promotion (news, products, advertising, etc.)

Monitor Alerts

Unsupported Features

Payment Related - Red Packets, Transfers, Receipts, etc. are not supported

@ someone in a group chat - yes, Web WeChat doesn't alert you when you're @ someone either

Send business cards - but can be forwarded via send_raw_msg()

Send share link - also not forwarding

Sending voice messages

Circle of Friends Related

Unable to delete friends and unfollow public numbers

Risks and shortcomings

There is a chance that you will be restricted from logging in, mainly to Web WeChat (but not to other platforms such as mobile).

Newly registered WeChat signal cannot login directly to Web WeChat

There is a subsequent risk that the web version of WeChat will be discontinued

Module Features

Send text, pictures, videos, files

Search by keywords or user attributes Friends, group chat, group members, etc.

Get nickname, notes, gender, region, etc. of friends/group members

Add friends, create groups, invite to groups, move out of groups

easy to get started

# Import modules

fromwxpyimport

# Initialize the bot, scan the code and log in

bot=Bot()

# Search for names containing " swim or swim not" of male Shenzhen friends

my_friend=bot.friends().search(' swim or swim not',sex=MALE,city=" Shenzhen")[]

# Send text to a friend

my_friend.send('Hello WeChat!')

# Sending pictures

my_friend.send_image('my_picture.jpg')

# Search for names containing " swim or swim not" of male Shenzhen friends

my_friend=bot.friends().search(' swim or swim not',sex=MALE,city=" Shenzhen")[]

# Send text to a friend

my_friend.send('Hello WeChat!')

# Sending pictures

my_friend.send_image('my_picture.jpg')

# Print messages from other friends, group chats and public

@bot.register()

defprint_others(msg):

print(msg)

# Reply to my_friend's message (priority match after registered function!)

@bot.register(my_friend)defreply_my_friend(msg):

return'received:{}({})'.format(msg.text,msg.type)

# Automatically accept new friend requests

@bot.register(msg_types=FRIENDS)

defauto_accept_friends(msg):

# Accept friend request new_friend=msg.card.accept() # Send message to new friend

new_friend.send(' (onom.) laughing out loud, I automatically accepted your friend request.')

# Go to the Python command line, keep the program running

embed()

# Or just blocking threads

# bot.join()

this text

Introducing some usage scenarios, unsupported features, and risks and pitfalls of pywx.


Recommended>>
1、Shenzhen Hongdigital Technology in collaboration with Hebei Engineering Software College conducted the launch meeting of medical big data project
2、Kudos Pingtans first APP garbage sorting and smart recycling system is online
3、Heres what you want to know about Peanut Rich
4、Machine learning clustering analysis kmeans text clustering analysis
5、Wheres the good content

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号