forked from Firepup650/FireBot
Mostly pyright and handler re-works
This commit is contained in:
parent
d050de403e
commit
c18027ca9e
4 changed files with 32 additions and 26 deletions
2
bot.py
2
bot.py
|
@ -216,7 +216,7 @@ class bot(bare.bot):
|
||||||
reload(conf)
|
reload(conf)
|
||||||
reload(cmds)
|
reload(cmds)
|
||||||
reload(handlers)
|
reload(handlers)
|
||||||
self.msg("", chan) # type: ignore
|
self.msg("Reloaded successfully", chan) # type: ignore
|
||||||
elif action == "NICK":
|
elif action == "NICK":
|
||||||
name = ircmsg.split("!", 1)[0][1:]
|
name = ircmsg.split("!", 1)[0][1:]
|
||||||
if name == self.nick:
|
if name == self.nick:
|
||||||
|
|
47
commands.py
47
commands.py
|
@ -1,45 +1,46 @@
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
from config import npbase, su, decode_escapes
|
from config import npbase, su, decode_escapes
|
||||||
import random as r
|
import random as r
|
||||||
from typing import Any
|
from typing import Any, Callable
|
||||||
|
import bare
|
||||||
|
|
||||||
|
|
||||||
def goat(bot, chan: str, name: str, message: str) -> None:
|
def goat(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.log("GOAT DETECTED")
|
bot.log("GOAT DETECTED")
|
||||||
bot.msg("Hello Goat", chan)
|
bot.msg("Hello Goat", chan)
|
||||||
bot.gmode = False
|
bot.gmode = False
|
||||||
|
|
||||||
|
|
||||||
def botlist(bot, chan: str, name: str, message: str) -> None:
|
def botlist(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"Hi! I'm FireBot (https://git.amcforum.wiki/Firepup650/fire-ircbot)! My admins on this server are {bot.adminnames}.",
|
f"Hi! I'm FireBot (https://git.amcforum.wiki/Firepup650/fire-ircbot)! My admins on this server are {bot.adminnames}.",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def bugs(bot, chan: str, name: str, message: str) -> None:
|
def bugs(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"\x01ACTION realizes {name} looks like a bug, and squashes {name}\x01",
|
f"\x01ACTION realizes {name} looks like a bug, and squashes {name}\x01",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def hi(bot, chan: str, name: str, message: str) -> None:
|
def hi(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(f"Hello {name}!", chan)
|
bot.msg(f"Hello {name}!", chan)
|
||||||
|
|
||||||
|
|
||||||
def op(bot, chan: str, name: str, message: str) -> None:
|
def op(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.op(name, chan)
|
bot.op(name, chan)
|
||||||
|
|
||||||
|
|
||||||
def ping(bot, chan: str, name: str, message: str) -> None:
|
def ping(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"{name}: pong",
|
f"{name}: pong",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def uptime(bot, chan: str, name: str, message: str) -> None:
|
def uptime(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
uptime = run(["uptime", "-p"], stdout=PIPE).stdout.decode().strip()
|
uptime = run(["uptime", "-p"], stdout=PIPE).stdout.decode().strip()
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"Uptime: {uptime}",
|
f"Uptime: {uptime}",
|
||||||
|
@ -47,14 +48,14 @@ def uptime(bot, chan: str, name: str, message: str) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def isAdmin(bot, chan: str, name: str, message: str) -> None:
|
def isAdmin(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"{name.lower()} in {bot.adminnames} == {name.lower() in bot.adminnames}",
|
f"{name.lower()} in {bot.adminnames} == {name.lower() in bot.adminnames}",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def help(bot, chan: str, name: str, message: str) -> None:
|
def help(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
helpErr = False
|
helpErr = False
|
||||||
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
||||||
name == "ReplIRC" and bot.server == "replirc"
|
name == "ReplIRC" and bot.server == "replirc"
|
||||||
|
@ -86,17 +87,17 @@ def help(bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg("Sorry, I can't send help to bridged users.", chan)
|
bot.msg("Sorry, I can't send help to bridged users.", chan)
|
||||||
|
|
||||||
|
|
||||||
def goatOn(bot, chan: str, name: str, message: str) -> None:
|
def goatOn(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.log("GOAT DETECTION ACTIVATED")
|
bot.log("GOAT DETECTION ACTIVATED")
|
||||||
bot.gmode = True
|
bot.gmode = True
|
||||||
|
|
||||||
|
|
||||||
def goatOff(bot, chan: str, name: str, message: str) -> None:
|
def goatOff(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.log("GOAT DETECTION DEACTIVATED")
|
bot.log("GOAT DETECTION DEACTIVATED")
|
||||||
bot.gmode = False
|
bot.gmode = False
|
||||||
|
|
||||||
|
|
||||||
def quote(bot, chan: str, name: str, message: str) -> None:
|
def quote(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
r.seed()
|
r.seed()
|
||||||
mm = open("mastermessages.txt", "r")
|
mm = open("mastermessages.txt", "r")
|
||||||
q = mm.readlines()
|
q = mm.readlines()
|
||||||
|
@ -105,12 +106,12 @@ def quote(bot, chan: str, name: str, message: str) -> None:
|
||||||
mm.close()
|
mm.close()
|
||||||
|
|
||||||
|
|
||||||
def join(bot, chan: str, name: str, message: str) -> None:
|
def join(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
newchan = message.split(" ", 1)[1].strip()
|
newchan = message.split(" ", 1)[1].strip()
|
||||||
bot.join(newchan, chan)
|
bot.join(newchan, chan)
|
||||||
|
|
||||||
|
|
||||||
def eball(bot, chan: str, name: str, message: str) -> None:
|
def eball(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
if message.endswith("?"):
|
if message.endswith("?"):
|
||||||
eb = open("eightball.txt", "r")
|
eb = open("eightball.txt", "r")
|
||||||
q = eb.readlines()
|
q = eb.readlines()
|
||||||
|
@ -121,7 +122,7 @@ def eball(bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg("Please pose a Yes or No question.", chan)
|
bot.msg("Please pose a Yes or No question.", chan)
|
||||||
|
|
||||||
|
|
||||||
def debug(bot, chan: str, name: str, message: str) -> None:
|
def debug(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
dbg_out = {
|
dbg_out = {
|
||||||
"VERSION": bot.__version__,
|
"VERSION": bot.__version__,
|
||||||
"NICKLEN": bot.nicklen,
|
"NICKLEN": bot.nicklen,
|
||||||
|
@ -132,16 +133,16 @@ def debug(bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(f"[DEBUG] {dbg_out}", chan)
|
bot.msg(f"[DEBUG] {dbg_out}", chan)
|
||||||
|
|
||||||
|
|
||||||
def raw(bot, chan: str, name: str, message: str) -> None:
|
def raw(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.sendraw(message.split(" ", 1)[1])
|
bot.sendraw(message.split(" ", 1)[1])
|
||||||
|
|
||||||
|
|
||||||
def reboot(bot, chan: str, name: str, message: str) -> None:
|
def reboot(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.send("QUIT :Rebooting\n")
|
bot.send("QUIT :Rebooting\n")
|
||||||
bot.exit("Reboot")
|
bot.exit("Reboot")
|
||||||
|
|
||||||
|
|
||||||
def sudo(bot, chan: str, name: str, message: str) -> None:
|
def sudo(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
if name.lower() in bot.adminnames:
|
if name.lower() in bot.adminnames:
|
||||||
bot.msg("Error - system failure, contact system operator", chan)
|
bot.msg("Error - system failure, contact system operator", chan)
|
||||||
elif "bot" in name.lower():
|
elif "bot" in name.lower():
|
||||||
|
@ -150,11 +151,11 @@ def sudo(bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg("Access Denied", chan)
|
bot.msg("Access Denied", chan)
|
||||||
|
|
||||||
|
|
||||||
def nowplaying(bot, chan: str, name: str, message: str) -> None:
|
def nowplaying(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
if name in bot.npallowed:
|
if name in bot.npallowed:
|
||||||
x02 = "\x02"
|
x02 = "\x02"
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"f.sp {message.split(':')[1].split('(')[0].strip(f' {x02}')}",
|
f"f.sp {message.split(x02)[1]}",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -178,8 +179,8 @@ data: dict[str, dict[str, Any]] = {
|
||||||
"ping": {"prefix": True, "aliases": []},
|
"ping": {"prefix": True, "aliases": []},
|
||||||
"op me": {"prefix": False, "aliases": [], "admin": True},
|
"op me": {"prefix": False, "aliases": [], "admin": True},
|
||||||
}
|
}
|
||||||
checks = [npbase, su]
|
checks: list[str] = [npbase, su]
|
||||||
call = {
|
call: dict[str, Callable[[bare.bot, str, str, str], None]] = {
|
||||||
"!botlist": botlist,
|
"!botlist": botlist,
|
||||||
"bugs bugs bugs": bugs,
|
"bugs bugs bugs": bugs,
|
||||||
"hi $BOTNICK": hi,
|
"hi $BOTNICK": hi,
|
||||||
|
|
|
@ -46,7 +46,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str]
|
||||||
name = msg.split("!", 1)[0][1:]
|
name = msg.split("!", 1)[0][1:]
|
||||||
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
||||||
name == "ReplIRC" and bot.server == "replirc"
|
name == "ReplIRC" and bot.server == "replirc"
|
||||||
):
|
) or (name == "FirePyLink_" and bot.server == "ircnow"):
|
||||||
if msg.find("<") != -1 and msg.find(">") != -1:
|
if msg.find("<") != -1 and msg.find(">") != -1:
|
||||||
Nname = msg.split("<", 1)[1].split(">", 1)[0].strip()
|
Nname = msg.split("<", 1)[1].split(">", 1)[0].strip()
|
||||||
if name == "ReplIRC":
|
if name == "ReplIRC":
|
||||||
|
|
7
logs.py
7
logs.py
|
@ -15,7 +15,12 @@ def log(
|
||||||
else:
|
else:
|
||||||
stream = stdout
|
stream = stdout
|
||||||
if time == "now":
|
if time == "now":
|
||||||
time = dt.now()
|
dtime = dt.now()
|
||||||
|
if type(time) == str:
|
||||||
|
raise ValueError("Only \"now\" is an accepted string argument for time")
|
||||||
|
else:
|
||||||
|
dtime = time # type: dt #type: ignore
|
||||||
|
time = dtime.strftime("%H:%M:%S")
|
||||||
if not "\n" in message:
|
if not "\n" in message:
|
||||||
print(f"[{level}][{origin}][{time}] {message}", file=stream)
|
print(f"[{level}][{origin}][{time}] {message}", file=stream)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue