forked from Firepup650/FireBot
Formatting
This commit is contained in:
parent
2c10e267e5
commit
b26bd4097f
4 changed files with 18 additions and 22 deletions
2
bare.py
2
bare.py
|
@ -1,9 +1,11 @@
|
|||
#!/usr/bin/python3
|
||||
from socket import socket
|
||||
from overrides import bytes, bbytes
|
||||
|
||||
logs = ...
|
||||
re = ...
|
||||
from typing import NoReturn, Union
|
||||
|
||||
cmds = ...
|
||||
conf = ...
|
||||
sleep = ...
|
||||
|
|
25
handlers.py
25
handlers.py
|
@ -7,6 +7,7 @@ from overrides import bytes, bbytes
|
|||
from importlib import reload
|
||||
import bare
|
||||
|
||||
|
||||
def CTCP(bot: bare.bot, msg: str) -> bool:
|
||||
sender = msg.split("!", 1)[0][1:]
|
||||
kind = msg.split("\x01")[1].split(" ", 1)[0]
|
||||
|
@ -39,6 +40,7 @@ def CTCP(bot: bare.bot, msg: str) -> bool:
|
|||
bot.log(f'Unknown CTCP "{kind}"', "WARN")
|
||||
return False
|
||||
|
||||
|
||||
def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
||||
# Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
|
||||
name = msg.split("!", 1)[0][1:]
|
||||
|
@ -53,9 +55,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
|||
name = Nname
|
||||
message = msg.split(">", 1)[1].strip()
|
||||
else:
|
||||
message = (
|
||||
msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
||||
)
|
||||
message = msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
||||
elif name == bot.nick:
|
||||
return # type: ignore
|
||||
else:
|
||||
|
@ -82,10 +82,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
|||
for cmd in cmds.data:
|
||||
triggers = [cmd]
|
||||
triggers.extend(cmds.data[cmd]["aliases"])
|
||||
triggers = list(
|
||||
call.replace("$BOTNICK", bot.nick.lower())
|
||||
for call in triggers
|
||||
)
|
||||
triggers = list(call.replace("$BOTNICK", bot.nick.lower()) for call in triggers)
|
||||
if conf.mfind(
|
||||
message.lower(),
|
||||
triggers,
|
||||
|
@ -105,9 +102,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
|||
if not handled:
|
||||
for check in cmds.checks:
|
||||
if re.search(
|
||||
check.replace("$MAX", str(bot.nicklen)).replace(
|
||||
"$BOTNICK", bot.nick
|
||||
),
|
||||
check.replace("$MAX", str(bot.nicklen)).replace("$BOTNICK", bot.nick),
|
||||
message,
|
||||
):
|
||||
cmds.call[check](bot, chan, name, message)
|
||||
|
@ -138,15 +133,11 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
|||
mm = open("mastermessages.txt", "r")
|
||||
q = mm.readlines()
|
||||
sel = conf.decode_escapes(
|
||||
str(r.sample(q, 1))
|
||||
.strip("[]'")
|
||||
.replace("\\n", "")
|
||||
.strip('"')
|
||||
str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"')
|
||||
)
|
||||
bot.msg(f"[QUOTE] {sel}", chan)
|
||||
mm.close()
|
||||
return # type: ignore
|
||||
|
||||
handles = {
|
||||
"PRIVMSG": PRIVMSG
|
||||
}
|
||||
|
||||
handles = {"PRIVMSG": PRIVMSG}
|
||||
|
|
5
logs.py
5
logs.py
|
@ -5,7 +5,10 @@ from typing import Union
|
|||
|
||||
|
||||
def log(
|
||||
message: str, origin: str = "Unknown", level: str = "LOG", time: Union[dt, str] = "now"
|
||||
message: str,
|
||||
origin: str = "Unknown",
|
||||
level: str = "LOG",
|
||||
time: Union[dt, str] = "now",
|
||||
) -> None:
|
||||
if level in ["EXIT", "CRASH"]:
|
||||
stream = stderr
|
||||
|
|
|
@ -28,14 +28,14 @@ class bytes(bbytes):
|
|||
errors: str = "strict",
|
||||
) -> _T:
|
||||
if type(thing) == str:
|
||||
cls.value = super().__new__(cls, thing, encoding, errors) # type: ignore
|
||||
cls.value = super().__new__(cls, thing, encoding, errors) # type: ignore
|
||||
elif thing == None:
|
||||
cls.value = super().__new__(cls) # type: ignore
|
||||
cls.value = super().__new__(cls) # type: ignore
|
||||
elif thing != None:
|
||||
cls.value = super().__new__(cls, thing) # type: ignore
|
||||
cls.value = super().__new__(cls, thing) # type: ignore
|
||||
else:
|
||||
raise AttributeError("This shouldn't happen")
|
||||
return cls.value # type: ignore
|
||||
return cls.value # type: ignore
|
||||
|
||||
@classmethod
|
||||
def lazy_decode(cls):
|
||||
|
|
Loading…
Reference in a new issue