def on_privmsg(self, bot, source, target, message): m = re.search('((https?:\/\/|www\.)\S+)', message, re.IGNORECASE) if m: url = m.group(1) self.urls[target] = URL() self.urls[target].url = m.group(1) self.urls[target].nick = source self.urls[target].timestamp = 'test' tweetbool = tweet.match_tweet_url(url) try: title = utility.timeout(get_title, 10, (url,)) self.urls[target].title = title self.save_last_url(target) if not tweetbool and target in ['#c++.se', '#d1d', '#lithen', "#d2006","#testchannel"]: # don't announce title if we've been asked to be quiet spoiler_averted = False if target in self.no_spoil_dict: ts = self.no_spoil_dict[target] del self.no_spoil_dict[target] now = datetime.datetime.now() diff_secs = (now - ts).total_seconds() if diff_secs < 60: spoiler_averted = True if not spoiler_averted: bot.tell(target, self.clean(url, title)) except utility.TimeoutException: pass
def on_privmsg(self, bot, source, target, message): m = re.search('((https?:\/\/|www\.)\S+)', message, re.IGNORECASE) if m: url = m.group(1) self.urls[target] = URL() self.urls[target].url = m.group(1) self.urls[target].nick = source self.urls[target].timestamp = 'test' tweetbool = tweet.match_tweet_url(url) try: title = utility.timeout(get_title, 10, (url, )) self.urls[target].title = title self.save_last_url(target) if not tweetbool and target in settings.title_channels: bot.tell(target, self.clean(url, title)) except utility.TimeoutException: pass
def on_privmsg(self, bot, source, target, message): m = re.search('((https?:\/\/|www\.)\S+)', message, re.IGNORECASE) if m: url = m.group(1) self.urls[target] = URL() self.urls[target].url = m.group(1) self.urls[target].nick = source self.urls[target].timestamp = 'test' tweetbool = tweet.match_tweet_url(url) try: title = utility.timeout(get_title, 10, (url,)) self.urls[target].title = title self.save_last_url(target) if not tweetbool and target in settings.title_channels: bot.tell(target, self.clean(url, title)) except utility.TimeoutException: pass
def on_privmsg(self, bot, source, target, message): m = re.search('((https?:\/\/|www\.)\S+)', message, re.IGNORECASE) if m: url = m.group(1) self.urls[target] = URL() self.urls[target].url = m.group(1) self.urls[target].nick = source self.urls[target].timestamp = 'test' tweetbool = tweet.match_tweet_url(url) try: title = utility.timeout(get_title, 10, (url,)) self.urls[target].title = title self.save_last_url(target) if not tweetbool and target in ['#c++.se', '#d1d', '#lithen', "#d2006", "#d2005a", "#uppetid", "#starkast", "#testchannel"]: bot.tell(target, self.clean(url, title)) except utility.TimeoutException: pass
def on_privmsg(self, bot, source, target, message): link = None haz_url = re.search('https?:\/\/', message, re.IGNORECASE) if haz_url: link = BeautifulSoup(bleach.linkify(message), 'html5lib').find('a') if link: url = link.attrs['href'] self.urls[target] = URL() self.urls[target].url = url self.urls[target].nick = source self.urls[target].timestamp = 'test' tweetbool = tweet.match_tweet_url(url) try: title = utility.timeout(get_title, 10, (url,)) self.urls[target].title = title self.save_last_url(target) if not tweetbool and target in settings.title_channels: bot.tell(target, self.clean(url, title)) except utility.TimeoutException: print "TitleReaderPlugin utility.TimeoutException for %s" % (url) pass