forked from Firepup650/FireBot
Allow certain hostnames to have global admin perks
This commit is contained in:
parent
3960ae7f54
commit
eab0787fff
2 changed files with 8 additions and 2 deletions
|
@ -3,6 +3,7 @@ from os import environ as env
|
|||
from dotenv import load_dotenv
|
||||
import re, codecs
|
||||
from typing import Union, Any
|
||||
import bare
|
||||
|
||||
load_dotenv()
|
||||
__version__ = "v2.0.4"
|
||||
|
@ -34,6 +35,7 @@ servers: dict[str, dict[str, Any]] = {
|
|||
"admins": ["firepup650", "thelounge87"]
|
||||
}
|
||||
}
|
||||
admin_hosts: list[str] = ["firepup.firepi", "owner.firepi", "47.221.227.180"]
|
||||
ESCAPE_SEQUENCE_RE = re.compile(
|
||||
r"""
|
||||
( \\U........ # 8-digit hex escapes
|
||||
|
@ -60,3 +62,6 @@ def mfind(message: str, find: list, usePrefix: bool = True) -> bool:
|
|||
return any(message[: len(match) + 1] == prefix + match for match in find)
|
||||
else:
|
||||
return any(message[: len(match)] == match for match in find)
|
||||
|
||||
def adminCheck(bot: bare.bot, name: str, host: str) -> bool:
|
||||
return name in servers[bot.server]["admins"] or host in admin_hosts
|
||||
|
|
|
@ -44,6 +44,7 @@ def CTCP(bot: bare.bot, msg: str) -> bool:
|
|||
def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str]]:
|
||||
# Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
|
||||
name = msg.split("!", 1)[0][1:]
|
||||
host = msg.split("@", 1)[1].split(" ", 1)[0]
|
||||
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
||||
name == "ReplIRC" and bot.server == "replirc"
|
||||
) or (name == "FirePyLink_" and bot.server == "ircnow"):
|
||||
|
@ -91,7 +92,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str]
|
|||
):
|
||||
if (
|
||||
"admin" in cmds.data[cmd] and cmds.data[cmd]["admin"]
|
||||
) and name not in bot.adminnames:
|
||||
) and not conf.adminCheck(bot, name, host):
|
||||
bot.msg(
|
||||
f"Sorry {name}, you don't have permission to use {cmd.strip()}.",
|
||||
chan,
|
||||
|
@ -110,7 +111,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str]
|
|||
handled = True
|
||||
break
|
||||
if not handled and conf.mfind(message, ["reload"]):
|
||||
if name in bot.adminnames:
|
||||
if conf.adminCheck(bot, name, host):
|
||||
return "reload", chan
|
||||
else:
|
||||
bot.msg(
|
||||
|
|
Loading…
Reference in a new issue