Python easy to play with XXX (WeChat) robot

Source: Internet
Author: User

Python environment for Python3, setting up the environment here is not to say, before the article has

First, install a Python XXX library

pip install -U wxpy
The following release source: #!/usr/bin/env python3# coding:utf-8# @Author: aikerfrom wxpy import *# Scan code Login bot = bot () # Initialize Turing (API key application: http://tuling123.com) tuling = tuling (api_key= ' cc7e7f95db3545ad8e4867xxxxxx ') # Xiaoi = Xiaoi (' 2oeuyx5pbm5i ', ' 3jfiuwwkcbvj5bx75syl ') #xiaoI机器人boring_group = Bot.groups (). Search (' Anker ') [0]boring_group1 = Bot.groups (). Search (' BP ') [0]boring_group2 = Bot.groups (). Search (' Aiker ') [0]# boring_group1 = bot.groups (). Search ("Anker Shenzhen", ' anker! ' , ' Spring Travel Home Group ') [0]# boring_group2 = bot.groups (). Search (' anker! ') [0]my_friend = Bot.friends (). Search ("Aiker") [0]JT = Bot.friends (). Search (' JTT ') [0]mygroup=bot.groups () print (    MyGroup) #打印所有群 # does not automatically reply to the specified group message and friend Message @bot.register ([BORING_GROUP,BORING_GROUP1,BORING_GROUP2,JT]) def ignore (msg): Print (Boring_group) # Nothing to do return# automatically reply to all text messages and print @bot.register (msg_types=text) def auto_reply_all (msg): Tuling.do_ Reply (msg) print (msg) # Prints the specified group message @bot.register ([Boring_group, Boring_group1, boring_group2]) def just_print (msg): PR  int (msg) #   f = open (' Wilow.txt ', ' WB ') # F.writelines (msg) # reply @ Group chat message and personal message @bot.register ((msg_types=text)) #注册消息类型为文本消息def auto_re        Ply (MSG): If Isinstance (Msg.chat,group) and not msg.is_at: # Determine if the message is @ and the personal message, if not the @ message return #什么也不做 else: Tuling.do_reply (msg) #图灵自动回复消息 print (msg) #打印消息 print (Tuling.do_reply (msg)) #打印回复的消息内容 # retur N ' received message: {} ({}) '. Format (msg.text,msg.type) #回复消息: Message Received: Content # @bot. Register () # def just_print (msg): # Print (msg) # Start running, Embe D can be debugged, can directly Bot.join () # Bot.join () #运行embed () # Plug the thread and go to the Python command line

#源码结束

The following manual debugs require a blocking thread:

Send a message to a friend under Python:

In [26]: jt = bot.friends ().search(‘贾TT‘)[0]In [28]: jt.send(‘老铁‘)Out[28]: ? 贾TT : 老铁 (Text)In [29]: jt.send(‘从前有个人...‘)Out[29]: ? 贾TT : 从前有个人... (Text)

Show two common friends of XXX:

Show your recent history message:

Other features require your own research, WXPY documentation:

Wxpy Document Description

Python easy to play with XXX (WeChat) robot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.