From 8c536d4f1eee33ead0c17e34563ca88d3c9f3cc7 Mon Sep 17 00:00:00 2001 From: jcao219 Date: Mon, 25 Jun 2012 17:53:24 -0500 Subject: [PATCH] allow /notice commands as an option in the botconfig (not turned on by default) --- botconfig.py.example | 2 ++ modules/common.py | 8 +++-- modules/wolfgame.py | 77 ++++++++++++++++++++++---------------------- wolfbot.py | 1 + 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/botconfig.py.example b/botconfig.py.example index 81fb2a8..1904948 100644 --- a/botconfig.py.example +++ b/botconfig.py.example @@ -10,6 +10,8 @@ CHANGING_HOST_QUIT_MESSAGE = "Changing host" JOIN_AFTER_CLOAKED = True # Set to false if the bot does not have a cloak DISABLE_DEBUG_MODE = False # Entirely disable debug mode IGNORE_HIDDEN_COMMANDS = True # Ignore commands sent to @#channel or +#channel +ALLOW_NOTICE_COMMANDS = False # allow /notice #channel !command to be interpreted as a command +ALLOW_PRIVATE_NOTICE_COMMANDS = False # allow !command's from /notice (Private) OWNERS = ("unaffiliated/wolfbot_admin1",) # the comma is required at the end if there is one owner ADMINS = ("unaffiliated/wolfbot_admin2", "unaffiliated/wolfbot_admin3") # glob syntax supported (wildcards) diff --git a/modules/common.py b/modules/common.py index dd7a162..3b545e9 100644 --- a/modules/common.py +++ b/modules/common.py @@ -7,11 +7,15 @@ import tools.moduleloader as ld import traceback from settings import common as var -def on_privmsg(cli, rawnick, chan, msg): +def on_privmsg(cli, rawnick, chan, msg, notice = False): currmod = ld.MODULES[ld.CURRENT_MODULE] if botconfig.IGNORE_HIDDEN_COMMANDS and (chan.startswith("@#") or chan.startswith("+#")): return + + if (notice and ((chan != botconfig.NICK and not botconfig.ALLOW_NOTICE_COMMANDS) or + (chan == botconfig.NICK and not botconfig.ALLOW_PRIVATE_NOTICE_COMMANDS))): + return # not allowed in settings if chan != botconfig.NICK: #not a PM if currmod and "" in currmod.COMMANDS.keys(): @@ -79,7 +83,7 @@ def __unhandled__(cli, prefix, cmd, *args): for arg in args if isinstance(arg, bytes)])) - + COMMANDS = {} PM_COMMANDS = {} HOOKS = {} diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 0ba706d..f59a642 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -35,6 +35,45 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False) # Game Logic Begins: +var.LAST_PING = None # time of last ping +var.LAST_STATS = None +var.LAST_VOTES = None +var.LAST_ADMINS = None + +var.USERS = {} + +var.PINGING = False +var.ADMIN_PINGING = False +var.ROLES = {"person" : []} +var.ORIGINAL_ROLES = {} +var.PLAYERS = {} +var.DCED_PLAYERS = {} +var.ADMIN_TO_PING = None +var.AFTER_FLASTGAME = None +var.PHASE = "none" # "join", "day", or "night" +var.TIMERS = [None, None] +var.DEAD = [] + +var.ORIGINAL_SETTINGS = {} + +var.LAST_SAID_TIME = {} + +var.GAME_START_TIME = datetime.now() # for idle checker only +var.GRAVEYARD_LOCK = threading.RLock() +var.GAME_ID = 0 + +var.DISCONNECTED = {} # players who got disconnected + +var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME) + +if botconfig.DEBUG_MODE: + var.NIGHT_TIME_LIMIT = 0 # 90 + var.DAY_TIME_LIMIT_WARN = 0 + var.DAY_TIME_LIMIT_CHANGE = 0 + var.KILL_IDLE_TIME = 0 #300 + var.WARN_IDLE_TIME = 0 #180 + + def connect_callback(cli): to_be_devoiced = [] @@ -73,44 +112,6 @@ def connect_callback(cli): cli.who(botconfig.CHANNEL, "%nuhaf") - var.LAST_PING = None # time of last ping - var.LAST_STATS = None - var.LAST_VOTES = None - var.LAST_ADMINS = None - - var.USERS = {} - - var.PINGING = False - var.ADMIN_PINGING = False - var.ROLES = {"person" : []} - var.ORIGINAL_ROLES = {} - var.PLAYERS = {} - var.DCED_PLAYERS = {} - var.ADMIN_TO_PING = None - var.AFTER_FLASTGAME = None - var.PHASE = "none" # "join", "day", or "night" - var.TIMERS = [None, None] - var.DEAD = [] - - var.ORIGINAL_SETTINGS = {} - - var.LAST_SAID_TIME = {} - - var.GAME_START_TIME = datetime.now() # for idle checker only - var.GRAVEYARD_LOCK = threading.RLock() - var.GAME_ID = 0 - - var.DISCONNECTED = {} # players who got disconnected - - var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME) - - if botconfig.DEBUG_MODE: - var.NIGHT_TIME_LIMIT = 0 # 90 - var.DAY_TIME_LIMIT_WARN = 0 - var.DAY_TIME_LIMIT_CHANGE = 0 - var.KILL_IDLE_TIME = 0 #300 - var.WARN_IDLE_TIME = 0 #180 - diff --git a/wolfbot.py b/wolfbot.py index 57d2745..b9d6c39 100755 --- a/wolfbot.py +++ b/wolfbot.py @@ -41,6 +41,7 @@ def main(): cli = IRCClient( {"privmsg":modules.common.on_privmsg, + "notice":lambda a, b, c, d: modules.common.on_privmsg(a, b, c, d, True), "":modules.common.__unhandled__}, host=botconfig.HOST, port=botconfig.PORT,