forked from Firepup650/FireBot
General ease-of-use commit
This commit is contained in:
parent
e5b8930c6c
commit
42631780ff
3 changed files with 10 additions and 9 deletions
10
checks.py
10
checks.py
|
@ -8,9 +8,9 @@ import bare, re
|
|||
def admin(
|
||||
bot: bare.bot,
|
||||
name: str,
|
||||
host: Optional[str] = "nul",
|
||||
chan: Optional[str] = "nul",
|
||||
cmd: Optional[str] = "nul",
|
||||
host: Optional[str] = "",
|
||||
chan: Optional[str] = "",
|
||||
cmd: Optional[str] = "",
|
||||
) -> bool:
|
||||
if (
|
||||
name.lower() in conf.servers[bot.server]["admins"]
|
||||
|
@ -20,13 +20,13 @@ def admin(
|
|||
if bot.current != "bridge":
|
||||
return True
|
||||
else:
|
||||
if type(chan) != str or chan == "nul":
|
||||
if not chan:
|
||||
return False
|
||||
else:
|
||||
bot.msg(f"Sorry {name}, bridged users can't use admin commands.", chan)
|
||||
return False
|
||||
else:
|
||||
if type(chan) != str or chan == "nul":
|
||||
if not chan:
|
||||
return False
|
||||
else:
|
||||
bot.msg(f"Sorry {name}, {cmd} is an admin only command.", chan)
|
||||
|
|
|
@ -67,8 +67,9 @@ def mfind(message: str, find: list, usePrefix: bool = True) -> bool:
|
|||
else:
|
||||
return any(message[: len(match)] == match for match in find)
|
||||
|
||||
def sub(message: str, bot: bare.bot, chan: Optional[str], name: Optional[str]):
|
||||
def sub(message: str, bot: bare.bot, chan: Optional[str] = "", name: Optional[str] = "") -> str:
|
||||
result = message.replace("$BOTNICK", bot.nick).replace("$NICK", bot.nick)
|
||||
result = result.replace("$NICKLEN", str(bot.nicklen)).replace("$MAX", str(bot.nicklen))
|
||||
if chan:
|
||||
result = result.replace("$CHANNEL", chan).replace("$CHAN", chan)
|
||||
if name:
|
||||
|
|
|
@ -99,9 +99,9 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str]
|
|||
for cmd in cmds.data:
|
||||
triggers = [cmd]
|
||||
triggers.extend(cmds.data[cmd]["aliases"])
|
||||
triggers = list(call.replace("$BOTNICK", bot.nick.lower()) for call in triggers)
|
||||
triggers = list(conf.sub(call, bot, chan, name).lower() for call in triggers)
|
||||
if conf.mfind(
|
||||
message.lower(),
|
||||
conf.sub(message, bot, chan, name).lower(),
|
||||
triggers,
|
||||
cmds.data[cmd]["prefix"],
|
||||
):
|
||||
|
@ -115,7 +115,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str]
|
|||
if not handled:
|
||||
for check in cmds.regexes:
|
||||
if re.search(
|
||||
check.replace("$MAX", str(bot.nicklen)).replace("$BOTNICK", bot.nick),
|
||||
conf.sub(check, bot, chan, name),
|
||||
message,
|
||||
):
|
||||
cmds.call[check](bot, chan, name, message)
|
||||
|
|
Loading…
Reference in a new issue