import pygame import itchat import time #声音提示 def voice(): pygame.mixer.init()#初始化 pygame.mixer.music.load('love.mp3') pygame.mixer.music.play() time.sleep(9) pygame.mixer.music.stop() #是否群发 @itchat.msg_register('Note',isGroupChat=True) def getNotGroup(msg): #print(msg) if u'收到红包' in msg.Text: print('新消息,群红包',msg['Text']) #提示音乐 #监控是否私发 @itchat.msg_register('Note',isGroupChat=False) def getPrivate(): if u'收到红包' in msg.Text: print('新消息,有人给你发红包了',msg['Text']) itchat.login() itchat.run()