def outgoing(self, message): ''' log prepaid message ''' # log outgoing message try: if message.PREPAID: log = MessageLog(sender=self.me, recipient=message.peer, \ text=message.text, date=datetime.now()) log.save() except AttributeError: pass
def parse(self, message): ''' tag and log message if it's a prepaid one. returns bool ''' # Test if it's a prepaid message for keyword in self.keywords: if message.text.upper().startswith(keyword['keyw'].upper()): # message is prepaid message.PREPAID = True message.PREPAID_ACTION = keyword['id'] # log incoming message log = MessageLog(sender=message.peer, recipient=self.me, \ text=message.text, date=datetime.now()) log.save() return # message is not prepaid return False