Exemplo n.º 1
0
def on_privmsg(cli, rawnick, chan, msg, notice = False):


	if chan == config.NICK:
		chan = parse_nick(rawnick)[0]

	for fn in decorators.COMMANDS[""]:
		try:
			fn.caller(cli, rawnick, chan, msg)
		except Exception:
			notify_error(cli,chan,log)



	for x in decorators.COMMANDS:
		if chan != parse_nick(rawnick)[0] and not msg.lower().startswith(config.ADDRCHAR):
			break # channel message but no prefix; ignore
		if msg.lower().startswith(config.ADDRCHAR+x):
			h = msg[len(x)+len(config.ADDRCHAR):]
		elif not x or msg.lower().startswith(x):
			h = msg[len(x):]
		else:
			continue
		if not h or h[0] == " ":
			for fn in decorators.COMMANDS.get(x, []):
				try:
					fn.caller(cli, rawnick, chan, h.lstrip())
				except Exception:
					notify_error(cli,chan,log)
Exemplo n.º 2
0
def on_privmsg(cli, rawnick, chan, msg, notice = False):


	if chan == config.NICK:
		chan = parse_nick(rawnick)[0]

	for fn in decorators.COMMANDS[""]:
		try:
			fn.caller(cli, rawnick, chan, msg)
		except Exception:
			notify_error(cli,chan,log)



	for x in decorators.COMMANDS:
		if chan != parse_nick(rawnick)[0] and not msg.lower().startswith(config.ADDRCHAR):
			break # channel message but no prefix; ignore
		if msg.lower().startswith(config.ADDRCHAR+x):
			h = msg[len(x)+len(config.ADDRCHAR):]
		elif not x or msg.lower().startswith(x):
			h = msg[len(x):]
		else:
			continue
		if not h or h[0] == " ":
			for fn in decorators.COMMANDS.get(x, []):
				try:
					fn.caller(cli, rawnick, chan, h.lstrip())
				except Exception:
					notify_error(cli,cli.devchan,log)
Exemplo n.º 3
0
def check(cli, rnick, chan, rest):
    """Gets help."""
    import re
    nick, mode, user, ip = parser.parse_nick(rnick)
    suip = re.findall(r'([0-9.]+){4}/[0-9]*|([0-9A-Fa-f:]+)+/[0-9]*',ip)
    if suip:
        ip = suip[0]
    sident = re.escape(user)
    sip = re.escape(ip)
    snick = re.escape(nick)
    p = Popen('cat raw.log | egrep \'{0}{1}{2}\' | egrep \'!keep|!approve\''.format(snick,"|"+sident if '~' not in ident else "","|"+sip if not ip == 'shell.xshellz.com'),shell=True,stdout=PIPE,stderr=STDOUT)
    t = p.communicate()
    if not t[0] == "":
        ever = t[0].split('\n')
        for x in ever:
            try:
                us = x.split()[-1]
                if  us!= rest:
                    cli.msg("##monitxshellz","{0} and {1} found to be used by the same person".format(us,rest))
            except:
                continue
Exemplo n.º 4
0
def get_help(cli, rnick, chan, rest):
    """Gets help."""
    nick, mode, user, cloak = parser.parse_nick(rnick)
    fns = []

    rest = rest.strip().replace(CMD_CHAR, "", 1).lower()
    splitted = re.split(" +", rest, 1)
    cname = splitted.pop(0)
    rest = splitted[0] if splitted else ""
    if cname:
        if cname in COMMANDS.keys():
            for fn in COMMANDS[cname]:
                if fn.__doc__:
                    got = True
                    if callable(fn.__doc__):
                        msg = CMD_CHAR+cname+": "+fn.__doc__(rest)
                    else:
                        msg = CMD_CHAR+cname+": "+fn.__doc__
                    if chan == nick:
                        cli.msg( nick, msg)
                    else:
                        cli.notice(nick, msg)
                    return
                else:
                    got = False
                    continue
            else:
                if got:
                    return
                elif chan == nick:
                    cli.msg(nick, "Documentation for this command is not available.")
                else:
                    cli.notice(nick, "Documentation for this command is not available.")

        elif chan == nick:
            cli.msg(nick, "Command not found.")
        else:
            cli.notice(nick, "Command not found.")
        return

    # if command was not found, or if no command was given:
    for name,fn in COMMANDS.items():
        if name == '':
            continue
        if (name and not fn[0].admin_only and
            name not in fn[0].aliases and fn[0].chan):
            fns.append("{0}{1}{0}".format(u"\u0002", name))
    afns = []
    if (nick in cli.admin_nicks) or (cloak in cli.ownercloak):
        for name, fn in COMMANDS.items():
            if name == '':
                continue
            if fn[0].admin_only and name not in fn[0].aliases:
                afns.append("{0}{1}{0}".format(u"\u0002", name))
    fns.sort() # Output commands in alphabetical order
    if chan == nick:
        cli.msg(nick, "Available Commands: {0}".format(break_long_message(fns, ", ")))
    else:
        cli.notice(nick, "Available Commands: {0}".format(break_long_message(fns, ", ")))
    if afns:
        afns.sort()
        if chan == nick:
            cli.msg(nick, "Admin Commands: {0}".format(break_long_message(afns, ", ")))
        else:
            cli.notice(nick, "Admin Commands: {0}".format(break_long_message(afns, ", ")))