def send(self, user, text, in_reply_to = None): a = InstantMessage(id=None, sender=User.objects.get(username=\ self.get_username(self.jid.getStripped())), text=text, date=datetime.now()) a.save() super(LabsBot, self).send(user, text, in_reply_to)
def callback_message(self, conn, mess): sender = mess.getFrom().getStripped() if sender not in self.jids(): u = User(id=None, username=sender) u.save() j = JabberAccount(user=User.objects.get(username=sender), id=None, is_bot=False, jid=sender) j.save() a = InstantMessage(id=None, sender=User.objects.get(jabberaccount__jid=sender), text=mess.getBody(), date=datetime.now()) a.save() super(LabsBot, self).callback_message(conn, mess)