remove provided URL from title extraction messages
This commit is contained in:
12
urlbot.py
12
urlbot.py
@@ -56,7 +56,7 @@ def extract_title(url):
|
|||||||
(code, html_text, headers) = fetch_page(url)
|
(code, html_text, headers) = fetch_page(url)
|
||||||
|
|
||||||
if 1 == code:
|
if 1 == code:
|
||||||
return (3, 'failed: %s for %s' % (html_text, url))
|
return (3, 'failed: %s' % html_text)
|
||||||
|
|
||||||
if html_text:
|
if html_text:
|
||||||
charset = ''
|
charset = ''
|
||||||
@@ -174,26 +174,26 @@ def extract_url(data, msg_obj):
|
|||||||
if 0 == status:
|
if 0 == status:
|
||||||
title = title.strip()
|
title = title.strip()
|
||||||
|
|
||||||
message = 'Title: %s: %s' % (title, url)
|
message = 'Title: %s' % title
|
||||||
elif 1 == status:
|
elif 1 == status:
|
||||||
if conf('image_preview'):
|
if conf('image_preview'):
|
||||||
# of course it's fake, but it looks interesting at least
|
# of course it's fake, but it looks interesting at least
|
||||||
char = """,._-+=\|/*`~"'"""
|
char = """,._-+=\|/*`~"'"""
|
||||||
message = 'No text but %s, 1-bit ASCII art preview: [%c] %s' % (
|
message = 'No text but %s, 1-bit ASCII art preview: [%c]' % (
|
||||||
title, random.choice(char), url
|
title, random.choice(char)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
log.info('no message sent for non-text %s (%s)' % (url, title))
|
log.info('no message sent for non-text %s (%s)' % (url, title))
|
||||||
continue
|
continue
|
||||||
elif 2 == status:
|
elif 2 == status:
|
||||||
message = 'No title: %s' % url
|
message = '(No title)'
|
||||||
elif 3 == status:
|
elif 3 == status:
|
||||||
message = title
|
message = title
|
||||||
elif 4 == status:
|
elif 4 == status:
|
||||||
message = 'Bug triggered (%s), invalid URL/domain part: %s' % (title, url)
|
message = 'Bug triggered (%s), invalid URL/domain part: %s' % (title, url)
|
||||||
log.warn(message)
|
log.warn(message)
|
||||||
else:
|
else:
|
||||||
message = 'some error occurred when fetching %s' % url
|
message = 'some error occurred while fetching'
|
||||||
|
|
||||||
message = message.replace('\n', '\\n')
|
message = message.replace('\n', '\\n')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user