diff --git a/config/irc_config.py b/config/irc_config.py index 9f97b36..62ec6db 100644 --- a/config/irc_config.py +++ b/config/irc_config.py @@ -22,5 +22,6 @@ CHANS = ["##earwigbot", "##earwig", "#wikipedia-en-afc"] AFC_CHANS = ["#wikipedia-en-afc"] # report recent AFC changes BOT_CHANS = ["##earwigbot", "#wikipedia-en-afc"] # report edits containing "!earwigbot" -# hardcoded hostnames of users who can use !restart and !git -ADMINS = ["wikipedia/The-Earwig"] +# hardcoded hostnames of users with certain permissions +OWNERS = ["wikipedia/The-Earwig"] # can use owner-only commands (!restart and !git) +ADMINS = ["wikipedia/The-Earwig", "wikipedia/LeonardBloom"] # can use high-risk commands, e.g. !op diff --git a/irc/commands/chanops.py b/irc/commands/chanops.py new file mode 100644 index 0000000..7c22ecc --- /dev/null +++ b/irc/commands/chanops.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +"""Voice/devoice/op/deop users in the channel.""" + +from config.irc_config import * + +connection, data = None, None + +def call(c, d): + global connection, data + connection, data = c, d + + if data.host not in ADMINS: + connection.reply(data.chan, data.nick, "you must be a bot admin to use this command.") + return + + if not data.args: # if it is just !op/!devoice/whatever without arguments, assume they want to do this to themselves + target = data.nick + else: + target = data.args[0] + + action = data.command[1:] # strip ! at the beginning of the command + + connection.say("ChanServ", "%s %s %s" % (action, data.chan, target)) diff --git a/irc/commands/git.py b/irc/commands/git.py index 03d579e..ab17b93 100644 --- a/irc/commands/git.py +++ b/irc/commands/git.py @@ -11,8 +11,8 @@ def call(c, d): global connection, data connection, data = c, d - if data.host not in ADMINS: - connection.reply(data.chan, data.nick, "you must be a bot admin to use this command.") + if data.host not in OWNERS: + connection.reply(data.chan, data.nick, "you must be a bot owner to use this command.") return if not data.args: diff --git a/irc/frontend.py b/irc/frontend.py index 39f3299..1c6967a 100644 --- a/irc/frontend.py +++ b/irc/frontend.py @@ -52,8 +52,8 @@ def main(connection): triggers.check(connection, data, "msg") # check for general messages if data.msg.startswith("!restart"): # hardcode the !restart command (we can't restart from within an ordinary command) - if data.host in ADMINS: - print "restarting bot per admin request..." + if data.host in OWNERS: + print "restarting bot per owner request..." return if line[0] == "PING": # If we are pinged, pong back to the server diff --git a/irc/triggers.py b/irc/triggers.py index 1c93ed6..08a13c2 100644 --- a/irc/triggers.py +++ b/irc/triggers.py @@ -2,7 +2,7 @@ # Check what events on IRC we can respond to. -from irc.commands import test, help, git, link +from irc.commands import test, help, git, link, chanops def check(connection, data, hook): data.parse_args() # parse command arguments into data.command and data.args @@ -30,3 +30,7 @@ def check(connection, data, hook): ("[[" in data.msg and "]]" in data.msg) or ("{{" in data.msg and "}}" in data.msg)): link.call(connection, data) + + elif (data.command == "!voice" or data.command == "!devoice" or + data.command == "!op" or data.command == "!deop"): + chanops.call(connection, data) diff --git a/irc/watcher.py b/irc/watcher.py index 7e4a705..db2c700 100644 --- a/irc/watcher.py +++ b/irc/watcher.py @@ -54,7 +54,7 @@ def report(msg, chans): frontend_conn.say(chan, msg) def check(rc): - """check to see if """ + """check if we're supposed to report this message anywhere""" page_name = rc.page.lower() pretty_msg = rc.pretty()