Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
williamhorning committed May 5, 2024
1 parent 658c0e7 commit 1fa7d08
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
21 changes: 21 additions & 0 deletions packages/lightning/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @jersey/lightning

lightning is a Typescript-based chatbot that supports bridging multiple chat platforms via plugins.

## [docs](https://williamhorning.dev/bolt)
## example config

```ts
import { define_config } from "jsr:@jersey/lightning@0.7.0";
import { discord_plugin } from "https://williamhorning.dev/bolt/x/bolt-discord/0.7.0/mod.ts";

export default define_config({
redis_host: "localhost",
redis_port: 6379,
plugins: [
discord_plugin.new({
// ...
}),
],
});
```
4 changes: 2 additions & 2 deletions packages/lightning/mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @module
* Lightning is a Typescript-based chatbot that supports
* lightning is a typescript-based chatbot that supports
* bridging multiple chat platforms via plugins.
* @module
*/

export { bridges } from './src/bridges/mod.ts';
Expand Down
25 changes: 20 additions & 5 deletions packages/lightning/src/bridges/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class bridges {
l.commands.set('bridge', bridge_commands(l));
}

/** get all the platforms a message was bridged to */
/**
* get all the platforms a message was bridged to
* @param id the id of the message to get the platforms for
*/
async get_bridge_message(id: string): Promise<bridge_document | undefined> {
const rdata = await this.l.redis.sendCommand([
'GET',
Expand All @@ -39,7 +42,10 @@ export class bridges {
return JSON.parse(rdata as string) as bridge_document;
}

/** check if a message was bridged */
/**
* check if a message was bridged
* @param id the id of the message to check
*/
async is_bridged(id: string): Promise<boolean> {
return Boolean(
Number(
Expand All @@ -48,7 +54,10 @@ export class bridges {
);
}

/** check if a channel is in a bridge */
/**
* check if a channel is in a bridge
* @param channel the channel to check
*/
async is_in_bridge(channel: string): Promise<boolean> {
return Boolean(
Number(
Expand All @@ -60,7 +69,10 @@ export class bridges {
);
}

/** get a bridge using the bridges name or a channel in it */
/**
* get a bridge using the bridges name or a channel in it
* @param param0 the id or channel of the bridge
*/
async get_bridge({
id,
channel
Expand All @@ -76,7 +88,10 @@ export class bridges {
);
}

/** update a bridge in a database */
/**
* update a bridge in a database
* @param bridge the bridge to update
*/
async set_bridge(bridge: bridge_document): Promise<void> {
await this.l.redis.sendCommand([
'SET',
Expand Down
5 changes: 4 additions & 1 deletion packages/lightning/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import type {
} from './types.ts';

/**
* a plugin for lightning
* lightning plugins are used to add support for new platforms to lightning
* @module
*/

/** a plugin for lightning */
export abstract class plugin<cfg> extends EventEmitter<plugin_events> {
/** access the instance of lightning you're connected to */
lightning: lightning;
Expand Down
5 changes: 5 additions & 0 deletions packages/lightning/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { lightning } from './lightning.ts';
import type { plugin } from './plugins.ts';

/**
* types used by lightning
* @module
*/

/** attachments within a message */
export interface attachment {
/** alt text for images */
Expand Down
7 changes: 6 additions & 1 deletion packages/lightning/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { fivesevenredis } from './migrations.ts';
import type { config, err, message, migration, versions } from './types.ts';

/**
* utilities used by lightning
* @module
*/

/**
* apply many migrations given data
* @param migrations the migrations to apply
Expand Down Expand Up @@ -88,7 +93,7 @@ export async function log_error(
).text();
}

console.error(`%cLightning Error ${uuid}`, 'color: red');
console.error(`%clightning error ${uuid}`, 'color: red');
console.error(e, extra);

const message = create_message(
Expand Down

0 comments on commit 1fa7d08

Please sign in to comment.