FireBot/commands.py

160 lines
4.6 KiB
Python
Raw Normal View History

2023-11-07 05:19:40 +00:00
from subprocess import run, PIPE
2023-11-07 00:18:52 +00:00
2023-11-07 05:19:59 +00:00
2023-11-07 05:19:40 +00:00
def goat(bot, chan: str, name: str, message: str) -> None:
2023-11-07 00:18:52 +00:00
bot.log("GOAT DETECTED")
bot.msg("Hello Goat", chan)
if mfind(
message.lower(),
["!botlist"],
False,
):
2023-11-07 05:19:40 +00:00
bot.msg(
2023-11-07 00:18:52 +00:00
f"Hi! I'm FireBot (https://git.amcforum.wiki/Firepup650/fire-ircbot)! My admins on this server are {adminnames}.",
chan,
)
2023-11-07 05:19:59 +00:00
2023-11-07 05:19:40 +00:00
def bugs(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
bot.msg(
f"\x01ACTION realizes {name} looks like a bug, and squashes {name}\x01",
chan,
)
2023-11-07 05:19:40 +00:00
def hi(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
bot.msg(f"Hello {name}!", chan)
2023-11-07 05:19:40 +00:00
def op(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:22:36 +00:00
bot.op(name, chan)
2023-11-07 05:19:59 +00:00
2023-11-07 05:19:40 +00:00
def ping(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
bot.msg(
f"{name}: pong",
chan,
)
2023-11-07 05:19:40 +00:00
def uptime(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
uptime = run(["uptime", "-p"], stdout=PIPE).stdout.decode().strip()
bot.msg(
f"Uptime: {uptime}",
chan,
)
2023-11-07 05:19:40 +00:00
def isAdmin(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
bot.msg(
f"{name.lower()} in {bot.adminnames} == {name.lower() in bot.adminnames}",
chan,
)
def help(bot, chan: str, name: str, message: str) -> None:
if not helpErr:
bot.msg("Command list needs rework", name)
return
bot.msg("List of commands:", name)
bot.msg(f'Current bot.prefix is "{bot.prefix}"', name)
bot.msg(f"{bot.prefix}help - Sends this help list", name)
bot.msg(f"{bot.prefix}quote - Sends a random firepup quote", name)
2023-11-07 05:19:40 +00:00
bot.msg(
2023-11-07 05:19:59 +00:00
f"{bot.prefix}(eightball,8ball,8b) [question]? - Asks the magic eightball a question",
name,
2023-11-07 00:18:52 +00:00
)
2023-11-07 05:19:59 +00:00
bot.msg(f"(hi,hello) {botnick} - The bot says hi to you", name)
if name.lower() in bot.adminnames:
bot.msg(f"reboot {bot.rebt} - Restarts the bot", name)
bot.msg("op me - Makes the bot try to op you", name)
2023-11-07 05:19:40 +00:00
bot.msg(
2023-11-07 05:19:59 +00:00
f"{bot.prefix}join [channel(s)] - Joins the bot to the specified channel(s)",
2023-11-07 00:18:52 +00:00
name,
)
2023-11-07 05:19:59 +00:00
else:
bot.msg("Sorry, I can't send help to bridged users.", chan)
2023-11-07 05:19:40 +00:00
def goatOn(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
bot.log("GOAT DETECTION ACTIVATED")
bot.gmode = True
2023-11-07 05:19:40 +00:00
def goatOff(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
bot.log("GOAT DETECTION DEACTIVATED")
bot.gmode = False
2023-11-07 05:19:40 +00:00
def quote(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
r.seed()
mm = open("mastermessages.txt", "r")
q = mm.readlines()
sel = decode_escapes(str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"'))
bot.msg(sel, chan)
mm.close()
2023-11-07 05:19:40 +00:00
def join(bot, chan: str, name: str, message: str) -> None:
if name.lower() in bot.adminnames:
newchan = message.split(" ", 1)[1].strip()
channels = bot.join(newchan, chan)
2023-11-07 05:19:59 +00:00
2023-11-07 05:19:40 +00:00
def eball(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
if message.endswith("?"):
eb = open("eightball.txt", "r")
q = eb.readlines()
sel = str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"')
bot.msg(f"The magic eightball says: {sel}", chan)
eb.close()
else:
bot.msg("Please pose a Yes or No question.", chan)
2023-11-07 05:19:40 +00:00
def debug(bot, chan: str, name: str, message: str) -> None:
if name.lower() in bot.adminnames:
bot.msg(f"[DEBUG] NICKLEN={nicklen}", chan)
bot.msg(f"[DEBUG] ADMINS={adminnames}", chan)
bot.msg(f"[DEBUG] CHANNELS={channels}", chan)
2023-11-07 05:19:59 +00:00
2023-11-07 05:19:40 +00:00
def raw(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
sendraw(message.split(" ", 1)[1])
2023-11-07 05:19:40 +00:00
def reboot(bot, chan: str, name: str, message: str) -> None:
if name.lower() in bot.adminnames:
2023-11-07 00:18:52 +00:00
send("QUIT :Rebooting\n")
exit("Reboot")
2023-11-07 05:19:59 +00:00
2023-11-07 05:19:40 +00:00
def sudo(bot, chan: str, name: str, message: str) -> None:
2023-11-07 05:19:59 +00:00
if name.lower() in bot.adminnames:
bot.msg("Error - system failure, contact system operator", chan)
elif "bot" in name.lower():
bot.log("lol, no.")
else:
bot.msg("Access Denied", chan)
2023-11-07 05:19:40 +00:00
def nowplaying(bot, chan: str, name: str, message: str) -> None:
if name in bot.npallowed:
2023-11-07 00:18:52 +00:00
x02 = "\x02"
2023-11-07 05:19:40 +00:00
bot.msg(
2023-11-07 00:18:52 +00:00
f"f.sp {message.split(':')[1].split('(')[0].strip(f' {x02}')}",
chan,
)
2023-11-07 05:19:59 +00:00
data = {
"!botlist": {"prefix": False, "aliases": []},
"bugs bugs bugs": {"prefix": False, "aliases": []},
"hi $BOTNICK": {"prefix": False, "aliases": ["hello $BOTNICK"]},
}
call = {
"!botlist": botlist,
"bugs bugs bugs": bugs,
"hi $BOTNICK": hi,
}