def __ignored(self, content: Content, sender: ID, msg: ReliableMessage) -> bool: # check robot if sender.type in [NetworkType.ROBOT, NetworkType.STATION]: Log.info('Dialog > ignore message from another robot: %s' % sender) return True # check time now = int(time.time()) dt = now - msg.time if dt > 600: # Old message, ignore it return True # check group message if content.group is None: # not a group message return False text = content.text if text is None: raise ValueError('text content error: %s' % content) # checking '@nickname' receiver = msg.receiver at = '@%s' % self.facebook.name(identifier=receiver) if text.find(at) < 0: Log.info('ignore group message that not querying me: %s' % text) return True # TODO: remove all '@nickname' text = text.replace(at, '') content.text = text
def __ignored(self, content: Content, sender: ID, msg: InstantMessage) -> bool: # check robot if sender.type.is_robot() or sender.type.is_station(): self.info('Dialog > ignore message from another robot: %s' % msg.content) return True # check time now = int(time.time()) dt = now - msg.envelope.time if dt > 600: self.info('Old message, ignore it: %s' % msg) return True # check group message if content.group is None: # not a group message return False text = content.text if text is None: raise ValueError('text content error: %s' % content) # checking '@nickname' receiver = self.facebook.identifier(msg.envelope.receiver) at = '@%s' % self.facebook.nickname(identifier=receiver) self.info('Group Dialog > searching "%s" in "%s"...' % (at, text)) if text.find(at) < 0: self.info('ignore group message that not querying me: %s' % text) return True # TODO: remove all '@nickname' text = text.replace(at, '') content.text = text