Merge branch 'develop' of https://github.com/ClouDev/CloudBot into develop

This commit is contained in:
Luke Rogers 2013-09-05 15:54:54 +12:00
commit 5844d914de
4 changed files with 77 additions and 51 deletions

View file

@ -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,

View file

@ -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)

View file

@ -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 <pass> <string> -- Cyphers <string> with <password>."""
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 <pass> <string> -- Decyphers <string> with <password>."""
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)

View file

@ -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] <user> -- Makes the bot ban <user> 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)