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
|
||||
__pycache__/**
|
||||
tmpbkp/**
|
||||
|
|
3
bare.py
3
bare.py
|
@ -28,10 +28,11 @@ class bot:
|
|||
__version__: str
|
||||
nick: str
|
||||
adminnames: list[str]
|
||||
queue: list[bbytes]
|
||||
queue: list[bbytes] # pyright: ignore [reportInvalidTypeForm]
|
||||
sock: socket
|
||||
npallowed: list[str]
|
||||
current: str
|
||||
tmpHost: 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.nick = "FireBot"
|
||||
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.npallowed = ["FireBitBot"]
|
||||
self.current = "user"
|
||||
|
@ -216,10 +216,12 @@ class bot(bare.bot):
|
|||
action = ircmsg.split(" ", 2)[1].strip()
|
||||
except IndexError:
|
||||
pass
|
||||
self.tmpHost = ""
|
||||
if action in handlers.handles:
|
||||
res, chan = handlers.handles[action](self, ircmsg)
|
||||
if res == "reload" and type(chan) == str:
|
||||
reload(conf)
|
||||
self.__version__ = conf.__version__
|
||||
reload(cmds)
|
||||
reload(handlers)
|
||||
self.msg("Reloaded successfully", chan)
|
||||
|
|
22
checks.py
22
checks.py
|
@ -14,20 +14,18 @@ def admin(
|
|||
) -> bool:
|
||||
if (
|
||||
name.lower() in conf.servers[bot.server]["admins"]
|
||||
or host in conf.admin_hosts
|
||||
or host in conf.servers[bot.server]["hosts"]
|
||||
or (host or bot.tmpHost) in conf.admin_hosts
|
||||
or (host or bot.tmpHost) in conf.servers[bot.server]["hosts"]
|
||||
):
|
||||
if bot.current != "bridge":
|
||||
return True
|
||||
elif not chan:
|
||||
return False
|
||||
else:
|
||||
if not chan:
|
||||
return False
|
||||
else:
|
||||
bot.msg(f"Sorry {name}, bridged users can't use admin commands.", chan)
|
||||
return False
|
||||
bot.msg(f"Sorry {name}, bridged users can't use admin commands.", chan)
|
||||
return False
|
||||
elif not chan:
|
||||
return False
|
||||
else:
|
||||
if not chan:
|
||||
return False
|
||||
else:
|
||||
bot.msg(f"Sorry {name}, {cmd} is an admin only command.", chan)
|
||||
return False
|
||||
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:
|
||||
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,
|
||||
)
|
||||
|
||||
|
@ -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:
|
||||
bot.msg(
|
||||
f"{checks.admin(bot, name)} (hostname is not checked)",
|
||||
f"{'Yes' if checks.admin(bot, name) else 'No'}",
|
||||
chan,
|
||||
)
|
||||
|
||||
|
@ -72,7 +72,7 @@ def help(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
|||
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("op me - Makes the bot try to op you", name)
|
||||
bot.msg(
|
||||
|
@ -98,7 +98,7 @@ def quote(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
|||
query = ""
|
||||
if " " in message:
|
||||
query = message.split(" ", 1)[1]
|
||||
qfilter = query.replace(" ", "\s")
|
||||
qfilter = query.replace(" ", "\s") # pyright: ignore [reportInvalidStringEscapeSequence]
|
||||
r.seed()
|
||||
with open("mastermessages.txt", "r") as mm:
|
||||
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:
|
||||
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]] = {
|
||||
|
|
|
@ -6,8 +6,8 @@ from typing import Optional, Any
|
|||
import bare
|
||||
|
||||
load_dotenv()
|
||||
__version__ = "v2.0.4"
|
||||
npbase: str = "\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?"
|
||||
__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\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
|
||||
su = "^(su|sudo|(su .*|sudo .*))$"
|
||||
servers: dict[str, dict[str, Any]] = {
|
||||
"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]”
|
||||
name = msg.split("!", 1)[0][1:]
|
||||
host = msg.split("@", 1)[1].split(" ", 1)[0]
|
||||
bot.tmpHost = host
|
||||
bridge = False
|
||||
bot.current = "user"
|
||||
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 CTCP(bot, message):
|
||||
kind = message.split("\x01")[1]
|
||||
if kind == "ACTION ducks":
|
||||
bot.msg("\x01ACTION gets hit by a duck\x01", chan)
|
||||
elif kind.startswith("ACTION ducks"):
|
||||
if kind.startswith("ACTION ducks") and len(kind.split(' ', 2)) == 3:
|
||||
bot.msg(
|
||||
f"\x01ACTION gets hit by {kind.split(' ', 2)[2]}\x01",
|
||||
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:
|
||||
r.seed()
|
||||
bot.channels[chan] = 0
|
||||
|
|
|
@ -46,7 +46,7 @@ class bytes(bbytes):
|
|||
|
||||
@classmethod
|
||||
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:
|
||||
return cls.decode(cls.value, errors="ignore") # type: ignore
|
||||
except TypeError:
|
||||
|
|
Loading…
Reference in a new issue