diff --git a/config.default b/config.default index 43fb526..824cfd1 100644 --- a/config.default +++ b/config.default @@ -8,6 +8,7 @@ "user": "cloudbot", "realname": "CloudBot - http://git.io/cloudbotirc", "nickserv_password": "", + "nickserv_user": "", "channels": ["#cloudbot", "#cloudbot2"], "invite_join": true, "auto_rejoin": false, diff --git a/plugins/core_misc.py b/plugins/core_misc.py index 4fb082f..5e075a9 100755 --- a/plugins/core_misc.py +++ b/plugins/core_misc.py @@ -22,11 +22,19 @@ def invite(paraml, conn=None): def onjoin(paraml, conn=None, bot=None): 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_account_name = conn.conf.get('nickserv_user', '') + nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY') if nickserv_password: + print "Found a password..." if nickserv_password in bot.config['censored_strings']: bot.config['censored_strings'].remove(nickserv_password) - conn.msg(nickserv_name, nickserv_command % nickserv_password) + if nickserv_account_name: + print "Found an account name..." + print "Sending"," ".join([nickserv_command, nickserv_account_name, nickserv_password]),"to",nickserv_name + conn.msg(nickserv_name, " ".join([nickserv_command, nickserv_account_name, nickserv_password])) + else: + print "Sending"," ".join([nickserv_command, nickserv_password]),"to",nickserv_name + conn.msg(nickserv_name, " ".join([nickserv_command, nickserv_password])) bot.config['censored_strings'].append(nickserv_password) time.sleep(1) diff --git a/plugins/cypher.py b/plugins/cypher.py index 1c4d7d6..1527778 100755 --- a/plugins/cypher.py +++ b/plugins/cypher.py @@ -1,65 +1,37 @@ -""" -Plugin which (de)cyphers a string -Doesn't cypher non-alphanumeric strings yet. -by instanceoftom -All character cyphering added - TheNoodle -""" - +import base64 from util import hook +def encode(key, clear): + enc = [] + for i in range(len(clear)): + key_c = key[i % len(key)] + enc_c = chr((ord(clear[i]) + ord(key_c)) % 256) + enc.append(enc_c) + return base64.urlsafe_b64encode("".join(enc)) + +def decode(key, enc): + dec = [] + enc = base64.urlsafe_b64decode(enc.encode('ascii','ignore')) + for i in range(len(enc)): + key_c = key[i % len(key)] + dec_c = chr((256 + ord(enc[i]) - ord(key_c)) % 256) + dec.append(dec_c) + return "".join(dec) + + @hook.command def cypher(inp): """cypher -- Cyphers with .""" passwd = inp.split(" ")[0] - len_passwd = len(passwd) inp = " ".join(inp.split(" ")[1:]) - - out = "" - passwd_index = 0 - for character in inp: - chr_index = ord(character) - passwd_chr_index = ord(passwd[passwd_index]) - - out_chr_index = (chr_index + passwd_chr_index) % 255 - out_chr = chr[out_chr_index] - - out += out_chr - - passwd_index = (passwd_index + 1) % len_passwd - return out + return encode(passwd,inp) @hook.command def decypher(inp): """decypher -- Decyphers with .""" - passwd = inp.split(" ")[0] - len_passwd = len(passwd) inp = " ".join(inp.split(" ")[1:]) - - passwd_index = 0 - for character in inp: - passwd_index = (passwd_index + 1) % len_passwd - - passwd_index -= 1 - reversed_message = inp[::-1] - - out = "" - for character in reversed_message: - try: - chr_index = ord(character) - passwd_chr_index = ord(passwd[passwd_index]) - - out_chr_index = (chr_index - passwd_chr_index) % 255 - out_chr = chars[out_chr_index] - - out += out_chr - - passwd_index = (passwd_index - 1) % len_passwd - except ValueError: - out += character - continue - - return out[::-1] + return decode(passwd,inp) diff --git a/plugins/op.py b/plugins/op.py index bab1979..ed51f3f 100755 --- a/plugins/op.py +++ b/plugins/op.py @@ -16,6 +16,19 @@ def mode_cmd(mode, text, inp, chan, conn, notice): conn.send("MODE {} {} {}".format(channel, mode, target)) +def mode_cmd_no_target(mode, text, inp, chan, conn, notice): + """ generic mode setting function without a target""" + split = inp.split(" ") + if split[0].startswith("#"): + channel = split[0] + notice("Attempting to {} {}...".format(text, channel)) + conn.send("MODE {} {}".format(channel, mode)) + else: + channel = chan + notice("Attempting to {} {}...".format(text, channel)) + conn.send("MODE {} {}".format(channel, mode)) + + @hook.command(permissions=["op_ban", "op"]) def ban(inp, conn=None, chan=None, notice=None): """ban [channel] -- Makes the bot ban in [channel]. @@ -134,3 +147,35 @@ def remove(inp, chan=None, conn=None): message = " ".join(split) out = "REMOVE {} :{}".format(chan, message) conn.send(out) + + +@hook.command(permissions=["op_mute", "op"], autohelp=False) +def mute(inp, conn=None, chan=None, notice=None): + """mute [channel] -- Makes the bot mute a channel.. + If [channel] is blank the bot will mute + the channel the command was used in.""" + mode_cmd_no_target("+m", "mute", inp, chan, conn, notice) + + +@hook.command(permissions=["op_mute", "op"], autohelp=False) +def unmute(inp, conn=None, chan=None, notice=None): + """mute [channel] -- Makes the bot mute a channel.. + If [channel] is blank the bot will mute + the channel the command was used in.""" + mode_cmd_no_target("-m", "unmute", inp, chan, conn, notice) + + +@hook.command(permissions=["op_lock", "op"], autohelp=False) +def lock(inp, conn=None, chan=None, notice=None): + """lock [channel] -- Makes the bot lock a channel. + If [channel] is blank the bot will mute + the channel the command was used in.""" + mode_cmd_no_target("+i", "lock", inp, chan, conn, notice) + + +@hook.command(permissions=["op_lock", "op"], autohelp=False) +def unlock(inp, conn=None, chan=None, notice=None): + """unlock [channel] -- Makes the bot unlock a channel.. + If [channel] is blank the bot will mute + the channel the command was used in.""" + mode_cmd_no_target("-i", "unlock", inp, chan, conn, notice) \ No newline at end of file