Merge branch 'develop' of https://github.com/ClouDev/CloudBot into develop
This commit is contained in:
commit
5844d914de
4 changed files with 77 additions and 51 deletions
|
@ -8,6 +8,7 @@
|
||||||
"user": "cloudbot",
|
"user": "cloudbot",
|
||||||
"realname": "CloudBot - http://git.io/cloudbotirc",
|
"realname": "CloudBot - http://git.io/cloudbotirc",
|
||||||
"nickserv_password": "",
|
"nickserv_password": "",
|
||||||
|
"nickserv_user": "",
|
||||||
"channels": ["#cloudbot", "#cloudbot2"],
|
"channels": ["#cloudbot", "#cloudbot2"],
|
||||||
"invite_join": true,
|
"invite_join": true,
|
||||||
"auto_rejoin": false,
|
"auto_rejoin": false,
|
||||||
|
|
|
@ -22,11 +22,19 @@ def invite(paraml, conn=None):
|
||||||
def onjoin(paraml, conn=None, bot=None):
|
def onjoin(paraml, conn=None, bot=None):
|
||||||
nickserv_password = conn.conf.get('nickserv_password', '')
|
nickserv_password = conn.conf.get('nickserv_password', '')
|
||||||
nickserv_name = conn.conf.get('nickserv_name', 'nickserv')
|
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:
|
if nickserv_password:
|
||||||
|
print "Found a password..."
|
||||||
if nickserv_password in bot.config['censored_strings']:
|
if nickserv_password in bot.config['censored_strings']:
|
||||||
bot.config['censored_strings'].remove(nickserv_password)
|
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)
|
bot.config['censored_strings'].append(nickserv_password)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
|
@ -1,65 +1,37 @@
|
||||||
"""
|
import base64
|
||||||
Plugin which (de)cyphers a string
|
|
||||||
Doesn't cypher non-alphanumeric strings yet.
|
|
||||||
by instanceoftom
|
|
||||||
All character cyphering added - TheNoodle
|
|
||||||
"""
|
|
||||||
|
|
||||||
from util import hook
|
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
|
@hook.command
|
||||||
def cypher(inp):
|
def cypher(inp):
|
||||||
"""cypher <pass> <string> -- Cyphers <string> with <password>."""
|
"""cypher <pass> <string> -- Cyphers <string> with <password>."""
|
||||||
|
|
||||||
passwd = inp.split(" ")[0]
|
passwd = inp.split(" ")[0]
|
||||||
len_passwd = len(passwd)
|
|
||||||
inp = " ".join(inp.split(" ")[1:])
|
inp = " ".join(inp.split(" ")[1:])
|
||||||
|
return encode(passwd,inp)
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def decypher(inp):
|
def decypher(inp):
|
||||||
"""decypher <pass> <string> -- Decyphers <string> with <password>."""
|
"""decypher <pass> <string> -- Decyphers <string> with <password>."""
|
||||||
|
|
||||||
passwd = inp.split(" ")[0]
|
passwd = inp.split(" ")[0]
|
||||||
len_passwd = len(passwd)
|
|
||||||
inp = " ".join(inp.split(" ")[1:])
|
inp = " ".join(inp.split(" ")[1:])
|
||||||
|
return decode(passwd,inp)
|
||||||
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]
|
|
||||||
|
|
|
@ -16,6 +16,19 @@ def mode_cmd(mode, text, inp, chan, conn, notice):
|
||||||
conn.send("MODE {} {} {}".format(channel, mode, target))
|
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"])
|
@hook.command(permissions=["op_ban", "op"])
|
||||||
def ban(inp, conn=None, chan=None, notice=None):
|
def ban(inp, conn=None, chan=None, notice=None):
|
||||||
"""ban [channel] <user> -- Makes the bot ban <user> in [channel].
|
"""ban [channel] <user> -- Makes the bot ban <user> in [channel].
|
||||||
|
@ -134,3 +147,35 @@ def remove(inp, chan=None, conn=None):
|
||||||
message = " ".join(split)
|
message = " ".join(split)
|
||||||
out = "REMOVE {} :{}".format(chan, message)
|
out = "REMOVE {} :{}".format(chan, message)
|
||||||
conn.send(out)
|
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)
|
Reference in a new issue