-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update version strings, simplify a ton
- Loading branch information
1 parent
898ca77
commit bdd9f5b
Showing
22 changed files
with
324 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,16 @@ apps via plugins. | |
## example config | ||
|
||
```ts | ||
import { define_config } from 'jsr:@jersey/[email protected]'; | ||
import type { config } from 'jsr:@jersey/[email protected]'; | ||
import { discord_plugin } from 'https://williamhorning.dev/bolt/x/bolt-discord/0.7.0/mod.ts'; | ||
|
||
export default define_config({ | ||
export default { | ||
redis_host: 'localhost', | ||
redis_port: 6379, | ||
plugins: [ | ||
discord_plugin.new({ | ||
// ... | ||
}) | ||
] | ||
}); | ||
} as config; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { lightning } from '../lightning.ts'; | ||
import type { bridge_document } from '../types.ts'; | ||
|
||
export async function exists(l: lightning, key: string) { | ||
return Boolean(await l.redis.sendCommand(['EXISTS', key])); | ||
} | ||
|
||
export async function get_json<T = unknown>( | ||
l: lightning, | ||
key: string | ||
): Promise<T | undefined> { | ||
const reply = await l.redis.sendCommand(['GET', key]); | ||
if (!reply || reply === 'OK') return; | ||
return JSON.parse(reply as string) as T; | ||
} | ||
|
||
export async function del_key(l: lightning, key: string) { | ||
await l.redis.sendCommand(['DEL', key]); | ||
} | ||
|
||
export async function set_json(l: lightning, key: string, value: unknown) { | ||
await l.redis.sendCommand(['SET', key, JSON.stringify(value)]); | ||
} | ||
|
||
export async function get_bridge(l: lightning, id: string) { | ||
return await get_json<bridge_document>(l, `lightning-bridge-${id}`); | ||
} | ||
|
||
export async function get_channel_bridge(l: lightning, id: string) { | ||
const ch = await l.redis.sendCommand(['GET', `lightning-bchannel-${id}`]); | ||
return await get_bridge(l, ch as string); | ||
} | ||
|
||
export async function get_message_bridge(l: lightning, id: string) { | ||
return await get_json<bridge_document>(l, `lightning-bridged-${id}`); | ||
} | ||
|
||
export async function set_bridge(l: lightning, bridge: bridge_document) { | ||
set_json(l, `lightning-bridge-${bridge.id}`, bridge); | ||
|
||
for (const channel of bridge.channels) { | ||
await l.redis.sendCommand([ | ||
'SET', | ||
`lightning-bchannel-${channel.id}`, | ||
bridge.id | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.