micro-channel message transmission itchat

1.1 micro-channel robotic auto-reply message

  1, run the program will pop up a two-dimensional code, you can automatically reply to a message after scanning authorize  Reference 01   Reference 02

#coding=utf8
import itchat, time
from itchat.content import *

@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])
def text_reply(msg):
    itchat.send('%s: %s' % (msg['Type'], msg['Text']), msg['FromUserName'])

@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
    msg['Text'](msg['FileName'])
    return  ' @ S @% S% ' % ({ ' Picture ' : ' IMG ' , ' Connections Video ' : ' VID ' } .get (MSG [ ' the Type ' ], ' FIL ' ), MSG [ ' FileName ' ]) 

itchat.msg_register @ (fRIENDS) 
DEF add_friend (MSG): 
    itchat.add_friend ( ** MSG [ ' the Text ' ]) # this operation will automatically enter a new message friends, contacts need to override 
    itchat.send_msg ( 'Nice to meet you!', msg['RecommendInfo']['UserName'])

@itchat.msg_register(TEXT, isGroupChat=True)
def text_reply(msg):
    if msg['isAt']:
        itchat.send(u'@%s\u2005I received: %s' % (msg['ActualNickName'], msg['Content']), msg['FromUserName'])

itchat.auto_login(True)
itchat.run()
Micro-channel auto-reply
# Coding UTF8 = 
Import itchat, Time 

# automatic reply 
# encapsulated decorators, when the received message is Text, i.e., text message 
@ itchat.msg_register ( ' the Text ' )
 DEF text_reply (MSG):
     # when the message are not by themselves when issued 
    IF  not msg [ ' fromusername ' ] == myUserName:
         # send a file to prompt assistant 
        itchat.send_msg (U " [% S] received information of friends @% s:% S \ the n- " % 
                        (time. the strftime ( " % D%% Y-M-% H:% M:% S " , time.localtime (MSG [ ' CreateTime '])), 
                         Msg [ ' the User ' ] [ ' the NickName ' ], 
                         msg [ ' Text ' ]), ' filehelper ' )
         # reply to a Friend 
        return U ' [automatic reply] Hello, I am now something is not, one will contact you. \ n have received your message:% S \ n ' % (msg [ ' Text ' ]) 

IF  __name__ == ' __main__ ' : 
    itchat.auto_login () 

    # Get your own UserName 
    myUserName = itchat.get_friends (Update = true) [0] ["UserName"]
    itchat.run()
Micro-channel method for automatically responding 2

 

Guess you like

Origin www.cnblogs.com/jiaxinzhu/p/12595940.html