Esempio n. 1
0
	def on_privmsg(self, bot, source, target, message):
		m = re.search('((https?:\/\/|www\.)\S+)', message, re.IGNORECASE)

		if m:
			url = m.group(1)
			
			url_obj = URL()
			url_obj.url = m.group(1)
			url_obj.nick = source
			url_obj.timestamp = datetime.now()
			
			try:
				url_obj.title = utility.timeout(get_title, 10, (url,))
			except utility.TimeoutException:
				return
			
			# Anti-old filter?
			if target in ['#d1d']:
				duplicates = self.search_url_list(target, [url_obj.url], False)
				
				if len(duplicates) > 0:
					whine_string = utility.extract_nick(source) + ': OOOLD!!! Already posted '
					whine_string += str(len(duplicates)) + ' time'
					
					if len(duplicates) > 1:
						whine_string += 's'
					
					whine_string += ', most recently by ' + utility.extract_nick(duplicates[-1].nick)
					
					if (datetime.now() - duplicates[-1].timestamp).days > 0:
						whine_string += " (although it was a while ago)"
					else:
						whine_string += duplicates[-1].timestamp.strftime(' at %H:%M:%S >:(')
					
					bot.tell(target, whine_string)
			
			# Save URL
			self.last_urls[target] = url_obj
			self.save_last_url(target)
			
			# Auto-title?
			if target in ['#c++.se', '#d1d', '#lithen', "#d2006"]:
				bot.tell(target, self.clean(url_obj.url, url_obj.title))
Esempio n. 2
0
	def on_privmsg(self, bot, source, target, message):
		self.on_tick(bot, self.time)

		if self.running:
			if self.current_question[1] == message:
				self.timeout_streak = 0

				if source in self.players:
					self.players[source] += 1
				else:
					self.players[source] = 1

				bot.tell(self.name, "Yay! %s got it!" % utility.extract_nick(source))

				self.new_question()
				self.send_question(bot)
Esempio n. 3
0
    def on_privmsg(self, bot, source, target, message):
        self.on_tick(bot, self.time)

        if self.running:
            if self.current_question[1] == message:
                self.timeout_streak = 0

                if source in self.players:
                    self.players[source] += 1
                else:
                    self.players[source] = 1

                bot.tell(self.name,
                         "Yay! %s got it!" % utility.extract_nick(source))

                self.new_question()
                self.send_question(bot)
Esempio n. 4
0
	def format_hiscore(self, tuple):
		return "%s: %d" % (utility.extract_nick(tuple[0]), tuple[1])
Esempio n. 5
0
 def format_hiscore(self, tuple):
     return "%s: %d" % (utility.extract_nick(tuple[0]), tuple[1])