A lot of stuff idk
This commit is contained in:
parent
c4c0a4317d
commit
95c2ed64c9
8 changed files with 28 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
.env
|
.env
|
||||||
__pycache__/**
|
__pycache__/**
|
||||||
|
tmpbkp/**
|
||||||
|
|
3
bare.py
3
bare.py
|
@ -28,10 +28,11 @@ class bot:
|
||||||
__version__: str
|
__version__: str
|
||||||
nick: str
|
nick: str
|
||||||
adminnames: list[str]
|
adminnames: list[str]
|
||||||
queue: list[bbytes]
|
queue: list[bbytes] # pyright: ignore [reportInvalidTypeForm]
|
||||||
sock: socket
|
sock: socket
|
||||||
npallowed: list[str]
|
npallowed: list[str]
|
||||||
current: str
|
current: str
|
||||||
|
tmpHost: str
|
||||||
|
|
||||||
def __init__(self, server: str):
|
def __init__(self, server: str):
|
||||||
...
|
...
|
||||||
|
|
4
bot.py
4
bot.py
|
@ -38,7 +38,7 @@ class bot(bare.bot):
|
||||||
self.__version__ = conf.__version__
|
self.__version__ = conf.__version__
|
||||||
self.nick = "FireBot"
|
self.nick = "FireBot"
|
||||||
self.adminnames = conf.servers[server]["admins"]
|
self.adminnames = conf.servers[server]["admins"]
|
||||||
self.queue: list[bbytes] = []
|
self.queue: list[bbytes] = [] # pyright: ignore [reportInvalidTypeForm]
|
||||||
self.sock = socket(AF_INET, SOCK_STREAM)
|
self.sock = socket(AF_INET, SOCK_STREAM)
|
||||||
self.npallowed = ["FireBitBot"]
|
self.npallowed = ["FireBitBot"]
|
||||||
self.current = "user"
|
self.current = "user"
|
||||||
|
@ -216,10 +216,12 @@ class bot(bare.bot):
|
||||||
action = ircmsg.split(" ", 2)[1].strip()
|
action = ircmsg.split(" ", 2)[1].strip()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
self.tmpHost = ""
|
||||||
if action in handlers.handles:
|
if action in handlers.handles:
|
||||||
res, chan = handlers.handles[action](self, ircmsg)
|
res, chan = handlers.handles[action](self, ircmsg)
|
||||||
if res == "reload" and type(chan) == str:
|
if res == "reload" and type(chan) == str:
|
||||||
reload(conf)
|
reload(conf)
|
||||||
|
self.__version__ = conf.__version__
|
||||||
reload(cmds)
|
reload(cmds)
|
||||||
reload(handlers)
|
reload(handlers)
|
||||||
self.msg("Reloaded successfully", chan)
|
self.msg("Reloaded successfully", chan)
|
||||||
|
|
22
checks.py
22
checks.py
|
@ -14,20 +14,18 @@ def admin(
|
||||||
) -> bool:
|
) -> bool:
|
||||||
if (
|
if (
|
||||||
name.lower() in conf.servers[bot.server]["admins"]
|
name.lower() in conf.servers[bot.server]["admins"]
|
||||||
or host in conf.admin_hosts
|
or (host or bot.tmpHost) in conf.admin_hosts
|
||||||
or host in conf.servers[bot.server]["hosts"]
|
or (host or bot.tmpHost) in conf.servers[bot.server]["hosts"]
|
||||||
):
|
):
|
||||||
if bot.current != "bridge":
|
if bot.current != "bridge":
|
||||||
return True
|
return True
|
||||||
|
elif not chan:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
if not chan:
|
bot.msg(f"Sorry {name}, bridged users can't use admin commands.", chan)
|
||||||
return False
|
return False
|
||||||
else:
|
elif not chan:
|
||||||
bot.msg(f"Sorry {name}, bridged users can't use admin commands.", chan)
|
return False
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
if not chan:
|
bot.msg(f"Sorry {name}, {cmd} is an admin only command.", chan)
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
bot.msg(f"Sorry {name}, {cmd} is an admin only command.", chan)
|
|
||||||
return False
|
|
||||||
|
|
10
commands.py
10
commands.py
|
@ -14,7 +14,7 @@ def goat(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
|
|
||||||
def botlist(bot: bare.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 + '.' if bot.adminnames else ''}", # pyright: ignore [reportOperatorIssue]
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def uptime(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
|
|
||||||
def isAdmin(bot: bare.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"{checks.admin(bot, name)} (hostname is not checked)",
|
f"{'Yes' if checks.admin(bot, name) else 'No'}",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ def help(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
bot.msg(f"(hi,hello) {bot.nick} - The bot says hi to you", name)
|
bot.msg(f"(hi,hello) {bot.nick} - The bot says hi to you", name)
|
||||||
if name.lower() in bot.adminnames:
|
if checks.admin(bot, name):
|
||||||
bot.msg(f"reboot {bot.rebt} - Restarts the bot", name)
|
bot.msg(f"reboot {bot.rebt} - Restarts the bot", name)
|
||||||
bot.msg("op me - Makes the bot try to op you", name)
|
bot.msg("op me - Makes the bot try to op you", name)
|
||||||
bot.msg(
|
bot.msg(
|
||||||
|
@ -98,7 +98,7 @@ def quote(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
query = ""
|
query = ""
|
||||||
if " " in message:
|
if " " in message:
|
||||||
query = message.split(" ", 1)[1]
|
query = message.split(" ", 1)[1]
|
||||||
qfilter = query.replace(" ", "\s")
|
qfilter = query.replace(" ", "\s") # pyright: ignore [reportInvalidStringEscapeSequence]
|
||||||
r.seed()
|
r.seed()
|
||||||
with open("mastermessages.txt", "r") as mm:
|
with open("mastermessages.txt", "r") as mm:
|
||||||
q = list(filter(lambda x: re.search(qfilter, x), mm.readlines()))
|
q = list(filter(lambda x: re.search(qfilter, x), mm.readlines()))
|
||||||
|
@ -166,7 +166,7 @@ def nowplaying(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def whoami(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
def whoami(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
bot.msg(f"I think you are {name}", chan)
|
bot.msg(f"I think you are {name} {'(bridge)' if bot.current == 'bridge' else ''}", chan)
|
||||||
|
|
||||||
|
|
||||||
data: dict[str, dict[str, Any]] = {
|
data: dict[str, dict[str, Any]] = {
|
||||||
|
|
|
@ -6,8 +6,8 @@ from typing import Optional, Any
|
||||||
import bare
|
import bare
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
__version__ = "v2.0.4"
|
__version__ = "v2.0.6"
|
||||||
npbase: str = "\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?"
|
npbase: str = "\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
|
||||||
su = "^(su|sudo|(su .*|sudo .*))$"
|
su = "^(su|sudo|(su .*|sudo .*))$"
|
||||||
servers: dict[str, dict[str, Any]] = {
|
servers: dict[str, dict[str, Any]] = {
|
||||||
"ircnow": {
|
"ircnow": {
|
||||||
|
|
|
@ -45,6 +45,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str]
|
||||||
# Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
|
# Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
|
||||||
name = msg.split("!", 1)[0][1:]
|
name = msg.split("!", 1)[0][1:]
|
||||||
host = msg.split("@", 1)[1].split(" ", 1)[0]
|
host = msg.split("@", 1)[1].split(" ", 1)[0]
|
||||||
|
bot.tmpHost = host
|
||||||
bridge = False
|
bridge = False
|
||||||
bot.current = "user"
|
bot.current = "user"
|
||||||
if (
|
if (
|
||||||
|
@ -128,13 +129,13 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str]
|
||||||
if not handled and len(message.split("\x01")) == 3:
|
if not handled and len(message.split("\x01")) == 3:
|
||||||
if not CTCP(bot, message):
|
if not CTCP(bot, message):
|
||||||
kind = message.split("\x01")[1]
|
kind = message.split("\x01")[1]
|
||||||
if kind == "ACTION ducks":
|
if kind.startswith("ACTION ducks") and len(kind.split(' ', 2)) == 3:
|
||||||
bot.msg("\x01ACTION gets hit by a duck\x01", chan)
|
|
||||||
elif kind.startswith("ACTION ducks"):
|
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"\x01ACTION gets hit by {kind.split(' ', 2)[2]}\x01",
|
f"\x01ACTION gets hit by {kind.split(' ', 2)[2]}\x01",
|
||||||
chan,
|
chan,
|
||||||
)
|
)
|
||||||
|
elif kind == "ACTION ducks":
|
||||||
|
bot.msg("\x01ACTION gets hit by a duck\x01", chan)
|
||||||
if chan in bot.channels and bot.channels[chan] >= bot.interval:
|
if chan in bot.channels and bot.channels[chan] >= bot.interval:
|
||||||
r.seed()
|
r.seed()
|
||||||
bot.channels[chan] = 0
|
bot.channels[chan] = 0
|
||||||
|
|
|
@ -46,7 +46,7 @@ class bytes(bbytes):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def safe_decode(cls) -> str:
|
def safe_decode(cls) -> str:
|
||||||
'Calls cls.decode(cls, errors = "ignore"), if that errors, returns a blank string'
|
'Calls cls.decode(cls, errors = "ignore"), if that errors, returns "nul"'
|
||||||
try:
|
try:
|
||||||
return cls.decode(cls.value, errors="ignore") # type: ignore
|
return cls.decode(cls.value, errors="ignore") # type: ignore
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
|
Loading…
Reference in a new issue