Browse Source

allow /notice commands as an option in the botconfig (not turned on by default)

master
jcao219 13 years ago
parent
commit
8c536d4f1e
  1. 2
      botconfig.py.example
  2. 8
      modules/common.py
  3. 77
      modules/wolfgame.py
  4. 1
      wolfbot.py

2
botconfig.py.example

@ -10,6 +10,8 @@ CHANGING_HOST_QUIT_MESSAGE = "Changing host" @@ -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)

8
modules/common.py

@ -7,11 +7,15 @@ import tools.moduleloader as ld @@ -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): @@ -79,7 +83,7 @@ def __unhandled__(cli, prefix, cmd, *args):
for arg in args
if isinstance(arg, bytes)]))
COMMANDS = {}
PM_COMMANDS = {}
HOOKS = {}

77
modules/wolfgame.py

@ -35,6 +35,45 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False) @@ -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): @@ -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

1
wolfbot.py

@ -41,6 +41,7 @@ def main(): @@ -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,

Loading…
Cancel
Save