misc fixes
This commit is contained in:
parent
105c3dd321
commit
3ddc4e3eb5
|
@ -27,6 +27,7 @@ in
|
||||||
unstable = nixForNixPlugins;
|
unstable = nixForNixPlugins;
|
||||||
};
|
};
|
||||||
matrix-appservice-discord = pkgs.matrix-appservice-discord.overrideAttrs (old: {
|
matrix-appservice-discord = pkgs.matrix-appservice-discord.overrideAttrs (old: {
|
||||||
|
doCheck = false;
|
||||||
patches = (old.patches or []) ++ [
|
patches = (old.patches or []) ++ [
|
||||||
(pkgs.fetchpatch {
|
(pkgs.fetchpatch {
|
||||||
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/eb989fa710e8db4ebc8f2ce36c6679ee6cbc1a44.patch";
|
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/eb989fa710e8db4ebc8f2ce36c6679ee6cbc1a44.patch";
|
||||||
|
@ -44,6 +45,7 @@ in
|
||||||
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/7f3d41d86ebce057cfdc82ce3aaab64b533e8f0b.patch";
|
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/7f3d41d86ebce057cfdc82ce3aaab64b533e8f0b.patch";
|
||||||
hash = "sha256-HmQ1KASZS+a78fe5yOCVXAnXLRmJUglzc6OxNJazOSk=";
|
hash = "sha256-HmQ1KASZS+a78fe5yOCVXAnXLRmJUglzc6OxNJazOSk=";
|
||||||
})
|
})
|
||||||
|
./matrix-appservice-discord/disable-attachment-forwarding-to-matrix.patch
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
# Various patches to change Nix version of existing packages so they don't error out because of nix-plugins in nix.conf
|
# Various patches to change Nix version of existing packages so they don't error out because of nix-plugins in nix.conf
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
diff --git a/src/bot.ts b/src/bot.ts
|
||||||
|
index fc575cd..b0b2624 100644
|
||||||
|
--- a/src/bot.ts
|
||||||
|
+++ b/src/bot.ts
|
||||||
|
@@ -1042,7 +1042,7 @@ export class DiscordBot {
|
||||||
|
try {
|
||||||
|
const intent = this.GetIntentFromDiscordMember(msg.author, msg.webhookID);
|
||||||
|
// Check Attachements
|
||||||
|
- if (!editEventId) {
|
||||||
|
+ if (false && !editEventId) {
|
||||||
|
// on discord you can't edit in images, you can only edit text
|
||||||
|
// so it is safe to only check image upload stuff if we don't have
|
||||||
|
// an edit
|
||||||
|
@@ -1093,6 +1093,11 @@ export class DiscordBot {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
+ for (let attachment of msg.attachments.array()) {
|
||||||
|
+ // this will be a temporary URL, which I don't care about, it's fine
|
||||||
|
+ if (!msg.content) msg.content = "";
|
||||||
|
+ msg.content += "\n" + attachment.url;
|
||||||
|
+ }
|
||||||
|
if (!msg.content && msg.embeds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
|
@ -206,7 +206,7 @@ IF_UNSPEC = -1
|
||||||
PROTO_UNSPEC = -1
|
PROTO_UNSPEC = -1
|
||||||
|
|
||||||
|
|
||||||
Domains = dict[str, dict]
|
Domains = dict[str, "Domains | bool"]
|
||||||
|
|
||||||
|
|
||||||
class NftQuery(TypedDict):
|
class NftQuery(TypedDict):
|
||||||
|
@ -591,15 +591,22 @@ def add_ips(set: str, ipv6: bool, ips: list[str], flush: bool = False):
|
||||||
traceback.print_exc(file=f)
|
traceback.print_exc(file=f)
|
||||||
|
|
||||||
|
|
||||||
def add_split_domain(domains: Domains, split_domain):
|
def add_split_domain(domains: Domains, split_domain: list[str]):
|
||||||
domains1: dict = domains
|
if not split_domain:
|
||||||
while split_domain:
|
return
|
||||||
|
split_domain = split_domain[:]
|
||||||
|
while len(split_domain) > 1:
|
||||||
key = split_domain[-1]
|
key = split_domain[-1]
|
||||||
if key not in domains1.keys():
|
if key in domains.keys():
|
||||||
domains1[key] = {}
|
domains1 = domains[key]
|
||||||
domains = domains1[key]
|
if isinstance(domains1, bool):
|
||||||
split_domain = split_domain[:-1]
|
return
|
||||||
domains1["__IsTrue__"] = True
|
else:
|
||||||
|
domains1 = {}
|
||||||
|
domains[key] = domains1
|
||||||
|
domains = domains1
|
||||||
|
split_domain.pop()
|
||||||
|
domains[split_domain[-1]] = True
|
||||||
|
|
||||||
|
|
||||||
def build_domains(domains: list[str]) -> Domains:
|
def build_domains(domains: list[str]) -> Domains:
|
||||||
|
@ -611,20 +618,14 @@ def build_domains(domains: list[str]) -> Domains:
|
||||||
|
|
||||||
def lookup_domain(domains: Domains, domain: str) -> bool:
|
def lookup_domain(domains: Domains, domain: str) -> bool:
|
||||||
split_domain: list[str] = domain.split(".")
|
split_domain: list[str] = domain.split(".")
|
||||||
domains1: dict = domains
|
|
||||||
while len(split_domain):
|
while len(split_domain):
|
||||||
key: str = split_domain[-1]
|
key: str = split_domain[-1]
|
||||||
split_domain = split_domain[:-1]
|
split_domain = split_domain[:-1]
|
||||||
star: Optional[dict] = domains1.get("*", None)
|
domains1 = domains.get(key, False)
|
||||||
if star is not None and star.get("__IsTrue__", False):
|
if isinstance(domains1, bool):
|
||||||
return True
|
return domains1
|
||||||
domains1 = domains1.get(key, None)
|
domains = domains1
|
||||||
if domains1 is None:
|
|
||||||
return False
|
return False
|
||||||
star = domains.get("*", None)
|
|
||||||
if star is not None and star.get("__IsTrue__", False):
|
|
||||||
return True
|
|
||||||
return bool(domains.get("__IsTrue__", False))
|
|
||||||
|
|
||||||
|
|
||||||
class DpiInfo(TypedDict):
|
class DpiInfo(TypedDict):
|
||||||
|
@ -827,7 +828,7 @@ def operate(id, event, qstate, qdata) -> bool:
|
||||||
n4 = n3.removesuffix(f".{k}")
|
n4 = n3.removesuffix(f".{k}")
|
||||||
qdomains = v["domains"]
|
qdomains = v["domains"]
|
||||||
if not lookup_domain(qdomains, n4):
|
if not lookup_domain(qdomains, n4):
|
||||||
add_split_domain(qdomains, ["*"] + n4.split("."))
|
add_split_domain(qdomains, n4.split("."))
|
||||||
old = []
|
old = []
|
||||||
if os.path.exists(f"/var/lib/unbound/{k}_domains.json"):
|
if os.path.exists(f"/var/lib/unbound/{k}_domains.json"):
|
||||||
with open(f"/var/lib/unbound/{k}_domains.json", "rt") as f:
|
with open(f"/var/lib/unbound/{k}_domains.json", "rt") as f:
|
||||||
|
@ -836,7 +837,7 @@ def operate(id, event, qstate, qdata) -> bool:
|
||||||
f"/var/lib/unbound/{k}_domains.json",
|
f"/var/lib/unbound/{k}_domains.json",
|
||||||
f"/var/lib/unbound/{k}_domains.json.bak",
|
f"/var/lib/unbound/{k}_domains.json.bak",
|
||||||
)
|
)
|
||||||
old.append("*." + n4)
|
old.append(n4)
|
||||||
with open(f"/var/lib/unbound/{k}_domains.json", "wt") as f:
|
with open(f"/var/lib/unbound/{k}_domains.json", "wt") as f:
|
||||||
json.dump(old, f)
|
json.dump(old, f)
|
||||||
elif n2.endswith(f".tmp{NFT_TOKEN}"):
|
elif n2.endswith(f".tmp{NFT_TOKEN}"):
|
||||||
|
@ -846,7 +847,7 @@ def operate(id, event, qstate, qdata) -> bool:
|
||||||
n4 = n3.removesuffix(f".{k}")
|
n4 = n3.removesuffix(f".{k}")
|
||||||
qdomains = v["domains"]
|
qdomains = v["domains"]
|
||||||
if not lookup_domain(qdomains, n4):
|
if not lookup_domain(qdomains, n4):
|
||||||
add_split_domain(qdomains, ["*"] + n4.split("."))
|
add_split_domain(qdomains, n4.split("."))
|
||||||
return True
|
return True
|
||||||
qnames: list[str] = []
|
qnames: list[str] = []
|
||||||
for k, v in NFT_QUERIES.items():
|
for k, v in NFT_QUERIES.items():
|
||||||
|
|
Loading…
Reference in a new issue