def random_quote(self, e, match): q = brain.get(choice(brain.keys("quote:*"))) if q is None: return q = eval(q) self.r(e, u'#%s: %s' % (q['id'], q['quote']))
def random_quote(self, e, match): q = brain.get(choice(brain.keys("quote:*"))) if q is None: return q = eval(q) self.r(e, u"#%s: %s" % (q["id"], q["quote"]))
def add_quote(self, e, match): try: author = e.source.nick quote = match.groups()[0] maxa = max([int(x.split(":")[1]) for x in brain.keys("quote:*")]) q = {"author": author, "date": str(time.time()), "id": str(maxa + 1), "quote": quote} brain.set(u"quote:%d" % (maxa + 1), q) self.r(e, "vai agile [#%d]" % (maxa + 1)) except: self.r(e, "macche'")
def add_quote(self, e, match): author = e.source.nick quote = match.groups()[0] maxa = max([int(x.split(':')[1]) for x in brain.keys('quote:*')]) q = { "author": author, "date": str(time.time()), "id": str(maxa + 1), "quote": quote } brain.set("quote:%d" % (maxa + 1), q)
def add_quote(self, e, match): try: author = e.source.nick quote = match.groups()[0] maxa = max([int(x.split(':')[1]) for x in brain.keys('quote:*')]) q = { "author": author, "date": str(time.time()), "id": str(maxa + 1), "quote": quote } brain.set(u"quote:%d" % (maxa + 1), q) self.r(e, "vai agile [#%d]" % (maxa + 1)) except: self.r(e, "macche'")
def search_quote(self, e, match): pattern = match.groups()[0] regex = re.compile(".*(%s).*" % pattern) # <PAZO> k = brain.keys("quote:*") if len(k) > 0: listo = [eval(l) for l in brain.mget(*k)] resp = [r for r in listo if regex.search(r['quote'])] # </PAZO> respa = choice(resp) if len(resp) > 0 else None if respa is None: self.r(e, 'no such quote') return None self.r(e, '#%s: %s' % (respa['id'], respa['quote']))
def search_quote(self, e, match): pattern = match.groups()[0] regex = re.compile(".*(%s).*" % pattern) # <PAZO> k = brain.keys("quote:*") if len(k) > 0: listo = [eval(l) for l in brain.mget(*k)] resp = [r for r in listo if regex.search(r["quote"])] # </PAZO> respa = choice(resp) if len(resp) > 0 else None if respa is None: self.r(e, "no such quote") return None self.r(e, "#%s: %s" % (respa["id"], respa["quote"]))