Просмотр исходного кода

adding channel operation functions (voice, devoice, op, deop)

separate owners and admins in config
fix incomplete docstring in watcher.py
tags/v0.1
Ben Kurtovic 13 лет назад
Родитель
Сommit
38ca184268
6 измененных файлов: 37 добавлений и 8 удалений
  1. +3
    -2
      config/irc_config.py
  2. +24
    -0
      irc/commands/chanops.py
  3. +2
    -2
      irc/commands/git.py
  4. +2
    -2
      irc/frontend.py
  5. +5
    -1
      irc/triggers.py
  6. +1
    -1
      irc/watcher.py

+ 3
- 2
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

+ 24
- 0
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))

+ 2
- 2
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:


+ 2
- 2
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


+ 5
- 1
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)

+ 1
- 1
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()



Загрузка…
Отмена
Сохранить