home · contact · privacy
Be more explicit on URL change on mobile twitter page title hack.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 22 Jan 2016 20:25:31 +0000 (21:25 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 22 Jan 2016 20:25:31 +0000 (21:25 +0100)
plomlombot.py

index 0f738f0003e5c8dca674e97b2df0bde7c9b9c460..a1ef7f8c3e2b60f9a61a4c2db1e8485e1b5ec5ae 100755 (executable)
@@ -110,7 +110,7 @@ def lineparser_loop(io, nickname):
 
         def url_check(msg):
 
-            def handle_url(url):
+            def handle_url(url, show_url=False):
 
                 def mobile_twitter_hack(url):
                     re1 = 'https?://(mobile.twitter.com/)[^/]+(/status/)'
@@ -121,7 +121,7 @@ def lineparser_loop(io, nickname):
                         m = re.search(re2, url)
                         url = 'https://twitter.com/' + m.group(1) + '/status/' \
                                 + m.group(2)
-                        handle_url(url)
+                        handle_url(url, True)
                         return True
 
                 try:
@@ -136,7 +136,10 @@ def lineparser_loop(io, nickname):
                     return
                 title = bs4.BeautifulSoup(r.text).title
                 if title:
-                    notice("PAGE TITLE: " + title.string.strip())
+                    prefix = "PAGE TITLE: "
+                    if show_url:
+                        prefix = "PAGE TITLE FOR <" + url + ">: "
+                    notice(prefix + title.string.strip())
                 else:
                     notice("PAGE HAS NO TITLE TAG")