示例#1
0
    def allivello(self, e, match):
        wikipedia_url = 'http://it.wikipedia.org/wiki/Speciale:PaginaCasuale#' + \
            str(time.time())
        respa = request_oembed(wikipedia_url)
        corpo = respa.get('html', None)
        text = "macche'"
        if corpo is not None:
            soup = BeautifulSoup(respa['html'])
            if soup.p:
                text = bleach.clean(soup.p, tags=[], strip=True)

        self.parliamo_summary = ' '.join(text.split('\n'))
        self.r(e, u'Parliamo di ' + respa.get('title', "macche'"))
示例#2
0
    def allivello(self, e, match):
        wikipedia_url = 'http://it.wikipedia.org/wiki/Speciale:PaginaCasuale#' + \
            str(time.time())
        respa = request_oembed(wikipedia_url)
        corpo = respa.get('html', None)
        text = "macche'"
        if corpo is not None:
            soup = BeautifulSoup(respa['html'])
            if soup.p:
                text = bleach.clean(soup.p, tags=[], strip=True)

        self.parliamo_summary = ' '.join(text.split('\n'))
        self.r(e, u'Parliamo di ' + respa.get('title', "macche'"))
示例#3
0
    def oembeddalo(self, e, match):
        allurls = URL_RE.findall(e.arguments[0])
        if len(allurls) != 1:
            return True

        #tipo goto ma peggio
        try:
            respa = request_oembed(allurls[0][0])
        except:
            pass
        thaurlhash = hashlib.md5(allurls[0][0]).hexdigest()
        hashish = brain.get("urlo:%s" % thaurlhash)

        try:
            if hashish is None:  # NO FUMO NO FUTURE
                ts = time.time()
                nic = e.source.nick
                brain.set("urlo:%s" % thaurlhash, "%f:%s:%d" % (ts, nic, 1))
                self.r(e, respa['title'])
            else:
                secondianno = 31556926  # num secondi in un anno youdontsay.png
                ts, nic, v = hashish.split(':')
                ts = float(ts)
                delta = time.time() - ts
                v = int(v) + 1
                brain.set("urlo:%s" % thaurlhash, "%f:%s:%d" % (ts, nic, v))
                manti, expo = map(
                    float,
                    ("%e" % (delta / secondianno)).split("e"))
                symb, todo = check_SI(expo * v)
                dignene = "%.2f %sGaggo [postato da %s il %s]" % \
                          (manti + v,
                           symb, nic,
                           datetime.datetime.fromtimestamp(
                               ts).strftime('%d/%m/%y %H:%M:%S'))
                self.r(e, dignene)
        except:
            pass

        return True
示例#4
0
    def oembeddalo(self, e, match):
        allurls = URL_RE.findall(e.arguments[0])
        if len(allurls) != 1:
            return True

        #tipo goto ma peggio
        try:
            respa = request_oembed(allurls[0][0])
        except:
            pass
        thaurlhash = hashlib.md5(allurls[0][0]).hexdigest()
        hashish = brain.get("urlo:%s" % thaurlhash)

        try:
            if hashish is None:  # NO FUMO NO FUTURE
                ts = time.time()
                nic = e.source.nick
                brain.set("urlo:%s" % thaurlhash, "%f:%s:%d" % (ts, nic, 1))
                self.r(e, respa['title'])
            elif "[pnd]" not in e.arguments[0].lower():
                secondianno = 31556926  # num secondi in un anno youdontsay.png
                ts, nic, v = hashish.split(':')
                ts = float(ts)
                delta = time.time() - ts
                v = int(v) + 1
                brain.set("urlo:%s" % thaurlhash, "%f:%s:%d" % (ts, nic, v))
                manti, expo = map(
                    float,
                    ("%e" % (delta / secondianno)).split("e"))
                symb, todo = check_SI(expo * v)
                dignene = "%.2f %sGaggo [postato da %s il %s]" % \
                          (manti + v,
                           symb, nic,
                           datetime.datetime.fromtimestamp(
                               ts).strftime('%d/%m/%y %H:%M:%S'))
                self.r(e, dignene)
        except:
            pass

        return True