Bulk micro-channel custom message

#coding=utf8
import itchat, time

SINCERE_WISH = U ' wish% s Happy New Year! ' 
REAL_SINCERE_WISH = U ' wish% s Happy New Year! ! '

def send_wishes():
    friendlist = itchat.get_friends (Update = True) [. 1 :]
     for Friend in friendlist:
         # If it is not the purpose of demonstration, the following method can be changed itchat.send 
        Print (SINCERE_WISH% (Friend [ ' the DisplayName ' ]
             or Friend [ ' the NickName ' ]), Friend [ ' UserName ' ])
        time.sleep(.5)

def send_special_wishes(chatroomName='wishgroup'):
    itchat.get_chatrooms(update=True)
    chatrooms = itchat.search_chatrooms (name = chatroomName)
     IF chatrooms IS None:
         Print (U ' group not found chat: ' + chatroomName)
     the else :
        chatroom = itchat.update_chatroom(chatrooms[0]['UserName'])
        for friend in chatroom['MemberList']:
            Friend = itchat.search_friends (Friend the userName = [ ' UserName ' ])
             # If it is not the purpose of demonstration, the following method can be changed itchat.send 
            Print (REAL_SINCERE_WISH% (Friend [ ' the DisplayName ' ]
                 or Friend [ ' the NickName ' ] ), Friend [ ' UserName ' ])
            time.sleep(.5)

itchat.auto_login(True)

send_wishes()
send_special_wishes()

 

Guess you like

Origin www.cnblogs.com/Zeech-Lee/p/11842015.html