Exemplo n.º 1
0
	def forceunloadplugin(self, name, tasc):
		"""simply removes name from internal list, only call if unload else fails"""
		if not name in self.plugins:
			Log.error("Plugin %s not loaded" % name)
			return
		self.plugins.pop(name)
		Log.bad("%s UnLog.loaded(Forced)" % name)
Exemplo n.º 2
0
	def addplugin(self, name, tasc):
		"""try to import module name and init it"""
		if name in self.plugins:
			Log.bad("Plugin %s is already loaded" % name)
			return
		try:
			code = __import__(name)
		except ImportError:
			Log.debug('trying to load plugin %s from plugins subdir' % name )
			try:
				pname = 'tasbot.plugins.%s' % name
				__import__(pname)
				code = sys.modules[pname]
			except ImportError, imp:
				Log.error("Cannot load plugin %s" % name)
				Log.exception(imp)
				raise SystemExit(1)
Exemplo n.º 3
0
	def onsaidprivate(self, user, message):
		"""react on a few given keywords and also pass the call to all plugins"""
		args = message.split(" ")
		if args[0].lower() == "!reloadconfig" and user in self.app.admins:
			self.app.ReloadConfig()
		if (args[0].lower() == "!unloadplugin" and
				user in self.app.admins and len(args) == 2):
			try:
				self.unloadplugin(args[1])
			except Exception:
				Log.bad("Unloadplugin failed")
				Log.error(traceback.print_exc())

		if (args[0].lower() == "!loadplugin" and
				user in self.app.admins and len(args) == 2):
			try:
				self.addplugin(args[1], self.app.tasclient)
			except Exception:
				Log.bad("addplugin failed")
				Log.error(traceback.print_exc())

		if (args[0].lower() == "!reloadplugin" and
				user in self.app.admins and len(args) == 2):
			try:
				self.reloadplugin(args[1])
			except Exception:
				Log.bad("Unloadplugin failed")
				Log.error(traceback.print_exc())

		self.forall("onsaidprivate", user, message)
Exemplo n.º 4
0
	def ondisconnected(self):
		Log.bad("Disconnected")