FireBot/checks.py

34 lines
925 B
Python
Raw Normal View History

2023-11-20 23:52:18 +00:00
#!/usr/bin/python3
import config as conf
import random as r
from typing import Any, Callable, Optional
import bare, re
2023-11-21 02:18:48 +00:00
def admin(
bot: bare.bot,
name: str,
host: Optional[str] = "nul",
chan: Optional[str] = "nul",
cmd: Optional[str] = "nul",
) -> bool:
2023-11-20 23:52:18 +00:00
if (
name.lower() in conf.servers[bot.server]["admins"]
or host in conf.admin_hosts
or host in conf.servers[bot.server]["hosts"]
):
if bot.current != "bridge":
return True
else:
if type(chan) != str or chan == "nul":
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":
return False
else:
bot.msg(f"Sorry {name}, {cmd} is an admin only command.", chan)
return False