Example #1
0
def rl(inp, say=None, input=None, bot=None):
    "restart switch."
    if not perm.isadmin(input):
        input.notice("Only bot admins can use this command!")
    elif perm.isadmin(input):
        confofall=bot.config
        for xcon in bot.conns:
            confofall['connections'][xcon]=bot.conns[xcon].conf
        json.dump(confofall, open('config', 'w'), sort_keys=True, indent=1)
        time.sleep(0.1)
        for xcon in bot.conns:
            if inp=="":
                bot.conns[xcon].send('QUIT :\x02\x034,1Restart switch '
                                    'activated by %s.' % (input.nick))
            else:
                bot.conns[xcon].send('QUIT :\x02\x034,1Restart switch '
                        'activated by %s. Reason: %s' % (input.nick, inp))
        time.sleep(0.1)
        if os.name == 'posix':
            client("127.0.0.1", 4329, "bot term. shutdown. NOW")
            time.sleep(1)
            pid = os.getpid()
            os.execl("./b", "b")
            os.system("kill %s" % (pid))
        elif os.name == 'nt':
            os.system(bot.config["restartcmd"])
            client("127.0.0.1", 4329, "bot term. shutdown. NOW")
            time.sleep(1)
            pid = os.getpid()
            os.system("taskkill /PID %s" % (pid))
Example #2
0
def forget(inp, chan='', db=None, nick='', notice=None, modes=None, input=None):
    ".forget [.] <word> -- forgets the mapping that word had, '.' means here only"
    inuserhost = input.user+'@'+input.host
    local, chan, inp = checkinp(chan, inp, True)
    check = inp.split(" ")
    if check[0] == '.':
        local = True
    else:
        local = False
        chan = defaultchan
    db_init(db)

    data = get_memory(db, chan, inp)
    print("data: "+data)
    if data and data.startswith("<locked") and (not(perm.isadmin(input))):
        notice(("[local]" if local else "") + "that factoid is locked.")
        return
    if data and not data.startswith("<forgotten>") and perm.isadmin(input):
        db.execute("replace into memory(chan, word, data, nick) values (?,lower(?),?,?)",(chan, inp, "<forgotten>" + data, nick))
        print "replace into memory(chan, word, data, nick) values (?,lower(?),?,?)", repr((chan, inp, "<forgotten>" + data, nick))
        db.commit()
        notice(("[local]" if local else "") + ('forgot `%s`' % data.replace('`', "'")))
    elif data:
        notice(("[local]" if local else "") + "I already archived that.")
    else:
        notice(("[local]" if local else "") + "I don't know about that.")
Example #3
0
def quitss(inp, input=None, bot=None):
    on=0
    if on==1:
        if perm.isadmin(input):
            input.say("*as Gir* Master, where did you go? I can't see you!")
        else:
            input.say("Bye!")
Example #4
0
def addperm(inp, bot, input, type):
    regex = re.compile("(.*)!(.*)@(.*)")
    match = regex.search(inp)
    if type=="bot":
        type2="bots"
    if type=="voice":
        type2="voiced"
    if type=="admin":
        type2="admins"
    if type=="superadmin":
        type2="superadmins"
    if (inp=='' or inp=="*!*@*") or (not match):
        return("no hostmask was added to the "+type+" list...ignoring command...")
    if perm.isadmin(input) and match and (not match.group(1)=="" and not match.group(2)=="" and not match.group(3)==""):
        if input.conn.conf[type2].count(inp)==0:
            input.conn.conf[type2].append(inp)
            input.conn.conf[type2].sort()
            confofall=bot.config
            for xcon in bot.conns:
                confofall['connections'][xcon]=bot.conns[xcon].conf
                json.dump(confofall, open('config', 'w'), sort_keys=True, 
                                                            indent=1)
                return("done.")
        else:
            return("already a "+type+"...")
    else:
        return("Nope.avi")
Example #5
0
def ply(inp, bot=None, input=None, nick=None, db=None, chan=None):
    "execute local python - only admins can use this"
    if not perm.isadmin(input):
        return "Nope.avi"
    try:
        igncmds = [
            "sys.stdout",
            'send("quit")',
            "send('quit')",
            "conn.connect()",
            "bot.conns[",
            'conf["ftp_pw"]',
            'config["censored_strings"]',
            'conf["server_password"]',
            'conf["nickserv_password"]',
            "conf['ftp_pw']",
            "config['censored_strings']",
            "conf['server_password']",
            "conf['nickserv_password']",
        ]
        for data in igncmds:
            if str(data) in input.inp:
                return "Nope.avi"
        _blah = dict(globals())
        _blah.update(input)
        runcode(inp, _blah)
        if "_r" in _blah:
            out = _blah["_r"]
            igncmds = [
                "sys.stdout",
                'send("quit")',
                "send('quit')",
                "conn.connect()",
                "bot.conns[",
                'conf["ftp_pw"]',
                'config["censored_strings"]',
                'conf["server_password"]',
                'conf["nickserv_password"]',
                "conf['ftp_pw']",
                "config['censored_strings']",
                "conf['server_password']",
                "conf['nickserv_password']",
            ]
            for data in igncmds:
                if str(data) in input.inp:
                    return "Nope.avi"
    except:
        import traceback

        s = traceback.format_exc()
        sp = [x for x in s.split("\n") if x]
        if len(sp) > 2:
            sp = sp[-2:]
        p = 0
        for i in sp:
            p = p + 1
            if p == 1 and "^" in i:
                input.notice(i.replace(" ", "_"))
            else:
                input.notice(i)
Example #6
0
def kick(inp, input=None, notice=None):
    ".kick [channel] <user> [reason] -- kick a user!"
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return
    split = inp.split(" ")
    if split[0][0] == "#":
        chan = split[0]
        user = split[1]
        out = "KICK %s %s" % (chan, user)
        if len(split) > 2:
            reason = ""
            for x in split[2:]:
                reason = reason + x + " "
            reason = reason[:-1]
            out = "%s :%s" % (out,reason)
    else:
        chan = input.chan
        user = split[0]
        out = "KICK %s %s" % (input.chan, split[0])
        if len(split) > 1:
            reason = ""
            for x in split[1:]:
                reason =  "%s%s " % (reason, x)
            reason = reason[:-1]
            out = "%s :%s" % (out,reason)

    notice("Attempting to kick %s from %s..." % (user, chan))
    input.conn.send(out)
Example #7
0
def kickban(inp, chan=None, conn=None, notice=None, input=None):
    if perm.isadmin(input):
        inp = inp.split(" ")
        if inp[0][0] == "#":
            chan = inp[0]
            user = inp[1]
            out1 = "MODE %s +b %s" % (chan, user)
            out2 = "KICK %s %s" % (chan, user)
            if len(inp) > 2:
                reason = ""
                for x in inp[2:]:
                    reason = reason + x + " "
                reason = reason[:-1]
                out = out + " :" + reason
        else:
            user = inp[0]
            out1 = "MODE %s +b %s" % (chan, user)
            out2 = "KICK %s %s" % (chan, user)
            if len(inp) > 1:
                reason = ""
                for x in inp[1:]:
                    reason = reason + x + " "
                reason = reason[:-1]
                out = out + " :" + reason

        notice("Attempting to kickban %s from %s..." % (user, chan))
        conn.send(out1)
        conn.send(out2)
Example #8
0
def cycle(inp, input=None, db=None, notice=None):
    ".cycle <channel> -- cycles a channel"
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return
    notice("Attempting to cycle %s..." % (inp))
    input.conn.send("PART %s" % (inp))
    input.conn.send("JOIN %s" % (inp))
Example #9
0
def nasf(inp, bot=None, input=None):
	"checks to see if the bot cares about what you asked..."
	if perm.isadmin(input):
		return ("%s: Multiple cares found about %s" % (input.nick,
                                                            input.inp))
	else:
		return ("%s: Not a single care was found about%s" % (input.nick,
                                                                input.inp))
Example #10
0
def mem(inp, chan='', db=None, nick='', notice=None, user='', host='', bot=None, modes=None, input=None):
    "controls memory."
    inuserhost = input.user+'@'+input.host
    def lock(name):
        db_init(db)
        local = name.startswith("l:")
        if name.startswith("l:"):
            name = name[2:]
        facchan = defaultchan if not local else chan
        data = get_memory(db, facchan, name)
        if data and data.startswith("<locked"):
            notice("already locked")
        elif data:
            data = "<locked:%s!%s@%s %s %d>%s" % (nick, user, host, chan, time.time(), data)
            db.execute("replace into memory(chan, word, data, nick) values"
               " (?,lower(?),?,?)", (facchan, name, data, nick))
            db.commit()

    def unlock(name):
        db_init(db)
        local = name.startswith("l:")
        if name.startswith("l:"):
            name = name[2:]
        facchan = defaultchan if not local else chan
        data = get_memory(db, facchan, name)
        if data and not data.startswith("<locked"):
            notice("that's not locked..?")
        elif data:
            filtermatch = filter_re.search(data)
            if filtermatch:
                filtername = filtermatch.group(1).lower()
                data = filtermatch.group(2)
                notice("unlocking: " + filtername)
                db.execute("replace into memory(chan, word, data, nick) values"
                   " (?,lower(?),?,?)", (facchan, name, data, nick))
                db.commit()
            else:
                notice("this should never happen, but that doesn't seem to be a valid locked factoid. I'm just gonna delete it and let you recreate it, k?")
                notice("current value: " + repr(data))
                db.execute("delete from memory where chan=? and word=?", (facchan, name))
                db.commit()

    commands = {"lock": [1, lock, "lock"], "unlock": [1, unlock, "lock"]}
    split = inp.split(" ")
    if len(split):
        if not split[0] in commands:
            return "no such command"
        if not (perm.isadmin(input)):
            return "you do not have permission to use that command"
        if len(split) == commands[split[0]][0] + 1:
            func = commands[split[0]][1]
            func(*split[1:])
        else:
            return "wrong number of args for command"
    else:
        return "arguments reqired"
Example #11
0
def joinss(inp, input=None, bot=None):
    on=0
    if on==1:
        if perm.isadmin(input):
            input.say("*as Gir* ooh Hi Master!")
        else:
            if input.nick==input.conn.nick:
                input.say("")
            else:
                input.say("Hi there.")
Example #12
0
def listen(inp, bot=None, input=None):
    "removes the nick/host from the ignore list..."
    if not perm.isadmin(input):
        return("Nope.avi")
    else:
        if perm.isadmin(input) and not inp=='':
            if input.conn.conf["ignore"].count(inp)==1:
                input.conn.conf["ignore"].remove(inp)
                confofall=bot.config
                for xcon in bot.conns:
                    confofall['connections'][xcon]=bot.conns[xcon].conf
                json.dump(confofall, open('config', 'w'), sort_keys=True, 
                                                                indent=1)
                return("done.")
            else:
                return "I am not ignoring that person at this time."
        else:
            return("invalid syntax. ,listen "
            "<channel or nick to be listened to>")
Example #13
0
def save(inp, bot=None, input=None):
    "saves the bot's config. bot admins only."
    if perm.isadmin(input):
        confofall=bot.config
        for xcon in bot.conns:
            confofall['connections'][xcon]=bot.conns[xcon].conf
        json.dump(confofall, open('config', 'w'), sort_keys=True, indent=1)
        return "Done."
    else:
        return "Nope.avi"
Example #14
0
def part(inp, input=None, notice=None, bot=None):
    ".part <channel> -- leaves a channel"
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return
    notice("Attempting to part from %s..."  % (inp))
    input.conn.send("PART %s" % (inp))
    if input.conn.conf['channels'].count(inp)==1:
        input.conn.conf['channels'].remove(inp)
        json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=1)
        return"Done."
Example #15
0
def join(inp, input=None, db=None, notice=None, bot=None):
    ".join <channel> -- joins a channel"
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return
    notice("Attempting to join %s..." % (inp))
    input.conn.send("JOIN %s" % (inp))
    if input.conn.conf['channels'].count(inp)==0:
        input.conn.conf['channels'].append(inp)
        json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=1)
        return"Done."
Example #16
0
def unban(inp, conn=None, chan=None, notice=None, input=None):
    if perm.isadmin(input):
        inp = inp.split(" ")
        if inp[0][0] == "#":
            chan = inp[0]
            user = inp[1]
            out = "MODE %s -b %s" % (chan, user)
        else:
            user = inp[0]
            out = "MODE %s -b %s" % (chan, user)
        notice("Attempting to unban %s from %s..." % (user, chan))
        conn.send(out)
Example #17
0
def system(inp, input=None):
    ".system -- Retrieves information about the host system."
    if perm.isadmin(input):
        name = platform.node()
        os = platform.platform()
        python_version = platform.python_implementation() + ' ' + platform.python_version()
        arch = '-'.join(platform.architecture())
        cpu = platform.machine()
        input.say('Name: \x02%s\x02, Operating System: \x02%s\x02, Python Version: \x02%s\x02, Architecture: \x02%s\x02, CPU: \x02%s' % (name, os, python_version, arch, cpu))
        #input.say('Name: \x034,1\x02%s\x031,0\x02, Operating System: \x034,1\x02%s\x031,0\x02, Python Version: \x034,1\x02%s\x031,0\x02, Architecture: \x034,1\x02%s\x031,0\x02, CPU: \x034,1\x02%s' % (name, os, python_version, arch, cpu))
    else:
        input.say(input.nick+": Nope.avi")
Example #18
0
def remember(inp, nick='', chan='', db=None, input=None, notice=None, bot=None):
    ".remember [.] <word> is <data> -- maps word to data in the memory, '.' means here only"
    inuserhost = input.user+'@'+input.host
    db_init(db)

    local, chan, inp = checkinp(chan, inp, True)

    check = inp.split(" ")
    if check[0] == '.':
        local = True
    else:
        local = False
        chan = defaultchan
    
    try:
        head, tail = inp.split(" ", 1)
    except ValueError:
        return remember.__doc__
    if tail.startswith("is "):
        tail = " ".join(tail.split(" ")[1:])

    if tail.startswith("<locked") and (not(perm.isadmin(input))):
        notice(("[local]" if local else "") + "you may not lock factoids.")
        return

    data = get_memory(db, chan, head)

    if data and data.startswith("<locked") and (not(perm.isadmin(input))):
        input.notice(("[local]" if local else "") + "that factoid is locked.")
        return
    if data and not data.startswith("<forgotten>"):
        notice("but '%s' already means something else!" % head.replace("'", "`"))
        return
    elif data and data.startswith("<forgotten>"):
        input.notice(("[local]" if local else "") + "permanently deleting " + repr(data) + " to accomodate this")

    db.execute("replace into memory(chan, word, data, nick) values (?,lower(?),?,?)", (chan, head, tail, nick))
    print "replace into memory(chan, word, data, nick) values (?,lower(?),?,?)", repr((chan, head, tail, nick))
    db.commit()
    notice(("[local]" if local else "") + 'done.')
Example #19
0
def twittersettings(inp, input=None, bot=None):
    "This command is for the settings of the auto twitter."
    if perm.isadmin(input) and not input.inp=='':
        check = input.inp.split(' ')
        if len(check)>=2:
            print("twitter channel list cmd:: "+str(check))
            if check[0]=='add' and check[1] and check[1]:
                if input.conn.conf["twitterfeedchans"][check[1]].count(check[2])==0:
                    if check[2].startswith("#"):
                        input.conn.conf["twitterfeedchans"][check[1]].append(check[2])
                        input.conn.conf["twitterfeedchans"][check[1]].sort()
                        json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=1)
                        return("done.")
                    else:
                        return(check[2]+" is not a channel! only channels can be added to a twitter feed's channel list!")
                elif input.conn.conf["twitterfeedchans"][check[1]].count(check[2])==1:
                    return("Nope."+check[2]+" is already on "+check[1]+"'s channels list!")
            if check[0]=='add' and (not check[1] or not check[2]):
                return("invalid syntax. please try again with ,twitterchan "+check[0]+" <twitter account> <#channel to add>")
            if check[0]=='del' or check[0]=='delete' and check[1] and check[2]:
                if input.conn.conf["twitterfeedchans"][check[1]].count(str(check[2]))==1:
                    if check[2].startswith("#"):
                        input.conn.conf["twitterfeedchans"][check[1]].remove(check[2])
                        input.conn.conf["twitterfeedchans"][check[1]].sort()
                        json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=1)
                        return("done.")
                    else:
                        return(check[2]+" is not a channel! only channels can be removed from a twitter feed's channel list!")
                else:
                    return("Nope."+check[2]+" is not on "+check[1]+"'s channels list!")
            if check[0]=='del' or check[0]=='delete' and (not check[1] or not check[2]):
                return("invalid syntax. please try again with ,twitterchan "+check[0]+" <twitter account> <#channel to remove>")
            if check[0]=='list' and check[1] and not check[1]=='all':
                tchan={}
                for xcon in bot.conns:
                    tchan[xcon]=[]
                    for channels in bot.conns[xcon].conf["twitterfeedchans"][check[1]]:
                        tchan[xcon].append(channels)
                return("channels that will recieve '"+check[1]+"''s tweets are: "+(str(dict(tchan)).replace("{u'","").replace("u'","").replace("[","").replace("]","").replace("}","").replace("'","")))
            if check[0]=='list' and check[1] and check[1]=='all':
                tchan={}
                for xcon in bot.conns:
                    tchan[xcon]=[]
                    for users in bot.conns[xcon].conf["twitterfeedchans"]:
                        tchan[xcon].append(users)
                return("I am watching these twitter accounts for any new tweets: "+(str(dict(tchan)).replace("{u'","").replace("u'","").replace("[","").replace("]","").replace("}","").replace("'","")))
            if check[0]=='list' and not check[1]:
                return("invalid syntax. please try again with ,twitterchan "+check[0]+" <twitter account>")
            else:
                return("Command not recognised '"+check[0]+"' valid commands for this cmd are : 'add', 'del'/'delete' and 'list'. So replace "+check[0]+" with one of these commands!")
        else:
            return("invalid syntax. please try again with ,twitterchan <add,del/delete,list> <twitter account> [#channel]")
Example #20
0
def ignore(inp, bot=None, input=None):
    "adds a hostmask to the ignore list... eg ,ignore <nick>!<ident>@<host> -- * can be used as an all"
    if not inp.startswith("#"):
        regex = re.compile("(.*)!(.*)@(.*)")
        match = regex.search(inp)
        if (inp=='' or inp=="*!*@*") or (not match):
            return("no hostmask was added to ignore...ignoring command...")
        if perm.isadmin(input) and match and (not match.group(1)=="" and not match.group(2)=="" and not match.group(3)==""):
            if input.conn.conf["ignore"].count(inp)==0:
                input.conn.conf["ignore"].append(inp)
                input.conn.conf["ignore"].sort()
                confofall=bot.config
                for xcon in bot.conns:
                    confofall['connections'][xcon]=bot.conns[xcon].conf
                json.dump(confofall, open('config', 'w'), sort_keys=True, 
                                                            indent=1)
                return("done.")
            else:
                return("already ignored...")
        else:
            return("Nope.avi")
    if inp.startswith("#"):
        if inp=='':
            return("no hostmask was added to ignore...ignoring command...")
        if perm.isadmin(input):
            if input.conn.conf["ignore"].count(inp)==0:
                input.conn.conf["ignore"].append(inp)
                input.conn.conf["ignore"].sort()
                confofall=bot.config
                for xcon in bot.conns:
                    confofall['connections'][xcon]=bot.conns[xcon].conf
                json.dump(confofall, open('config', 'w'), sort_keys=True, 
                                                            indent=1)
                return("done.")
            else:
                return("already ignored...")
        else:
            return("Nope.avi")
Example #21
0
def gtfo(inp, input=None, bot=None):
    "makes me leave the channel. can be used by a channel op or bot admin..."
    if perm.isadmin(input) \
            or "o" in input.conn.users[input.chan].usermodes[input.nick][0]:
        if input.conn.conf['channels'].count(inp)==1:
            input.conn.conf['channels'].remove(inp)
            confofall=bot.config
            for xcon in bot.conns:
                confofall['connections'][xcon]=bot.conns[xcon].conf
            json.dump(confofall, open('config', 'w'), sort_keys=True, 
                                                                indent=1)
        input.conn.send("PART %s" % (input.chan))
    else:
        input.conn.send("PRIVMSG %s :You cannot do this." % (input.nick))
Example #22
0
def no(inp, nick='', chan='', db=None, notice=None, bot=None, modes=None, input=None):
    ".no <word> is <data> -- remaps word to data"
    inuserhost = input.user+'@'+input.host
    local, chan, inp = checkinp(chan, inp, True)
    check = inp.split(" ")
    if check[0] == '.':
        local = True
    else:
        local = False
        chan = defaultchan
    
    db_init(db)
    try:
        head, tail = inp.split(" ", 1)
    except ValueError:
        return no.__doc__
    if tail.startswith("is "):
        tail = " ".join(tail.split(" ")[1:])

    if tail.startswith("<locked") and (not(perm.isadmin(input))):
        notice(("[local]" if local else "") + "you may not lock factoids.")
        return

    data = get_memory(db, chan, head)

    if not data:
        notice("but '%s' doesn't exist!" % head.replace("'", "`"))
        return
    if data and data.startswith("<locked") and (not(perm.isadmin(input))):
        notice(("[local]" if local else "") + "that factoid is locked, sorry.")
        return

    db.execute("replace into memory(chan, word, data, nick) values (?,lower(?),?,?)", (chan, head, tail, nick))
    print "replace into memory(chan, word, data, nick) values (?,lower(?),?,?)", repr((chan, head, tail, nick))
    db.commit()
    notice('forgetting "%s", remembering this instead.' % \
                data.replace('"', "''"))
Example #23
0
 def finaloutput(s, redir, redirto, input, special=None):
     if not s:
         return
     if redirto.startswith("#") and (not(perm.isadmin(input))):
         redirto = nick
         s = "I am not sending factoids into channels. I am not that stupid and only bot admins can do this."
     if redir == ">" and not special:
         input.conn.cmd('PRIVMSG', [redirto, s])
     elif redir == "|" and not special:
         input.say(redirto + ": " + s)
     elif redir == "<" and not special:
         input.notice(s)
     elif special:
         special(s)
     else:
         input.say(s)
Example #24
0
def mode(inp, conn=None, chan=None, notice=None, input=None):
    if perm.isadmin(input):
        inp = inp.split(" ")
        if inp[0][0] == "#":
            chan = inp[0]
            user = inp[1]
            inpmode = inp[2]
            out = "MODE %s %s %s" % (chan, inpmode, user)
        else:
            chan = input.chan
            user = inp[0]
            inpmode = inp[1]
            out = "MODE %s %s %s" % (chan, inpmode, user)
        notice("Attempting to add the flag %s in %s to "
                                "%s..." % (inpmode, chan, user))
        conn.send(out)
Example #25
0
def topic(inp, input=None, notice=None):
    ".topic [channel] <topic> -- change the topic of a channel"
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return
    split = inp.split(" ")
    split[0] = split[0]+ " :"
    lenchan = len(split[0])
    split = str(' '.join(split))
    if split[0][0] == "#":
        if testsf==True:
            out = "TOPIC %s" % (split)
    else:
        if testsf=="":
            out = "PRIVMSG %s :Cant set topic." % (input.nick)
        else:
            out = "PRIVMSG "+input.nick+" :Cant set topic. "
            "Not enough arguements in command." 
    input.conn.send(out)
Example #26
0
def cmdcooldown(inp,input=None,bot=None):
    wait=False
    connitem = input.conn
    for xconn in bot.conns:
        if connitem==bot.conns[xconn]:
            server=xconn
    if input.nick in bot.cooldown[str(server)]:
        bot.cooldown[str(server)][input.nick]+=20
    if ((not perm.isadmin(input)) and (not input.nick in bot.cooldown[str(server)]) and (not input.nick=="") and (input.inp[1].startswith(",") or input.inp[1].startswith("?") or input.inp[1].startswith("!")) and (not input.nick==input.conn.conf["nick"])):
        bot.cooldown[str(server)][input.nick]=7
        time.sleep(1)
        wait=True
    while wait==True:
        if bot.cooldown[str(server)][input.nick]<1:
            del bot.cooldown[str(server)][input.nick]
            wait=False
        else:
            bot.cooldown[str(server)][input.nick]+=-1
            time.sleep(1)
Example #27
0
def say(inp, input=None, notice=None):
    ".say [channel] <message> -- makes the bot say <message> in "
    "[channel]. if [channel] is blank the bot will say the <message> "
    "in the channel the command was used in."
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return None
    split = inp.split(" ")
    if split[0][0] == "#":
        message = ""
        for x in split[1:]:
            message = message + x + " "
        message = message[:-1]
        out = "PRIVMSG %s :%s" % (split[0], message)
    else:
        message = ""
        for x in split[0:]:
            message = message + x + " "
        message = message[:-1]
        out = "PRIVMSG %s :%s" % (input.chan, message)
    input.conn.send(out)
Example #28
0
def act(inp, input=None, notice=None):
    ".act [channel] <action> -- makes the bot act <action> in "
    "[channel]. if [channel] is blank the bot will act the <action> "
    "in the channel the command was used in."
    if not perm.isadmin(input):
        notice("Only bot admins can use this command!")
        return
    split = inp.split(" ")
    if split[0][0] == "#":
        message = ""
        for x in split[1:]:
            message = "%s%s " % (message, x)
        message = message[:-1]
        out = "PRIVMSG %s :\x01ACTION %s\x01" % (split[0], message)
    else:
        message = ""
        for x in split[0:]:
            message = message + x + " "
        message = message[:-1]
        out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message)
    input.conn.send(out)
Example #29
0
def ident(paraml, conn=None, bot=None, input=None):
    ",ident   makes the bot identify with what ever..." \
    " use in case of fire or auto identify failing..."
    if perm.isadmin(input):
        nickserv_password = conn.conf.get('nickserv_password', '')
        nickserv_name = conn.conf.get('nickserv_name', 'nickserv')
        nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY %s')
        nickserv_command2 = conn.conf.get('nickserv_command', 'REGAIN %s %s')
        if nickserv_password:
            if nickserv_password in bot.config['censored_strings']:
                for x in range(0,(bot.config['censored_strings'].count(nickserv_password))):
                    bot.config['censored_strings'].remove(nickserv_password)
            print(bot.config['censored_strings'])
            conn.msg(nickserv_name, nickserv_command2 % (conn.nick,
                                                        nickserv_password))
            conn.msg(nickserv_name, nickserv_command % nickserv_password)
            time.sleep(1)
            bot.config['censored_strings'].append(nickserv_password)
            input.say("Done.")
    else:
        input.say("Nope.avi")
Example #30
0
def cheval(inp, bot=None, input=None, nick=None, db=None, chan=None):
    "checks the bot for values. admins only..."
    if not perm.isadmin(input):
        return "Nope.avi"
    try:
        if '^' in input.paraml[1]:
            inp = str(inp).replace("^", \
                            bot.chanseen[input.conn.name][input.chan][0])
        inpss = "input.say(str("+inp+"))"
        blocked = ["sys.stdout",".connect",'.send',
        "bot.conns[",".conf",".config",".clear",".kill",
        "/home/redm","__import__"]
        igncmds=blocked
        for data in igncmds:
            if str(data) in input.inp:
                return "Nope.avi"
        _blah = dict(globals())
        _blah.update(input)
        runcode(inpss, _blah)
        if "_r" in _blah:
            out = _blah["_r"]
            igncmds=blocked
            for data in igncmds:
                if str(data) in input.inp:
                    return "Nope.avi"
    except:
        import traceback
        s = traceback.format_exc()
        sp = [x for x in s.split("\n") if x]
        if len(sp) > 2: sp = sp[-2:]
        p=0
        for i in sp:
            p=p+1
            if p==1 and "^" in i:
                input.notice(i.replace(" ","_"))
            else:
                input.notice(i)