diff --git a/README.md b/README.md index 243cab2..d76e1b7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # bsky-event-handlers - An easy package to use for making bluesky bots with validators and handler actions [![GitHub Actions Test Status](https://img.shields.io/github/actions/workflow/status/juni-b-queer/bsky-event-handlers/testandlint.yml?logo=github&label=Tests)](https://github.com/juni-b-queer/bsky-event-handlers/actions/workflows/testandlint.yml?query=branch%3Amain) @@ -14,23 +13,24 @@ An easy package to use for making bluesky bots with validators and handler actio Scaffold a new project with this package using: \ [![create-bsky-bot](https://img.shields.io/badge/create--bsky--bot-white.svg?logo=npm&color=blue)](https://www.npmjs.com/package/create-bsky-bot) + # Table of contents **There is a lot of work left to be done for likes, reskeets, and follows, but is mostly complete for handling new skeets** -- [Quickstart](#quickstart) -- [Overview](#overview) -- [Agent](./src/agent/README.md) -- [Validators](./src/validations/README.md) -- [Actions](./src/actions/README.md) -- [Handlers](./src/handlers/README.md) - - [Record Handlers](./src/handlers/README.md) - - [Pre-made Handlers](./src/handlers/premade-handlers/README.md) -- [Jetsteam Firehose Subscription](./src/firehose/README.md) -- [Utility Functions](./src/utils/README.md) -- [Jetstream Types](./src/types/README.md) -- [Credits](#credits) +- [Quickstart](#quickstart) +- [Overview](#overview) +- [Agent](./src/agent/README.md) +- [Validators](./src/validations/README.md) +- [Actions](./src/actions/README.md) +- [Handlers](./src/handlers/README.md) + - [Record Handlers](./src/handlers/README.md) + - [Pre-made Handlers](./src/handlers/premade-handlers/README.md) +- [Jetsteam Firehose Subscription](./src/firehose/README.md) +- [Utility Functions](./src/utils/README.md) +- [Jetstream Types](./src/types/README.md) +- [Credits](#credits) [npm Package](https://www.npmjs.com/package/bsky-event-handlers) @@ -61,9 +61,9 @@ Create your bsky agent and prepare your jetstreamSubscription variable ```typescript const testAgent = new HandlerAgent( - 'test-bot', - Bun.env.TEST_BSKY_HANDLE, - Bun.env.TEST_BSKY_PASSWORD + 'test-bot', + Bun.env.TEST_BSKY_HANDLE, + Bun.env.TEST_BSKY_PASSWORD ); let jetstreamSubscription: JetstreamSubscription; @@ -73,28 +73,28 @@ Initialize your handlers ```typescript const handlers: JetstreamSubscriptionHandlers = { - post: { - c: [ - new CreateSkeetHandler( - [new InputEqualsValidator('Hello')], - [new ReplyToSkeetAction('World!')], - testAgent - ), - ], - d: [], - }, - like: { - c: [], - d: [], - }, - follow: { - c: [], - d: [], - }, - repost: { - c: [], - d: [], - }, + post: { + c: [ + new CreateSkeetHandler( + [new InputEqualsValidator('Hello')], + [new ReplyToSkeetAction('World!')], + testAgent + ), + ], + d: [], + }, + like: { + c: [], + d: [], + }, + follow: { + c: [], + d: [], + }, + repost: { + c: [], + d: [], + }, }; ``` @@ -104,15 +104,15 @@ for our example, we'll only be acting upon post creations, so our handlers will ```typescript const handlers: JetstreamSubscriptionHandlers = { - post: { - c: [ - new CreateSkeetHandler( - [new InputEqualsValidator('Hello')], - [new ReplyToSkeetAction('World!')], - testAgent - ), - ], - }, + post: { + c: [ + new CreateSkeetHandler( + [new InputEqualsValidator('Hello')], + [new ReplyToSkeetAction('World!')], + testAgent + ), + ], + }, }; ``` @@ -123,13 +123,13 @@ Then in out `initialize` function, we authenticate the agent, and create the Jet ```typescript async function initialize() { - await testAgent.authenticate(); - DebugLog.info('INIT', 'Initialized!'); + await testAgent.authenticate(); + DebugLog.info('INIT', 'Initialized!'); - jetstreamSubscription = new JetstreamSubscription( - handlers, - Bun.env.JETSTREAM_URL - ); + jetstreamSubscription = new JetstreamSubscription( + handlers, + Bun.env.JETSTREAM_URL + ); } ``` @@ -137,7 +137,7 @@ Then finally, we call initialize, then start the subscription to listen for even ```typescript initialize().then(() => { - jetstreamSubscription.createSubscription(); + jetstreamSubscription.createSubscription(); }); ``` @@ -145,47 +145,47 @@ All together, a simple bot index.ts would look like ```typescript import { - HandlerAgent, - JetstreamSubscriptionHandlers, - JetstreamSubscription, - CreateSkeetHandler, - InputEqualsValidator, - ReplyToSkeetAction, - DebugLog, + HandlerAgent, + JetstreamSubscriptionHandlers, + JetstreamSubscription, + CreateSkeetHandler, + InputEqualsValidator, + ReplyToSkeetAction, + DebugLog, } from 'bsky-event-handlers'; const testAgent = new HandlerAgent( - 'test-bot', - Bun.env.TEST_BSKY_HANDLE, - Bun.env.TEST_BSKY_PASSWORD + 'test-bot', + Bun.env.TEST_BSKY_HANDLE, + Bun.env.TEST_BSKY_PASSWORD ); let jetstreamSubscription: JetstreamSubscription; const handlers: JetstreamSubscriptionHandlers = { - post: { - c: [ - new CreateSkeetHandler( - [new InputEqualsValidator('Hello')], - [new ReplyToSkeetAction('World!')], - testAgent - ), - ], - }, + post: { + c: [ + new CreateSkeetHandler( + [new InputEqualsValidator('Hello')], + [new ReplyToSkeetAction('World!')], + testAgent + ), + ], + }, }; async function initialize() { - await testAgent.authenticate(); - DebugLog.info('INIT', 'Initialized!'); + await testAgent.authenticate(); + DebugLog.info('INIT', 'Initialized!'); - jetstreamSubscription = new JetstreamSubscription( - handlers, - Bun.env.JETSTREAM_URL - ); + jetstreamSubscription = new JetstreamSubscription( + handlers, + Bun.env.JETSTREAM_URL + ); } initialize().then(() => { - jetstreamSubscription.createSubscription(); + jetstreamSubscription.createSubscription(); }); ``` @@ -224,13 +224,12 @@ your bot in response to defined triggers, enhancing your bot's interactivity, fl ## Packages/dependencies used -- [@atproto/api](https://www.npmjs.com/package/@atproto/api) -- [Jetstream](https://github.com/ericvolp12/jetstream) (Though I use - a [forked version](https://github.com/juni-b-queer/jetstream) to include the CID and build/publish the docker - container) - +- [@atproto/api](https://www.npmjs.com/package/@atproto/api) +- [Jetstream](https://github.com/ericvolp12/jetstream) (Though I use + a [forked version](https://github.com/juni-b-queer/jetstream) to include the CID and build/publish the docker + container) ## Contact me [![discord](https://img.shields.io/badge/junib33-7289da.svg?logo=discord)](#contact-me) -[![bsky](https://img.shields.io/badge/Juni!_on_Bluesky-5BCEFA.svg?logo=bluesky)](https://bsky.app/profile/did:plc:wpp4lklhvmopw6zcy6qb42ru) \ No newline at end of file +[![bsky](https://img.shields.io/badge/Juni!_on_Bluesky-5BCEFA.svg?logo=bluesky)](https://bsky.app/profile/did:plc:wpp4lklhvmopw6zcy6qb42ru) diff --git a/src/handlers/README.md b/src/handlers/README.md index e5750e9..786db5a 100644 --- a/src/handlers/README.md +++ b/src/handlers/README.md @@ -57,4 +57,3 @@ CreateSkeetHandler.make( handlerAgent ); ``` -