Commit 9699bf46 authored by Mindiell's avatar Mindiell

Added url title shower

parent 80cfaf6a
......@@ -54,4 +54,7 @@ Utilisation: !kill <url de l'article>
"stats_bravo":
"""Bravo les neurones, rien en retard depuis ces %s derniers jours!""",
"title":
"""Titre: %s (à %s)""",
}
......@@ -119,6 +119,21 @@ class Wantzel(object):
self.kill(user, channel, msg)
elif command=="stats":
self.stats(user, channel, msg)
# Whatever is done, get the title of an existing url in a message
if "http" in msg:
content = ""
title = ""
website = ""
try:
url = re.search("(http[^ ]*)", msg).group(1)
website = re.search("//([^/]*)", url).group(1)
f = urllib.URLopener().open(url)
content = f.read()
title = re.search("<title>([^<]+)</title>", content).group(1)
except:
pass
if title and website:
self.send_message(channel, messages["title"] % (title, website))
def on_joined(self, channel):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment