FireBot/checks.py

32 lines
838 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,
2023-12-05 04:48:56 +00:00
host: Optional[str] = "",
chan: Optional[str] = "",
cmd: Optional[str] = "",
2023-11-21 02:18:48 +00:00
) -> bool:
2023-11-20 23:52:18 +00:00
if (
name.lower() in conf.servers[bot.server]["admins"]
2024-02-15 03:17:08 +00:00
or (host or bot.tmpHost) in conf.admin_hosts
or (host or bot.tmpHost) in conf.servers[bot.server]["hosts"]
2023-11-20 23:52:18 +00:00
):
if bot.current != "bridge":
return True
2024-02-15 03:17:08 +00:00
elif not chan:
2023-11-20 23:52:18 +00:00
return False
else:
2024-02-15 03:17:08 +00:00
bot.msg(f"Sorry {name}, bridged users can't use admin commands.", chan)
2023-11-20 23:52:18 +00:00
return False
2024-02-15 03:17:08 +00:00
elif not chan:
return False
else:
bot.msg(f"Sorry {name}, {cmd} is an admin only command.", chan)
return False