Skip to content

Commit

Permalink
[url] Update to 4.0 standards, fix .title
Browse files Browse the repository at this point in the history
  • Loading branch information
embolalia committed Jun 5, 2013
1 parent 821dcc6 commit 7a13023
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions url.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
from htmlentitydefs import name2codepoint
import willie.web as web
from willie.module import command, rule
import urllib2
import urlparse

Expand Down Expand Up @@ -74,6 +75,7 @@ def setup(willie):
(exclusion_char))


@command('title')
def title_command(willie, trigger):
"""
Show the title or URL information for the given URL, or the last URL seen
Expand All @@ -93,9 +95,11 @@ def title_command(willie, trigger):
urls = re.findall(url_finder, trigger)

results = process_urls(willie, trigger, urls)
title_command.commands = ['title']
for result in results[:4]:
message = '[ %s ] - %s' % tuple(result)


@rule('(?u).*(https?://\S+).*')
def title_auto(willie, trigger):
"""
Automatically show titles for URLs. For shortened URLs/redirects, find
Expand All @@ -113,7 +117,6 @@ def title_auto(willie, trigger):
message = '[ %s ] - %s' % tuple(result)
if message != trigger:
willie.say(message)
title_auto.rule = '(?u).*(https?://\S+).*'


def process_urls(willie, trigger, urls):
Expand Down

0 comments on commit 7a13023

Please sign in to comment.