]> jfr.im git - erebus.git/blobdiff - modules/urls.py
urls - allow to block channels in config
[erebus.git] / modules / urls.py
index 80ae1ee8328dffeb896febd316827d1976b95a11..6e99530468a635cbe755e719540365ee5bbb852b 100644 (file)
@@ -77,6 +77,9 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
                result.status = code
                return result
 
+def _get_blocked_chans():
+       return lib.parent.cfg.get('urls', 'blocked', '').split(',')
+
 def process_line(line):
        responses = []
        num_found = 0
@@ -101,6 +104,8 @@ def privmsg_hook(bot, textline):
        user = parser_hostmask(textline[1:textline.find(' ')])
        chan = textline.split()[2]
 
+       if chan in _get_blocked_chans(): return
+
        try:
                line = textline.split(None, 3)[3][1:]
        except IndexError:
@@ -267,7 +272,7 @@ def goturl(url):
                        try:
                                soup = BeautifulSoup(responsebody)
                                if soup.title:
-                                       output.append('Title: ' + unescape('%s' % (soup.find('title').string)))
+                                       output.append('Title: ' + unescape('%s' % (soup.find('title').string.strip())))
                                else:
                                        output.append('No title')
                        except Exception as e: