allow /notice commands as an option in the botconfig (not turned on by default)
This commit is contained in:
parent
0ae9781c5e
commit
033aa41917
@ -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)
|
||||
|
@ -7,12 +7,16 @@ 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():
|
||||
for fn in currmod.COMMANDS[""]:
|
||||
|
@ -35,44 +35,6 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
|
||||
|
||||
# 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_STATS = None
|
||||
var.LAST_VOTES = None
|
||||
@ -112,6 +74,45 @@ def connect_callback(cli):
|
||||
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):
|
||||
|
@ -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…
x
Reference in New Issue
Block a user