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. 6
      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"
JOIN_AFTER_CLOAKED = True # Set to false if the bot does not have a cloak JOIN_AFTER_CLOAKED = True # Set to false if the bot does not have a cloak
DISABLE_DEBUG_MODE = False # Entirely disable debug mode DISABLE_DEBUG_MODE = False # Entirely disable debug mode
IGNORE_HIDDEN_COMMANDS = True # Ignore commands sent to @#channel or +#channel 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 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) ADMINS = ("unaffiliated/wolfbot_admin2", "unaffiliated/wolfbot_admin3") # glob syntax supported (wildcards)

6
modules/common.py

@ -7,12 +7,16 @@ import tools.moduleloader as ld
import traceback import traceback
from settings import common as var 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] currmod = ld.MODULES[ld.CURRENT_MODULE]
if botconfig.IGNORE_HIDDEN_COMMANDS and (chan.startswith("@#") or chan.startswith("+#")): if botconfig.IGNORE_HIDDEN_COMMANDS and (chan.startswith("@#") or chan.startswith("+#")):
return 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 chan != botconfig.NICK: #not a PM
if currmod and "" in currmod.COMMANDS.keys(): if currmod and "" in currmod.COMMANDS.keys():
for fn in currmod.COMMANDS[""]: for fn in currmod.COMMANDS[""]:

77
modules/wolfgame.py

@ -35,44 +35,6 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
# Game Logic Begins: # Game Logic Begins:
def connect_callback(cli):
to_be_devoiced = []
@hook("whospcrpl", hookid=294)
def on_whoreply(cli, server, nick, ident, cloak, user, status, acc):
if user in var.USERS: return # Don't add someone who is already there
if user == botconfig.NICK:
cli.nickname = user
cli.ident = ident
cli.hostmask = cloak
if acc == "0":
acc = "*"
if "+" in status:
to_be_devoiced.append(user)
var.USERS[user] = dict(cloak=cloak,account=acc)
@hook("endofwho", hookid=294)
def afterwho(*args):
cmodes = []
for nick in to_be_devoiced:
cmodes.append(("-v", nick))
# devoice all on connect
@hook("quietlist", hookid=294)
def on_quietlist(cli, server, botnick, channel, q, quieted, by, something):
if re.match(".+\!\*@\*", quieted): # only unquiet people quieted by bot
cmodes.append(("-q", quieted))
@hook("quietlistend", hookid=294)
def on_quietlistend(cli, *rest):
decorators.unhook(HOOKS, 294)
mass_mode(cli, cmodes)
cli.mode(botconfig.CHANNEL, "-m") # remove -m mode from channel
cli.mode(botconfig.CHANNEL, "q") # unquiet all
cli.who(botconfig.CHANNEL, "%nuhaf")
var.LAST_PING = None # time of last ping var.LAST_PING = None # time of last ping
var.LAST_STATS = None var.LAST_STATS = None
var.LAST_VOTES = None var.LAST_VOTES = None
@ -112,6 +74,45 @@ def connect_callback(cli):
var.WARN_IDLE_TIME = 0 #180 var.WARN_IDLE_TIME = 0 #180
def connect_callback(cli):
to_be_devoiced = []
@hook("whospcrpl", hookid=294)
def on_whoreply(cli, server, nick, ident, cloak, user, status, acc):
if user in var.USERS: return # Don't add someone who is already there
if user == botconfig.NICK:
cli.nickname = user
cli.ident = ident
cli.hostmask = cloak
if acc == "0":
acc = "*"
if "+" in status:
to_be_devoiced.append(user)
var.USERS[user] = dict(cloak=cloak,account=acc)
@hook("endofwho", hookid=294)
def afterwho(*args):
cmodes = []
for nick in to_be_devoiced:
cmodes.append(("-v", nick))
# devoice all on connect
@hook("quietlist", hookid=294)
def on_quietlist(cli, server, botnick, channel, q, quieted, by, something):
if re.match(".+\!\*@\*", quieted): # only unquiet people quieted by bot
cmodes.append(("-q", quieted))
@hook("quietlistend", hookid=294)
def on_quietlistend(cli, *rest):
decorators.unhook(HOOKS, 294)
mass_mode(cli, cmodes)
cli.mode(botconfig.CHANNEL, "-m") # remove -m mode from channel
cli.mode(botconfig.CHANNEL, "q") # unquiet all
cli.who(botconfig.CHANNEL, "%nuhaf")
def mass_mode(cli, md): def mass_mode(cli, md):

1
wolfbot.py

@ -41,6 +41,7 @@ def main():
cli = IRCClient( cli = IRCClient(
{"privmsg":modules.common.on_privmsg, {"privmsg":modules.common.on_privmsg,
"notice":lambda a, b, c, d: modules.common.on_privmsg(a, b, c, d, True),
"":modules.common.__unhandled__}, "":modules.common.__unhandled__},
host=botconfig.HOST, host=botconfig.HOST,
port=botconfig.PORT, port=botconfig.PORT,

Loading…
Cancel
Save