juni-b-queer / bsky-event-handlers

Typescript based framework for building Bluesky bots. Designed to be easily extendable, this bot framework can be used to make almost any bot you could want.
13 stars 0 forks source link

Optional Database and Feed Add-Ons for bsky-event-handlers #46

Open juni-b-queer opened 1 month ago

juni-b-queer commented 1 month ago

Many custom feeds consume the firehose and populate a database, it would be extremely helpful if I could add database Validators and Actions in order to use saved data for validations, as well as save data in Actions.

class MessageExistsInDatabaseValidator extends AbstractValidator {

   constructor(dbConnection, dbModelOrTable, validatorAction?){
      // verify dbConnection and table
   }

   handle(message: JetstreamMessage, handlerAgent: HanderAgent){
      // validate message exists in db
   }
}

class InsertMessageIntoDatabaseAction extends AbstractMessageAction {

   constructor(dbConnection, dbModelOrTable, optionalFormattingAction){
      // verify dbConnection and table
   }

   handle(message: JetstreamMessage, handlerAgent: HanderAgent){
      let modelToInsert;
      if(formattingAction){
         modelToInsert = this.optionalFormattingAction(message);
      }

      // insert model into database
   }
}

This will be easier for making feed database entries since theyll all be pretty much the same, but may be more complicated for database tables with unique columns. But maybe it'll just need to be a bunch of new validators and actions