コード例 #1
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def review_feeds(self, message, keywords):
		if not self.bot.auth.check_logged_in(message.nick):
			self.bot.client.send_notice(message.nick, self.lang.get('access_denied'))
			return
		
		args = message.bot_args.split()
		
		if len(args) == 0:
			# Display a list of unreviewed feeds
			cursor = self.connection.cursor()
			cursor.execute('SELECT * FROM feeds WHERE moderated = 0 ORDER BY id ASC')
			
			self.bot.client.send_notice(message.nick,  \
				Format.color('darkblue') + Format.bold() +  \
				self.lang.get('unreviewed_feeds'))
			for row in cursor:
				self.bot.client.send_notice(message.nick, \
					"%s%s:%s %d %s%s:%s %s" % (Format.bold(),
						self.lang.get('id'), Format.bold(), int(row[0]),
						Format.bold(), self.lang.get('url'), 
						Format.bold(), row[2]
					)
				)
		elif len(args) == 2:
			if not args[0].isdigit():
				self.bot.client.send_notice(message.nick, self.lang.get('invalid_id'))
				return
			
			# Review a feed
			if args[1] in ['ok', 'good', 'yes']:
				cursor = self.connection.cursor()
				cursor.execute('UPDATE feeds SET moderated = 1 WHERE id = ?', (args[0],))
				
				self.connection.commit()
				cursor.close()
				
				self.bot.client.send_notice(message.nick, self.lang.get('feed_reviewed'))
			elif args[1] in ['wrong', 'bad', 'no']:
				cursor = self.connection.cursor()
				cursor.execute('DELETE FROM feeds WHERE id = ?', (args[0],))
				
				self.connection.commit()
				cursor.close()
				
				self.bot.client.send_notice(message.nick, self.lang.get('feed_reviewed'))
			else:
				self.bot.client.send_notice(message.nick, self.lang.get('review_syntax').replace('!', self.bot.settings.get('Bot', 'command_prefix')))
		else:
			self.bot.client.send_notice(message.nick, self.lang.get('review_syntax').replace('!', self.bot.settings.get('Bot', 'command_prefix')))			
コード例 #2
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def send_weekly_top(self, user, message):
		lastfm = LastFMInfo(user)
		
		try:
			tracks = lastfm.get_weekly_tracks()
		except:
			import traceback
			traceback.print_exc()
			self.bot.client.send_pm(message.channel, _("Could not load data, probably the user doesn't exists"))
		else:
			if len(tracks) == 0:
				self.bot.client.send_pm(message.channel, _("No top tracks available"))
			else:
				self.bot.client.send_pm(message.channel, Format.color('darkblue') + Format.bold() + _("Weekly top tracks from %s") % user)
				
				i = 1
				for track in tracks:
					self.bot.client.send_pm(message.channel, Format.bold() + str(i) + ". " + Format.bold() + track)
					i += 1
コード例 #3
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def send_top_artists(self, user, message):
		lastfm = LastFMInfo(user)
		
		try:
			artists = lastfm.get_top_artists()
		except:
			import traceback
			traceback.print_exc()
			self.bot.client.send_pm(message.channel, _("Could not load data, probably the user doesn't exists"))
		else:
			if len(artists) == 0:
				self.bot.client.send_pm(message.channel, _("No top artists available"))
			else:
				self.bot.client.send_pm(message.channel, Format.color('darkblue') + Format.bold() + _("Top artists from %s") % user)
				
				i = 1
				for artist in artists:
					self.bot.client.send_pm(message.channel, Format.bold() + str(i) + ". " + Format.bold() + artist)
					i += 1
コード例 #4
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def list_plugins(self, message, keywords):
		self.bot.client.send_pm(message.nick, "%s%s%s" % (Format.color('darkblue'), Format.bold(), _("Plugin List")))
		
		i = 1
		for plugin_file, plugin in self.bot.plugins.plugins.iteritems():
			self.bot.client.send_pm(message.nick, "%s#%d %s" % (Format.color('darkblue'), i, plugin.plugin_info['name']))
			#time.sleep(0.3)
			i += 1
		
		self.bot.client.send_pm(message.nick, _("Use !plugin plugin_name to view more info about a plugin").replace('!', self.bot.settings.get('Bot', 'command_prefix')))
コード例 #5
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def unload_plugin(self, message, keywords):
		if not self.bot.auth.check_logged_in(message.nick):
			self.bot.client.send_notice(message.nick, _("You do not have enough rights to use this command"))
			return
			
		if len(message.bot_args) == 0:
			return
		
		if not self.manager.unload_plugin(message.bot_args):
			self.bot.client.send_pm(message.channel, Format.color('red') + Format.bold() + _("Could not unload the plugin"))
		else:
			self.bot.client.send_pm(message.channel, Format.color('green') + _("Plugin succesfully unloaded"))
コード例 #6
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def show_plugin_info(self, message, keywords):
		# Check if plugin exists
		plugin_obj = None
		
		if self.bot.plugins.plugins.has_key(message.bot_args):
			plugin_obj = self.bot.plugins.plugins[message.bot_args]
		else:
			for plugin_dir, plugin in self.bot.plugins.plugins.iteritems():
				if self.plugin_info['name'] == message.bot_args:
					plugin_obj = plugin
					break
		
		if plugin_obj != None:
			self.bot.client.send_pm(message.nick, Format.color('darkblue') + Format.bold() + plugin_obj.plugin_info['name'])
			
			if plugin_obj.plugin_info.has_key('description'):
				self.bot.client.send_pm(message.nick, plugin_obj.plugin_info['description'])
			
			if plugin_obj.plugin_info.has_key('authors'):
				self.bot.client.send_pm(message.nick, Format.color('darkblue') + "%s %s" % (_("Created By: "), ', '.join(plugin_obj.plugin_info['authors'])))
			
			if hasattr(plugin_obj, 'commands') and len(plugin_obj.commands) > 0:
				self.bot.client.send_pm(message.nick, Format.bold() + _("Plugin commands:"))
				for command, tuple in plugin_obj.commands.iteritems():
					
					callback, data = tuple
					str = Format.color('darkred') + self.bot.settings.get('Bot', 'command_prefix') + command
					
					if data.has_key('args'):
						str += " %s%s%s" % (Format.color('orange'), data['args'], Format.normal())
					
					if data.has_key('help'):
						str += " - %s%s" % (Format.color('darkblue'), data['help'])
						
					self.bot.client.send_pm(message.nick, str)
		else:
			self.bot.client.send_notice(message.nick, _("The specified plugin does not exists"))
コード例 #7
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def reload_plugins(self, message, keywords):
		if not self.bot.auth.check_logged_in(message.nick):
			self.bot.client.send_notice(message.nick, _("You do not have enough rights to use this command"))
			return
		
		self.bot.client.send_pm(message.channel, Format.color('orange') + _("Reloading.."))
		if len(message.bot_args) != 0:
			success = self.manager.reload_plugin(message.bot_args)
		else:
			success = self.manager.reload_plugins()
		
		if not success:
			self.bot.client.send_pm(message.channel, Format.color('red') + Format.bold() + _("Could not reload the plugin(s)"))
		else:
			self.bot.client.send_pm(message.channel, Format.color('green') + _("Plugin(s) succesfully reloaded"))
コード例 #8
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def send_now_playing(self, user, message):
		lastfm = LastFMInfo(user)
		try:
			title = lastfm.now_playing()
		except:
			import traceback
			traceback.print_exc()
			self.bot.client.send_pm(message.channel, _("Could not load data, probably the user doesn't exists"))
		else:
			if title == False:
				self.bot.client.send_pm(message.channel, _("No track currently playing"))
			else:
				self.bot.client.send_pm(message.channel, Format.color('darkblue') + Format.bold() + _('[%s] Last.FM Now Playing:%s %s') % (user, Format.bold(), title))
		
		del lastfm
コード例 #9
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def read_feed(self, message, keywords):	
		try:	
			url = Format.remove(message.bot_args)
			
			# Check URL
			if not self._validate_url(url):
				url = self.get_url(url)
				if url == None:
					raise RssException, self.lang.get('not_found')
			
			rss = RssFeed(url)
			rss.parse(5)
			
			self.bot.client.send_pm(message.channel, Format.color('darkblue') + Format.bold() + rss.title)
			for item in rss:
				send = "[ %s%s%s ] - %s" % (Format.color('red'), item['link'], Format.normal(), item['title'])
				self.bot.client.send_pm(message.channel, send)
		except RssException, error:
			self.bot.client.send_pm(message.channel, error)
コード例 #10
0
ファイル: __init__.py プロジェクト: Wiebe/wabot
	def show_info(self, message, keywords):
		self.bot.client.send_pm(message.channel, Format.color('darkblue') + Format.bold() + _("LuckyBot, an extendable IRC bot written in python. Version %s" % (luckybot.__version__)))
		self.bot.client.send_pm(message.channel, Format.color('darkblue') + _("Created by Lucas van Dijk. http://www.return1.net"))