From 3585e9316ee454f18dd28f75838b317544dbe53c Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Wed, 9 Oct 2024 05:08:37 +0200 Subject: [PATCH] Fall back to @yukikaze-bot/erlpack if erlpack cant be found or loaded --- flake.lock | 12 ++++++------ src/gateway/events/Connection.ts | 7 ++++++- src/gateway/events/Message.ts | 7 ++++++- src/gateway/util/Send.ts | 7 ++++++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 42952374..2e819fa1 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1723637854, - "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=", + "lastModified": 1728241625, + "narHash": "sha256-yumd4fBc/hi8a9QgA9IT8vlQuLZ2oqhkJXHPKxH/tRw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9", + "rev": "c31898adf5a8ed202ce5bea9f347b1c6871f32d1", "type": "github" }, "original": { diff --git a/src/gateway/events/Connection.ts b/src/gateway/events/Connection.ts index 1991ebbe..e2135a13 100644 --- a/src/gateway/events/Connection.ts +++ b/src/gateway/events/Connection.ts @@ -33,7 +33,12 @@ let erlpack: ErlpackType | null = null; try { erlpack = require("erlpack") as ErlpackType; } catch (e) { - // empty + console.log("Failed to import erlpack: ", e); + try { + erlpack = require("@yukikaze-bot/erlpack") as ErlpackType; + } catch (e) { + console.log("Failed to import @yukikaze-bot/erlpack: ", e); + } } // TODO: check rate limit diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts index 52d9edd8..b21965ce 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts @@ -31,7 +31,12 @@ let erlpack: ErlpackType | null = null; try { erlpack = require("erlpack") as ErlpackType; } catch (e) { - // empty + console.log("Failed to import erlpack: ", e); + try { + erlpack = require("@yukikaze-bot/erlpack") as ErlpackType; + } catch (e) { + console.log("Failed to import @yukikaze-bot/erlpack: ", e); + } } export async function Message(this: WebSocket, buffer: WS.Data) { diff --git a/src/gateway/util/Send.ts b/src/gateway/util/Send.ts index 57f87d8b..a1be8398 100644 --- a/src/gateway/util/Send.ts +++ b/src/gateway/util/Send.ts @@ -25,7 +25,12 @@ let erlpack: ErlpackType | null = null; try { erlpack = require("erlpack") as ErlpackType; } catch (e) { - // empty + console.log("Failed to import erlpack: ", e); + try { + erlpack = require("@yukikaze-bot/erlpack") as ErlpackType; + } catch (e) { + console.log("Failed to import @yukikaze-bot/erlpack: ", e); + } } // don't care