Exemple #1
0
 def outnocb(self, channel, txt, how=None, event=None, origin=None, response=None, dotime=False, *args, **kwargs):
     txt = self.normalize(txt)
     if event and event.how != "background":
         logging.info("%s - out - %s" % (self.cfg.name, txt))
     if "http://" in txt or "https://" in txt:
          for item in re_url_match.findall(txt):
              logging.debug("web - raw - found url - %s" % item)
              url = '<a href="%s" onclick="window.open(\'%s\'); return false;">%s</a>' % (item, item, item)
              try: txt = txt.replace(item, url)
              except ValueError:  logging.error("web - invalid url - %s" % url)
     if response or (event and event.doweb): self._raw(txt, event.target, event.how, event.handler)
     else:
         if event:
             e = cpy(event)
             e.txt = txt
             e.channel = channel
             e.how = event.how or how
         else:
             e = EventBase()
             e.nick = self.cfg.nick
             e.userhost = self.cfg.nick + "@" + "bot"
             e.channel = channel
             e.txt = txt
             e.div = "content_div"
             e.origin = origin
             e.how = how or "overwrite"
             e.headlines = True
         e.update(kwargs)
         update_web(self, e)
     self.benice(event)
Exemple #2
0
def geturls(txt):
    result = []
    if "http://" in txt or "https://" in txt:
        for item in re_url_match.findall(txt):
            logging.debug("web - raw - found url - %s" % item)
            try: txt = txt.replace(item, '')
            except ValueError:  logging.error("web - invalid url - %s" % url)
            i = item
            if i.endswith('"'): i = i[:-1]
            if i.endswith('")'): i = i[:-2]
            result.append(i)
    return (result, striphtml(txt))