def process(self, msg, type):
if type != TEXT:
return
groupName = msg['User']['NickName']
if any([ re.search(x, groupName) is not None for x in self.blacklist ]):
return
if re.search('^/', msg['Content']):
return
if self.isFromSelf(msg):
# Stop processing if the message is from myself
return
self.updateGroupContentCache(msg, groupName)
contentToPaiDui = list(self.WhatToPaiDui(groupName))
if len(contentToPaiDui) > 1:
logging.error('Multiple duis detected.')
if len(contentToPaiDui) != 0:
# Pai dui!
itchat.send(msg['Content'], msg['FromUserName'])
logging.info('Pai Dui! {0}.'.format(msg['Content']))
# Update data structure to avoid Pai dui for multiple times.
self.updateGroupContentCache({ 'Content': msg['Content'], 'FromSelf': True }, groupName)
评论列表
文章目录