Skip to content

Lightning 0.8.0 #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
5000ce9
formatting changes
williamhorning Oct 3, 2024
b5ffa7a
changes to temporal interface
williamhorning Oct 3, 2024
686e387
steps towards postgres
williamhorning Nov 12, 2024
da596ca
cleanup and add back cli
williamhorning Nov 16, 2024
5b35253
cleanup some stuff
williamhorning Nov 16, 2024
9fef901
clean up error handling a little
williamhorning Nov 16, 2024
93833f7
clean up the data structures a little bit?
williamhorning Nov 27, 2024
cc0d5cd
clean up unnecessary catches
williamhorning Nov 27, 2024
a349663
working postgres
williamhorning Nov 28, 2024
d9a8aa5
commands v2 starter
williamhorning Nov 28, 2024
0625771
commands v2
williamhorning Nov 28, 2024
7ba9ec3
replace log_error in most places
williamhorning Nov 28, 2024
aa323de
discord commands_v2
williamhorning Nov 29, 2024
845d7a0
errors v2 and pluginz v8
williamhorning Nov 29, 2024
460b9c0
change structure a bit
williamhorning Nov 29, 2024
ae7fd39
discord plugin to v8
williamhorning Nov 30, 2024
17f2a95
quick fix but otherwise it works i think
williamhorning Nov 30, 2024
7701d51
telegram plugin v8
williamhorning Nov 30, 2024
f2e26a3
rename thingies
williamhorning Nov 30, 2024
0a15686
formatting
williamhorning Nov 30, 2024
aae8135
split file proxy
williamhorning Nov 30, 2024
c1e27e5
fixes and stuff
williamhorning Nov 30, 2024
71741ac
use_rawname
williamhorning Dec 1, 2024
d5eb7c2
guilded and revolt stuff
williamhorning Dec 16, 2024
4eae73d
implement allow_everyone setting
williamhorning Dec 16, 2024
70f44d9
format code
williamhorning Dec 16, 2024
98ae09a
move folders around, make multiple database adapters
williamhorning Dec 22, 2024
e09c9eb
revolt fixes
williamhorning Dec 22, 2024
5512ead
updated documentation, explicit return types, string changes
williamhorning Dec 24, 2024
2b7f60c
remove leftover todos
williamhorning Dec 24, 2024
58b7b13
turns out the issue was fixed
williamhorning Dec 24, 2024
58ccb74
changes for jsr
williamhorning Dec 24, 2024
8d55722
use Deno 2.1.4
williamhorning Dec 24, 2024
1318d23
fix discord file size thing and formatting
williamhorning Dec 25, 2024
2ca1a18
implement redis migration logic
williamhorning Jan 1, 2025
c22c412
fix redis migration logic
williamhorning Jan 5, 2025
e772fab
some more changes
williamhorning Mar 2, 2025
7135552
some migration related fixes
williamhorning Mar 2, 2025
ed585b1
fix slash command arguments
williamhorning Mar 2, 2025
ff82b5c
fix many revolt issues and make logs consistent
williamhorning Mar 11, 2025
e8ce000
fix file size handling and clean up guilded attachments
williamhorning Mar 12, 2025
5337794
add quick little warning for mongodb
williamhorning Mar 12, 2025
426216d
clean up code, rename interfaces, remove extra licenses
williamhorning Mar 13, 2025
0b8ed6e
enable editing on database migration
williamhorning Mar 13, 2025
d71188d
remove user facing bolt references
williamhorning Mar 13, 2025
1d97540
typo
williamhorning Mar 13, 2025
58fc162
update mongo and remove some assertations
williamhorning Mar 13, 2025
b1ebbac
use guildapi (not yet published)
williamhorning Mar 30, 2025
591eaa0
aaaa bugs
williamhorning Mar 31, 2025
3f5ca2b
rewrite plugins and move toward 0.8.0-alpha.1 release
williamhorning Apr 7, 2025
a51c1fb
start to simplify the plugin api
williamhorning Apr 8, 2025
ba91acc
remove plugin log method
williamhorning Apr 10, 2025
fb0f9c7
remove mongodb, use toml config, and some other changes
williamhorning Apr 12, 2025
f262e59
overall cleanup and prep for 0.8.0
williamhorning Apr 13, 2025
30b02d5
sort imports, fix bridge error messages, make db migration command nicer
williamhorning Apr 18, 2025
25534b7
update dependencies
williamhorning Apr 18, 2025
565f19a
require id to leave bridges
williamhorning Apr 20, 2025
257657b
move to the lightning scope for jsr and the github repo
williamhorning Apr 20, 2025
19dd430
replace file proxy with oak. adds support for node and bun
williamhorning Apr 20, 2025
2c474ec
move to hopefully be cross-compatible
williamhorning Apr 20, 2025
9c72e01
improve node and bun compatibility.
williamhorning Apr 20, 2025
7b0cf70
0.8.0-alpha.1 release and improved node compatibility
williamhorning Apr 20, 2025
6284fc7
temporarily publish postgres
williamhorning Apr 20, 2025
be9a893
0.8.0-alpha.1
williamhorning Apr 20, 2025
d6f7548
fix github action
williamhorning Apr 20, 2025
6f9617c
fix jsr imports in docker
williamhorning Apr 20, 2025
c39c3f7
remove debug logging
williamhorning Apr 20, 2025
65a0364
actually set commands
williamhorning Apr 20, 2025
bc304af
refactor error handling and change revolt cdn endpoints
williamhorning Apr 27, 2025
f164d81
handle revolt disconnection
williamhorning Apr 27, 2025
9248115
format
williamhorning Apr 27, 2025
7f92248
bump version to 0.8.0-alpha.2
williamhorning Apr 27, 2025
ac02c72
redo error handling, centralize cacher, change schema handler, improv…
williamhorning May 17, 2025
ed8562b
add docs for cacher
williamhorning May 18, 2025
7fdcc2f
fix revolt permissions
williamhorning May 25, 2025
6569d2b
bump telegram version
williamhorning May 27, 2025
68faa71
handle emojis and mentions
williamhorning Jun 1, 2025
c88f74d
bump rvapi version
williamhorning Jun 2, 2025
cf7580f
bump to 0.8.0-alpha.4
williamhorning Jun 2, 2025
c87ba67
fix type errors
williamhorning Jun 2, 2025
6563e0f
bump rvapi version
williamhorning Jun 3, 2025
4f36dba
add telegram commands
williamhorning Jun 4, 2025
725444e
bump guildapi version
williamhorning Jun 4, 2025
633e916
add support for publishing and disabling read/write granularly
williamhorning Jun 5, 2025
e68a998
update dependencies and use ?? instead of ||
williamhorning Jun 5, 2025
a6ec9f9
bump to 0.8.0-alpha.5
williamhorning Jun 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 27 additions & 31 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,44 @@ on:
types: [published]

permissions:
contents: read
packages: write
id-token: write

jobs:
publish:
name: publish to jsr and ghcr
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # auth w/JSR
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2
with:
deno-version: v1.45.5
- name: setup qemu
deno-version: v2.3.5
- name: publish to jsr
run: deno publish
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: setup buildx
uses: docker/setup-buildx-action@v3
- name: login to docker hub
uses: docker/login-action@v3
- name: login to ghcr
uses: redhat-actions/podman-login@v1
with:
username: williamfromnj
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: go to the directory
run: cd packages/lightning
- name: publish to jsr
run: |
deno publish
cd packages/lightning
- name: setup docker metadata
id: metadata
uses: docker/metadata-action@v5
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: build image with podman
id: build-image
uses: redhat-actions/buildah-build@v2
with:
images: williamfromnj/bolt
tags: type=ref,event=tag
- name: build and push
uses: docker/build-push-action@v6
image: ghcr.io/williamhorning/lightning
archs: amd64, arm64
tags: latest ${{github.ref_name}}
containerfiles: ./containerfile
- name: push to ghcr.io
uses: redhat-actions/push-to-registry@v2
with:
context: .
file: ./packages/lightning/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io
username: ${{github.actor}}
password: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/.env
/config
/config.ts
/lightning.toml
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Jersey <wgyt735yt@gmail.com> William Horning <github@williamhorning.dev>
Jersey <wgyt735yt@gmail.com> William Horning <wgyt735yt@gmail.com>
22 changes: 22 additions & 0 deletions containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM denoland/deno:alpine-2.3.5

# make a deno cache directory
RUN ["mkdir", "/deno_dir"]
ENV DENO_DIR=/deno_dir

# install lightning
RUN ["deno", "install", "-gA", "--unstable-temporal", "--unstable-net", "jsr:@lightning/lightning@0.8.0-alpha.5"]
RUN ["chown", "--recursive", "1001:1001", "/deno_dir"]

# run as user instead of root
USER 1001:1001

# the volume containing your lightning.toml file
VOLUME [ "/data" ]
WORKDIR /data

# this is the lightning command line
ENTRYPOINT [ "lightning" ]

# run the bot using the user-provided lightning.toml file
CMD [ "run" ]
10 changes: 2 additions & 8 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
]
}
},
"workspace": [
"./packages/lightning",
"./packages/lightning-plugin-telegram",
"./packages/lightning-plugin-revolt",
"./packages/lightning-plugin-guilded",
"./packages/lightning-plugin-discord"
],
"workspace": ["./packages/*"],
"lock": false,
"unstable": ["temporal"]
"unstable": ["net", "temporal"]
}
28 changes: 28 additions & 0 deletions logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/discord/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @lightning/discord

[![JSR](https://jsr.io/badges/@lightning/discord)](https://jsr.io/@lightning/discord)

@lightning/discord adds support for Discord to Lightning. To use it, you'll
first need to create a Discord bot at the
[Discord Developer Portal](https://discord.com/developers/applications). After
you do that, you will need to add the following to your `lightning.toml` file:

```toml
[[plugins]]
plugin = "jsr:@lightning/discord@0.8.0-alpha.5"
config.token = "your_bot_token"
```
12 changes: 12 additions & 0 deletions packages/discord/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@lightning/discord",
"version": "0.8.0-alpha.5",
"license": "MIT",
"exports": "./src/mod.ts",
"imports": {
"@discordjs/core": "npm:@discordjs/core@^2.1.0",
"@discordjs/rest": "npm:@discordjs/rest@^2.5.0",
"@discordjs/ws": "npm:@discordjs/ws@^2.0.2",
"@lightning/lightning": "jsr:@lightning/lightning@0.8.0-alpha.5"
}
}
36 changes: 36 additions & 0 deletions packages/discord/src/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { API } from '@discordjs/core';
import type { command } from '@lightning/lightning';

export async function setup_commands(
api: API,
commands: command[],
): Promise<void> {
const format_arguments = (args: command['arguments']) =>
args?.map((arg) => ({
name: arg.name,
description: arg.description,
type: 3,
required: arg.required,
})) ?? [];

const format_subcommands = (subcommands: command['subcommands']) =>
subcommands?.map((subcommand) => ({
name: subcommand.name,
description: subcommand.description,
type: 1,
options: format_arguments(subcommand.arguments),
})) ?? [];

await api.applicationCommands.bulkOverwriteGlobalCommands(
(await api.applications.getCurrent()).id,
commands.map((cmd) => ({
name: cmd.name,
type: 1,
description: cmd.description,
options: [
...format_arguments(cmd.arguments),
...format_subcommands(cmd.subcommands),
],
})),
);
}
33 changes: 33 additions & 0 deletions packages/discord/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { DiscordAPIError } from '@discordjs/rest';
import { log_error } from '@lightning/lightning';

const errors = [
[30007, 'Too many webhooks in channel, try deleting some', false, true],
[30058, 'Too many webhooks in guild, try deleting some', false, true],
[50013, 'Missing permissions to make webhook', false, true],
[10003, 'Unknown channel, disabling channel', true, true],
[10015, 'Unknown message, disabling channel', false, true],
[50027, 'Invalid webhook token, disabling channel', false, true],
[0, 'Unknown DiscordAPIError, not disabling channel', false, false],
] as const;

export function handle_error(
err: unknown,
channel: string,
edit?: boolean,
) {
if (err instanceof DiscordAPIError) {
if (edit && err.code === 10008) return []; // message already deleted or non-existent

const extra = { channel, code: err.code };
const [, message, read, write] = errors.find((e) => e[0] === err.code) ??
errors[errors.length - 1];

log_error(err, { disable: { read, write }, message, extra });
} else {
log_error(err, {
message: `unknown discord error`,
extra: { channel },
});
}
}
Loading