Example #1
0
def handlePubmsg(connection, event):
	nick=event.source().split('!')[0]
	msg=event.arguments()
	msg=msg[0].split(" ")
	chan=event.target()
	if (len(msg) > 0 and msg[0].startswith(conf['prefix'])):
		command=msg[0].split(conf['prefix'])[1]
	if (len(msg) > 0 and msg[0].startswith(conf['aprefix'])):
		acommand=msg[0].split(conf['aprefix'])[1]
	if ('acommand' in locals() and ad.isAdmin(nick)):
		if (acommand == "cmds"):
			x = ", ".join(ad.pubAdmin)
			connection.notice(nick, x)
		elif (ad.isAdmin(nick) and acommand in ad.pubAdmin):
				try:
					package=plug.getPluginPackage(acommand)
					func=getattr(sys.modules[package],"pubadmin_%s" % acommand)
					func(connection, msg[1:], chan, nick)
				except Exception:
					exc_type, exc_value, exc_traceback = sys.exc_info()
					traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout)
	if ('command' in locals()):
		if (command == "cmds"):
			x = ", ".join(coha.pubcmds)
			connection.notice(nick, x)
		if (command in plug.loadedPlugins):
			try:
				package=plug.getPluginPackage(command)
				func=getattr(sys.modules[package],"pub_%s" % command)
				func(connection, msg[1:], chan, nick)
			except Exception:
				exc_type, exc_value, exc_traceback = sys.exc_info()
				logging.exception(traceback.extract_stack())
Example #2
0
def handlePrvmsg(connection, event):
	nick=event.source().split('!')[0]
	msg=event.arguments()
	msg=msg[0].split(" ")
	if (len(msg) > 0 and msg[0].startswith(conf['prefix'])):
		command=msg[0].split(conf['prefix'])[1]
	if (len(msg) > 0 and msg[0].startswith(conf['aprefix'])):
		acommand=msg[0].split(conf['aprefix'])[1]
	chan=nick
	if ('acommand' in locals()):
		if (nick in conf['admins']):
			
			if (acommand == "login" and len(msg) > 1 and ad.isAdmin(nick) == False):
				if (conf['password'] == msg[1]):
					ad.insertAdmin(nick)
					connection.privmsg(nick, "Logged in!")
				else:
					connection.privmsg(nick, "Incorrect Password!")
			elif (acommand == "login" and len(msg) > 1 and ad.isAdmin(nick) == True):
				connection.privmsg(nick,"You are already logged in!")
			elif (ad.isAdmin(nick) and acommand in ad.builtin and len(msg) > 0):
				func=getattr(ad,acommand)
				connection.privmsg(chan,func(msg[1:]))
			elif (ad.isAdmin(nick) and acommand == "cmds"):
				x=""
				if (len(ad.privAdmin) > 0):
					x = ", " + ", ".join(ad.privAdmin)
				connection.privmsg(nick, "%s%s" % (", ".join(ad.builtin),x))
			elif (ad.isAdmin(nick) and acommand in ad.privAdmin):
				try:
					package=plug.getPluginPackage(acommand)
					func=getattr(sys.modules[package],"privadmin_%s" % acommand)
					func(connection, msg[1:], chan, nick)
				except Exception:
					exc_type, exc_value, exc_traceback = sys.exc_info()
					logging.exception(traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout))
	if ('command' in locals() and command in plug.loadedPlugins):
		try:
			package=plug.getPluginPackage(command)
			func=getattr(sys.modules[package],"priv_%s" % command)
			func(connection, msg[1:], chan, nick)
		except Exception:
			exc_type, exc_value, exc_traceback = sys.exc_info()
			logging.exception(traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout))