Skip to content
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

redo a lot of the structure of core #58

Merged
merged 13 commits into from
Mar 26, 2024
1 change: 0 additions & 1 deletion .github/security.md

This file was deleted.

30 changes: 23 additions & 7 deletions .github/workflows/docker.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,45 @@ permissions:
packages: write

jobs:
build:
jsr:
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
with:
deno-version: v1.41.3
- name: publish to jsr
run: |
cd packages/lightning
deno publish
docker:
runs-on: ubuntu-latest
steps:
# Get the repository's code
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
- name: set up buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: williamfromnj
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
- name: metadata
id: yo
uses: docker/metadata-action@v3
with:
images: williamfromnj/bolt
tags: type=ref,event=tag
- name: Build and push
- name: build and push
uses: docker/build-push-action@v2
with:
context: .
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.example.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'

services:
bolt:
lightning:
build: .
volumes:
- ./config/data:/app/data
Expand Down
15 changes: 8 additions & 7 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
ARG DENO_VERSION=v1.40.4
ARG DENO_VERSION=v1.41.3

FROM docker.io/lukechannings/deno:${DENO_VERSION}
FROM docker.io/denoland/deno:${DENO_VERSION}

# add bolt to the image
# add lightning to the image
WORKDIR /app
ADD ./packages/bolt /app
RUN deno install -A --unstable-temporal -n bolt /app/cli.ts
# TODO: change when repos split
ADD ./packages/lightning /app
RUN deno install -A --unstable-temporal -n lightning /app/cli.ts

# set bolt as the entrypoint and use the run command by default
ENTRYPOINT [ "bolt" ]
# set lightning as the entrypoint and use the run command by default
ENTRYPOINT [ "lightning" ]
CMD [ "--run", "--config", "./data/config.ts"]
6 changes: 3 additions & 3 deletions packages/bolt-discord/_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export {
export { REST as rest, type RawFile } from 'npm:@discordjs/[email protected]';
export { WebSocketManager as socket } from 'npm:@discordjs/[email protected]';
export {
Bolt,
bolt_plugin,
lightning,
plugin,
type bridge_platform,
type deleted_message,
type message
} from '../bolt/mod.ts';
} from '../lightning/mod.ts';
10 changes: 5 additions & 5 deletions packages/bolt-discord/commands.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { API, Bolt, cmd_body } from './_deps.ts';
import { API, lightning, cmd_body } from './_deps.ts';
import { discord_config } from './mod.ts';

export async function register_commands(
config: discord_config,
api: API,
bolt: Bolt
l: lightning
) {
if (!config.slash_cmds) return;

const data: cmd_body = [...bolt.cmds.values()].map(command => {
const data: cmd_body = [...l.cmds.values()].map(command => {
const opts = [];

if (command.options?.argument_name) {
Expand All @@ -35,7 +35,7 @@ export async function register_commands(
type: 3,
required: i.options.argument_required || false
}
]
]
: undefined
};
})
Expand All @@ -45,7 +45,7 @@ export async function register_commands(
return {
name: command.name,
type: 1,
description: command.description || 'a bolt command',
description: command.description || 'a command',
options: opts
};
});
Expand Down
14 changes: 7 additions & 7 deletions packages/bolt-discord/mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Bolt,
lightning,
Client,
bolt_plugin,
plugin,
bridge_platform,
deleted_message,
message,
Expand All @@ -18,14 +18,14 @@ export type discord_config = {
slash_cmds?: boolean;
};

export class discord_plugin extends bolt_plugin<discord_config> {
export class discord_plugin extends plugin<discord_config> {
bot: Client;
name = 'bolt-discord';
version = '0.5.8';
version = '0.6.0';
support = ['0.5.5'];

constructor(bolt: Bolt, config: discord_config) {
super(bolt, config);
constructor(l: lightning, config: discord_config) {
super(l, config);
this.config = config;
const rest_client = new rest({ version: '10' }).setToken(config.token);
const gateway = new socket({
Expand All @@ -35,7 +35,7 @@ export class discord_plugin extends bolt_plugin<discord_config> {
});
this.bot = new Client({ rest: rest_client, gateway });
register_events(this);
register_commands(this.config, this.bot.api, bolt);
register_commands(this.config, this.bot.api, l);
gateway.connect();
}

Expand Down
6 changes: 3 additions & 3 deletions packages/bolt-guilded/_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export {
type WebhookPayload
} from 'npm:[email protected]';
export {
Bolt,
bolt_plugin,
lightning,
plugin,
create_message,
type bridge_platform,
type deleted_message,
type embed,
type message
} from '../bolt/mod.ts';
} from '../lightning/mod.ts';
18 changes: 10 additions & 8 deletions packages/bolt-guilded/legacybridging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@ export async function bridge_legacy(
await guilded.bot.messages.send(
senddata,
toguildedid(
create_message({
text: `In the next major version of Bolt, embed-based bridges like this one won't be supported anymore.
See https://github.com/williamhorning/bolt/issues/36 for more information.`
})
create_message(
`In the next major version of bolt-guilded, embed-based bridges like this one won't be supported anymore.
See https://github.com/williamhorning/bolt/issues/36 for more information.`
)
)
);
}
}
}

async function migrate_bridge(channel: string, guilded: guilded_plugin) {
if (!guilded.bolt.db.redis.get(`guilded-embed-migration-${channel}`)) {
await guilded.bolt.db.redis.set(
if (!guilded.lightning.redis.get(`guilded-embed-migration-${channel}`)) {
await guilded.lightning.redis.set(
`guilded-embed-migration-${channel}`,
'true'
);
const current = await guilded.bolt.bridge.get_bridge({ channel: channel });
const current = await guilded.lightning.bridge.get_bridge({
channel: channel
});
if (current) {
current.platforms[
current.platforms.findIndex(i => i.channel === channel)
Expand All @@ -50,7 +52,7 @@ async function migrate_bridge(channel: string, guilded: guilded_plugin) {
plugin: 'bolt-guilded',
senddata: await guilded.create_bridge(channel)
};
await guilded.bolt.bridge.update_bridge(current);
await guilded.lightning.bridge.update_bridge(current);
}
}
}
17 changes: 9 additions & 8 deletions packages/bolt-guilded/mod.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
Bolt,
lightning,
Client,
WebhookPayload,
WebhookClient,
bolt_plugin,
plugin,
bridge_platform,
deleted_message,
message
} from './_deps.ts';
import { bridge_legacy } from './legacybridging.ts';
import { tocore, toguilded } from './messages.ts';

export class guilded_plugin extends bolt_plugin<{ token: string }> {
export class guilded_plugin extends plugin<{ token: string }> {
bot: Client;
name = 'bolt-guilded';
version = '0.5.8';
version = '0.6.0';
support = ['0.5.5'];

constructor(bolt: Bolt, config: { token: string }) {
super(bolt, config);
constructor(l: lightning, config: { token: string }) {
super(l, config);
this.bot = new Client(config);
this.bot.on('ready', () => {
this.emit('ready');
Expand Down Expand Up @@ -61,7 +61,8 @@ export class guilded_plugin extends bolt_plugin<{ token: string }> {
});
const srvhooks = (await srvwhs.json()).webhooks;
const found_wh = srvhooks.find((wh: WebhookPayload) => {
if (wh.name === 'Bolt Bridges' && wh.channelId === channel) return true;
if (wh.name === 'Lightning Bridges' && wh.channelId === channel)
return true;
return false;
});
if (found_wh && found_wh.token)
Expand All @@ -75,7 +76,7 @@ export class guilded_plugin extends bolt_plugin<{ token: string }> {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Bolt Bridges',
name: 'Lightning Bridges',
channelId: channel
})
}
Expand Down
6 changes: 3 additions & 3 deletions packages/bolt-revolt/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export {
UserSystemMessage
} from 'npm:@williamhorning/[email protected]';
export {
Bolt,
bolt_plugin,
lightning,
plugin,
type bridge_platform,
type message
} from '../bolt/mod.ts';
} from '../lightning/mod.ts';
12 changes: 6 additions & 6 deletions packages/bolt-revolt/mod.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {
Bolt,
lightning,
Client,
Message,
bolt_plugin,
plugin,
bridge_platform,
message
} from './deps.ts';
import { tocore, torevolt } from './messages.ts';

export class revolt_plugin extends bolt_plugin<{ token: string }> {
export class revolt_plugin extends plugin<{ token: string }> {
bot: Client;
name = 'bolt-revolt';
version = '0.5.8';
version = '0.6.0';
support = ['0.5.5'];

constructor(bolt: Bolt, config: { token: string }) {
super(bolt, config);
constructor(l: lightning, config: { token: string }) {
super(l, config);
this.bot = new Client();
this.bot.on('messageCreate', message => {
if (message.systemMessage) return;
Expand Down
9 changes: 0 additions & 9 deletions packages/bolt/_deps.ts

This file was deleted.

Loading