bskybots
Create custom bots by configuration.
Install package in your project
npm i bskybot
Example config
Action Bot
import {
ActionBot,
CronBot,
KexwordBot
} from "bskybot";
const actionBot: ActionBot = {
identifier: "[did]",
password: "use app password!",
username: "[handle]", // optional for logging needed
service: "https://bsky.social", // or another
action: async (agent: AtpAgent) => {
// implement any logic you want here to be repeated at the scheduledExpression
const text = "implement logic to return a string";
console.info(new Date, `Post cronbot ${bot.identifier}: ${text}`)
agent.post({text});
}
}
const actionBotAgent = useActionBotAgent(actionBot);
Cron Bot
const cronBot: CronBot = {
identifier: "[did]",
password: "use app password!",
username: "[handle]", // optional for logging needed
service: "https://bsky.social", // or another
cronJob: {
scheduleExpression: "* * * * *", // a cron job expression
callback: null, // implement optional logic after the cronjob
timeZone: "Europe/Vienna"
},
action: async (agent: AtpAgent) => {
// implement any logic you want here to be executed in your project
const text = "implement logic to return a string";
console.info(new Date, `Post cronbot ${bot.identifier}: ${text}`)
agent.post({text});
}
}
const cronBotAgent = useCronBotAgent(cronBot);
Keyword Bot
const keywordBot: KeywordBot = {
identifier: "[did]",
password: "use app password!",
username: "[handle]", // optional for logging needed
service: "https://bsky.social", // or another
replies: [
{
keyword: "keyword1",
exclude: ["badword1", "badword2"],
messages: ["reply1", "reply2", "reply3"]
},
{
keyword: "keyword2",
messages: ["reply"]
},
]
}
const keywordBotAgent = useKeywordBotAgent(keywordBot);