コード例 #1
0
    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']))
コード例 #2
0
ファイル: quotatore.py プロジェクト: informateci/arnaldo
    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"]))
コード例 #3
0
ファイル: quotatore.py プロジェクト: informateci/arnaldo
 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'")
コード例 #4
0
ファイル: quotatore.py プロジェクト: mandrake/arnaldo
 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)
コード例 #5
0
 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'")
コード例 #6
0
    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']))
コード例 #7
0
ファイル: quotatore.py プロジェクト: informateci/arnaldo
    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"]))