Merge branch 'develop' of github.com:ClouDev/CloudBot into develop
This commit is contained in:
commit
9ef6899266
6 changed files with 92 additions and 99 deletions
|
@ -38,18 +38,14 @@ if not os.path.exists('config'):
|
||||||
"bitly_api": "INSERT API KEY FROM bitly.com HERE",
|
"bitly_api": "INSERT API KEY FROM bitly.com HERE",
|
||||||
"wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE",
|
"wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE",
|
||||||
"lastfm": "INSERT API KEY FROM lastfm HERE",
|
"lastfm": "INSERT API KEY FROM lastfm HERE",
|
||||||
"mc_user": "INSERT MINECRAFT USERNAME HERE",
|
"mc_user": "INSERT minecraft USERNAME HERE",
|
||||||
"mc_pass": "INSERT MINECRAFT PASSWORD HERE"
|
"mc_pass": "INSERT minecraft PASSWORD HERE"
|
||||||
},
|
},
|
||||||
"plugins":
|
"plugins":
|
||||||
{
|
{
|
||||||
"factoids":
|
"factoids":
|
||||||
{
|
{
|
||||||
"prefix": false
|
"prefix": false
|
||||||
},
|
|
||||||
"urlparse":
|
|
||||||
{
|
|
||||||
"enabled": false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"censored_strings":
|
"censored_strings":
|
||||||
|
@ -57,7 +53,7 @@ if not os.path.exists('config'):
|
||||||
"mypass",
|
"mypass",
|
||||||
"mysecret"
|
"mysecret"
|
||||||
],
|
],
|
||||||
"admins": ["myname"]
|
"admins": ["myname@myhost"]
|
||||||
}''') + '\n')
|
}''') + '\n')
|
||||||
print "Config generated!"
|
print "Config generated!"
|
||||||
print "Please edit the config now!"
|
print "Please edit the config now!"
|
||||||
|
|
|
@ -49,15 +49,15 @@ def clearlogs(inp, input=None):
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
def join(inp, input=None, notice=None):
|
def join(inp, conn=None, notice=None):
|
||||||
".join <channel> -- joins <channel>."
|
".join <channel> -- Joins <channel>."
|
||||||
notice("Attempting to join " + inp + "...")
|
notice("Attempting to join " + inp + "...")
|
||||||
conn.cmd("JOIN", [inp])
|
conn.cmd("JOIN", [inp])
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
def cycle(inp, conn=None, notice=None):
|
def cycle(inp, conn=None, notice=None):
|
||||||
".cycle <channel> -- cycles <channel>."
|
".cycle <channel> -- Cycles <channel>."
|
||||||
notice("Attempting to cycle " + inp + "...")
|
notice("Attempting to cycle " + inp + "...")
|
||||||
conn.cmd("PART", [inp])
|
conn.cmd("PART", [inp])
|
||||||
conn.cmd("JOIN", [inp])
|
conn.cmd("JOIN", [inp])
|
||||||
|
@ -65,7 +65,7 @@ def cycle(inp, conn=None, notice=None):
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
def part(inp, conn=None, notice=None):
|
def part(inp, conn=None, notice=None):
|
||||||
".part <channel> -- parts <channel>."
|
".part <channel> -- Parts from <channel>."
|
||||||
notice("Attempting to part from " + inp + "...")
|
notice("Attempting to part from " + inp + "...")
|
||||||
conn.cmd("PART", [inp])
|
conn.cmd("PART", [inp])
|
||||||
|
|
||||||
|
@ -88,8 +88,10 @@ def raw(inp, conn=None, notice=None):
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
def kick(inp, chan=None, notice=None):
|
def kick(inp, input=None, chan=None, conn=None, notice=None):
|
||||||
".kick [channel] <user> [reason] -- kicks a user."
|
".kick [channel] <user> [reason] -- Makes the bot kick <user> in [channel] "\
|
||||||
|
"If [channel] is blank the bot will kick the <user> in "\
|
||||||
|
"the channel the command was used in."
|
||||||
split = inp.split(" ")
|
split = inp.split(" ")
|
||||||
if split[0][0] == "#":
|
if split[0][0] == "#":
|
||||||
chan = split[0]
|
chan = split[0]
|
||||||
|
@ -113,11 +115,11 @@ def kick(inp, chan=None, notice=None):
|
||||||
out = out + " :" + reason
|
out = out + " :" + reason
|
||||||
|
|
||||||
notice("Attempting to kick %s from %s..." % (user, chan))
|
notice("Attempting to kick %s from %s..." % (user, chan))
|
||||||
input.conn.send(out)
|
conn.send(out)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
def say(inp, input=None, notice=None):
|
def say(inp, conn=None, notice=None):
|
||||||
".say [channel] <message> -- Makes the bot say <message> in [channel]. "\
|
".say [channel] <message> -- Makes the bot say <message> in [channel]. "\
|
||||||
"If [channel] is blank the bot will say the <message> in "\
|
"If [channel] is blank the bot will say the <message> in "\
|
||||||
"the channel the command was used in."
|
"the channel the command was used in."
|
||||||
|
@ -134,12 +136,12 @@ def say(inp, input=None, notice=None):
|
||||||
message = message + x + " "
|
message = message + x + " "
|
||||||
message = message[:-1]
|
message = message[:-1]
|
||||||
out = "PRIVMSG %s :%s" % (input.chan, message)
|
out = "PRIVMSG %s :%s" % (input.chan, message)
|
||||||
input.conn.send(out)
|
conn.send(out)
|
||||||
|
|
||||||
|
|
||||||
@hook.command("me", adminonly=True)
|
@hook.command("me", adminonly=True)
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
def act(inp, input=None, notice=None):
|
def act(inp, conn=None, notice=None):
|
||||||
".act [channel] <action> -- Makes the bot act out <action> in [channel] "\
|
".act [channel] <action> -- Makes the bot act out <action> in [channel] "\
|
||||||
"If [channel] is blank the bot will act the <action> in "\
|
"If [channel] is blank the bot will act the <action> in "\
|
||||||
"the channel the command was used in."
|
"the channel the command was used in."
|
||||||
|
@ -156,7 +158,7 @@ def act(inp, input=None, notice=None):
|
||||||
message = message + x + " "
|
message = message + x + " "
|
||||||
message = message[:-1]
|
message = message[:-1]
|
||||||
out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message)
|
out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message)
|
||||||
input.conn.send(out)
|
conn.send(out)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
@hook.command(adminonly=True)
|
||||||
|
|
73
plugins/ignore.py
Executable file
73
plugins/ignore.py
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
from util import hook
|
||||||
|
|
||||||
|
ignorelist = []
|
||||||
|
|
||||||
|
|
||||||
|
def ignore_target(target):
|
||||||
|
""" ignores someone """
|
||||||
|
target = target.lower()
|
||||||
|
ignorelist.append(target)
|
||||||
|
|
||||||
|
|
||||||
|
def unignore_target(target):
|
||||||
|
""" unignores someone """
|
||||||
|
target = target.lower()
|
||||||
|
ignorelist.remove(target)
|
||||||
|
|
||||||
|
|
||||||
|
def is_ignored(target):
|
||||||
|
""" checks of someone is ignored """
|
||||||
|
target = target.lower()
|
||||||
|
if target in ignorelist:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@hook.sieve
|
||||||
|
def ignoresieve(bot, input, func, type, args):
|
||||||
|
""" blocks input from ignored channels/users """
|
||||||
|
# don't block input to event hooks
|
||||||
|
if type == "event":
|
||||||
|
return input
|
||||||
|
if is_ignored(input.chan) or is_ignored(input.nick):
|
||||||
|
if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
|
||||||
|
return input
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return input
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command(autohelp=False)
|
||||||
|
def ignored(inp, bot=None):
|
||||||
|
".ignored -- Lists ignored channels/users."
|
||||||
|
if ignorelist:
|
||||||
|
return "Ignored channels/users are: " + ", ".join(ignorelist)
|
||||||
|
else:
|
||||||
|
return "No channels/users are currently ignored."
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command(adminonly=True)
|
||||||
|
def ignore(inp, input=None, notice=None):
|
||||||
|
".ignore <channel/user> -- Makes the bot ignore <channel/user>."
|
||||||
|
target = inp
|
||||||
|
|
||||||
|
if is_ignored(target):
|
||||||
|
notice("%s is already ignored." % target)
|
||||||
|
else:
|
||||||
|
ignore_target(target)
|
||||||
|
notice("%s has been ignored." % target)
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command(adminonly=True)
|
||||||
|
def unignore(inp, input=None, notice=None):
|
||||||
|
".unignore <channel/user> -- Makes the bot listen to <channel/user>."
|
||||||
|
target = inp
|
||||||
|
|
||||||
|
if is_ignored(target):
|
||||||
|
unignore_target(target)
|
||||||
|
notice("%s has been unignored." % target)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
notice("%s is not ignored." % target)
|
||||||
|
return
|
|
@ -1,73 +0,0 @@
|
||||||
from util import hook
|
|
||||||
|
|
||||||
muted = []
|
|
||||||
|
|
||||||
|
|
||||||
def mute_target(target):
|
|
||||||
""" mutes someone """
|
|
||||||
target = target.lower()
|
|
||||||
muted.append(target)
|
|
||||||
|
|
||||||
|
|
||||||
def unmute_target(target):
|
|
||||||
""" unmutes someone """
|
|
||||||
target = target.lower()
|
|
||||||
muted.remove(target)
|
|
||||||
|
|
||||||
|
|
||||||
def is_muted(target):
|
|
||||||
""" checks of someone is muted """
|
|
||||||
target = target.lower()
|
|
||||||
if target in muted:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
@hook.sieve
|
|
||||||
def mutesieve(bot, input, func, type, args):
|
|
||||||
""" blocks input from muted channels/users """
|
|
||||||
# don't block input to event hooks
|
|
||||||
if type == "event":
|
|
||||||
return input
|
|
||||||
if is_muted(input.chan) or is_muted(input.nick):
|
|
||||||
if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute":
|
|
||||||
return input
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
return input
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
|
||||||
def listmuted(inp, bot=None):
|
|
||||||
".listmuted -- Lists muted users/channels."
|
|
||||||
if muted:
|
|
||||||
return "Muted users/channels are: " + ", ".join(muted)
|
|
||||||
else:
|
|
||||||
return "No users are currently muted."
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
|
||||||
def mute(inp, input=None, db=None):
|
|
||||||
".mute <channel/user> -- Makes the bot ignore <channel/user>."
|
|
||||||
target = inp
|
|
||||||
|
|
||||||
if is_muted(target):
|
|
||||||
input.notice("%s is already muted." % target)
|
|
||||||
else:
|
|
||||||
mute_target(target)
|
|
||||||
input.notice("%s has been muted." % target)
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command(adminonly=True)
|
|
||||||
def unmute(inp, input=None, db=None):
|
|
||||||
".unmute <channel/user> -- Makes the bot listen to <channel/user>."
|
|
||||||
target = inp
|
|
||||||
|
|
||||||
if is_muted(target):
|
|
||||||
unmute_target(target)
|
|
||||||
input.notice("%s has been unmuted." % target)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
input.notice("%s is not muted." % target)
|
|
||||||
return
|
|
|
@ -36,11 +36,7 @@ def sieve_suite(bot, input, func, kind, args):
|
||||||
if args.get('adminonly', False):
|
if args.get('adminonly', False):
|
||||||
admins = bot.config.get('admins', [])
|
admins = bot.config.get('admins', [])
|
||||||
|
|
||||||
# admins = ["u3601@irccloud.com", "brjannc@smurfed.org"]
|
if input.mask not in admins and input.nick not in admins:
|
||||||
|
|
||||||
mask = input.user + "@" + input.host
|
|
||||||
|
|
||||||
if mask not in admins:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return input
|
return input
|
||||||
|
|
|
@ -4,8 +4,7 @@ import re
|
||||||
titler = re.compile(r'(?si)<title>(.+?)</title>')
|
titler = re.compile(r'(?si)<title>(.+?)</title>')
|
||||||
|
|
||||||
|
|
||||||
def parse(url):
|
def gettitle(url):
|
||||||
""" an improved version of our parsing code - now regex powered """
|
|
||||||
url = urlnorm.normalize(url.encode('utf-8'))
|
url = urlnorm.normalize(url.encode('utf-8'))
|
||||||
url = url.decode('utf-8')
|
url = url.decode('utf-8')
|
||||||
# add http if its missing
|
# add http if its missing
|
||||||
|
@ -34,4 +33,4 @@ def parse(url):
|
||||||
@hook.command
|
@hook.command
|
||||||
def title(inp):
|
def title(inp):
|
||||||
".title <url> -- gets the title of a web page"
|
".title <url> -- gets the title of a web page"
|
||||||
return parse(inp)
|
return gettitle(inp)
|
||||||
|
|
Reference in a new issue