Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Brendan Abolivier
wantzel
Commits
9699bf46
Commit
9699bf46
authored
May 18, 2015
by
Mindiell
Browse files
Added url title shower
parent
80cfaf6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
messages.py
View file @
9699bf46
...
...
@@ -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)"""
,
}
wantzel.py
View file @
9699bf46
...
...
@@ -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
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment