Exemple #1
0
 def __call__(self, context):
     msg = context.msg
     if self.commands(context):
         return
     urls = weblib.find_urls(msg)
     shortened = []
     for url in urls:
         if len(url) > self.maxlen:
             shorter = weblib.shorten_url(url)
             if shorter:
                 shortened.append([url, shorter])
     for orig, short in shortened:
         context.channel.say("%s..: %s" % (orig[:30], short))
Exemple #2
0
def summarize(context):
    msg = context.msg
    # skip command-ish things
    if msg.startswith("."):
        return
    urls = weblib.find_urls(msg)
    if not urls:
        return
    summaries = []
    for url in urls:
        try:
            summaries.append(weblib.get_summary(url))
        except:
            pass
    if context.channel:
        for summary in summaries:
            context.channel.say(summary)