def saveothers(self, msg, chan): subj = re.search('send\s*(.+)?', msg.value) if subj == None: self.savecontent(msg) else: sauvegarde = Savedthings.select().where(Savedthings.user == msg.user) tablesauvegarde = self.parsecontent(sauvegarde) if subj.group(1)== None: self.taemin.mailation.mailage(msg.chan.name, tablesauvegarde, msg.user, "Sauvegarde IRC") else: self.privmsg(chan, subj.group(1)) self.taemin.mailation.mailage(msg.chan.name, tablesauvegarde, msg.user, subj.group(1)) suppr = Savedthings.delete().where(Savedthings.user == msg.user) suppr.execute()
def on_pubmsg(self, msg): if msg.key != "save": return chan = msg.chan.name if msg.value == "": self.privmsg(chan, "Veuillez préciser le contenu à sauvegarder") return kws = re.search('quote\s+(\w+)\s+(\d+)', msg.value) if kws == None: self.saveothers(msg, chan) return quoteduser = self.get_user(kws.group(1), chan) quotedmsg = self.get_message(quoteduser,msg.chan, int(kws.group(2))) Savedthings.create(user = msg.user, content = quotedmsg.message) self.privmsg(chan, "Le contenu a bien été sauvegardé")
def savecontent(self, msg): Savedthings.create(user = msg.user, content = msg.value)