diff --git a/core/config.py b/core/config.py index 0401d3a..3354404 100755 --- a/core/config.py +++ b/core/config.py @@ -38,18 +38,14 @@ if not os.path.exists('config'): "bitly_api": "INSERT API KEY FROM bitly.com HERE", "wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE", "lastfm": "INSERT API KEY FROM lastfm HERE", - "mc_user": "INSERT MINECRAFT USERNAME HERE", - "mc_pass": "INSERT MINECRAFT PASSWORD HERE" + "mc_user": "INSERT minecraft USERNAME HERE", + "mc_pass": "INSERT minecraft PASSWORD HERE" }, "plugins": { "factoids": { "prefix": false - }, - "urlparse": - { - "enabled": false } }, "censored_strings": @@ -57,7 +53,7 @@ if not os.path.exists('config'): "mypass", "mysecret" ], - "admins": ["myname"] + "admins": ["myname@myhost"] }''') + '\n') print "Config generated!" print "Please edit the config now!" diff --git a/plugins/admin.py b/plugins/admin.py index 4b65124..38487e1 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -49,15 +49,15 @@ def clearlogs(inp, input=None): @hook.command(adminonly=True) -def join(inp, input=None, notice=None): - ".join -- joins ." +def join(inp, conn=None, notice=None): + ".join -- Joins ." notice("Attempting to join " + inp + "...") conn.cmd("JOIN", [inp]) @hook.command(adminonly=True) def cycle(inp, conn=None, notice=None): - ".cycle -- cycles ." + ".cycle -- Cycles ." notice("Attempting to cycle " + inp + "...") conn.cmd("PART", [inp]) conn.cmd("JOIN", [inp]) @@ -65,7 +65,7 @@ def cycle(inp, conn=None, notice=None): @hook.command(adminonly=True) def part(inp, conn=None, notice=None): - ".part -- parts ." + ".part -- Parts from ." notice("Attempting to part from " + inp + "...") conn.cmd("PART", [inp]) @@ -88,8 +88,10 @@ def raw(inp, conn=None, notice=None): @hook.command(adminonly=True) -def kick(inp, chan=None, notice=None): - ".kick [channel] [reason] -- kicks a user." +def kick(inp, input=None, chan=None, conn=None, notice=None): + ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ + "If [channel] is blank the bot will kick the in "\ + "the channel the command was used in." split = inp.split(" ") if split[0][0] == "#": chan = split[0] @@ -113,11 +115,11 @@ def kick(inp, chan=None, notice=None): out = out + " :" + reason notice("Attempting to kick %s from %s..." % (user, chan)) - input.conn.send(out) + conn.send(out) @hook.command(adminonly=True) -def say(inp, input=None, notice=None): +def say(inp, conn=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." @@ -134,12 +136,12 @@ def say(inp, input=None, notice=None): message = message + x + " " message = message[:-1] out = "PRIVMSG %s :%s" % (input.chan, message) - input.conn.send(out) + conn.send(out) @hook.command("me", adminonly=True) @hook.command(adminonly=True) -def act(inp, input=None, notice=None): +def act(inp, conn=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." @@ -156,7 +158,7 @@ def act(inp, input=None, notice=None): message = message + x + " " message = message[:-1] out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message) - input.conn.send(out) + conn.send(out) @hook.command(adminonly=True) diff --git a/plugins/ignore.py b/plugins/ignore.py new file mode 100755 index 0000000..fbeeba7 --- /dev/null +++ b/plugins/ignore.py @@ -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 -- Makes the bot ignore ." + 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 -- Makes the bot listen to ." + target = inp + + if is_ignored(target): + unignore_target(target) + notice("%s has been unignored." % target) + return + else: + notice("%s is not ignored." % target) + return diff --git a/plugins/mute.py b/plugins/mute.py deleted file mode 100755 index d59ded5..0000000 --- a/plugins/mute.py +++ /dev/null @@ -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 -- Makes the bot ignore ." - 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 -- Makes the bot listen to ." - 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 diff --git a/plugins/sieve.py b/plugins/sieve.py index 46e54b7..64411ee 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -36,11 +36,7 @@ def sieve_suite(bot, input, func, kind, args): if args.get('adminonly', False): admins = bot.config.get('admins', []) - # admins = ["u3601@irccloud.com", "brjannc@smurfed.org"] - - mask = input.user + "@" + input.host - - if mask not in admins: + if input.mask not in admins and input.nick not in admins: return None return input diff --git a/plugins/urlparse.py b/plugins/urlparse.py index d8a9b62..58fb8e2 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -4,8 +4,7 @@ import re titler = re.compile(r'(?si)(.+?)') -def parse(url): - """ an improved version of our parsing code - now regex powered """ +def gettitle(url): url = urlnorm.normalize(url.encode('utf-8')) url = url.decode('utf-8') # add http if its missing @@ -34,4 +33,4 @@ def parse(url): @hook.command def title(inp): ".title -- gets the title of a web page" - return parse(inp) + return gettitle(inp)