All pastes #345657 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-08 18:41 UTC
rendered paste body
	def processCommand(self, line, callbacks=[]):
		"""
		This function processes a command :-)
		"""
		self.proto.sendLine("a")
		if callbacks == []:
			callbacks = self.callbacks
			self.proto.sendLine("as")
		command=line.split()[0]
		self.proto.sendLine("asdf")
		args=line.split()[1:]
		print "   self.proto.sendLine()  ", self.proto.sendLine("asdfasd")

		#Hooks should only return something in special 
		#cases (IE, login plugin returning error because
		#user has still not logged in)
		result, message = self.__runHooks("processCommand", command, args)
		self.proto.sendLine("asdf")
		#Only process the command if no hook has returned error
		if not result:
			if self.commands.has_key(command):
				#return self.commands[command](args)
				newJob = self.commands[command]()
				newJob.command = command
				newJob.args = args
				newJob.sessionManager = self
				newJob.jobID = self.createJobID()
				for callback in callbacks:
					newJob.addCallback(callback)
				self.proto.sendLine("0 Command queued as: " + str(newJob.jobID))
				self.jobManager.add_job(newJob)
			else:
				return (-1, "Command not found")
		else:
			print "hook returned something:", result, message
			return (result, message)