Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #coding=utf8
  2. import itchat, time
  3.  
  4. SINCERE_WISH = u'祝%s新年快乐!'
  5. REAL_SINCERE_WISH = u'祝%s新年快乐!!'
  6.  
  7. def send_wishes():
  8. friendList = itchat.get_friends(update=True)[1:]
  9. for friend in friendList:
  10. # 如果不是演示目的,把下面的方法改为itchat.send即可
  11. print(SINCERE_WISH % (friend['DisplayName']
  12. or friend['NickName']), friend['UserName'])
  13. time.sleep(.5)
  14.  
  15. def send_special_wishes(chatroomName='wishgroup'):
  16. itchat.get_chatrooms(update=True)
  17. chatrooms = itchat.search_chatrooms(name=chatroomName)
  18. if chatrooms is None:
  19. print(u'没有找到群聊:' + chatroomName)
  20. else:
  21. chatroom = itchat.update_chatroom(chatrooms[0]['UserName'])
  22. for friend in chatroom['MemberList']:
  23. friend = itchat.search_friends(userName=friend['UserName'])
  24. # 如果不是演示目的,把下面的方法改为itchat.send即可
  25. print(REAL_SINCERE_WISH % (friend['DisplayName']
  26. or friend['NickName']), friend['UserName'])
  27. time.sleep(.5)
  28.  
  29. itchat.auto_login(True)
  30.  
  31. send_wishes()
  32. send_special_wishes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement