洪 民憙 (Hong Minhee)'s avatar
洪 民憙 (Hong Minhee)

@[email protected]

I'm currently brainstorming a framework for creating fediverse bots called , based on . It's less flexible than Fedify, but the goal is to make it possible to create simple fediverse bots with much less code. What do you think?

import { createBot, mention, text } from "@fedify/botkit";
import { RedisKvStore } from "@fedify/redis";
import { Redis } from "ioredis";

// Create a bot instance:
const bot = createBot({
  // The bot will have fediverse handle "@greetbot@mydomain":
  username: "greetbot",
  // Set the profile icon (avatar):
  icon: new URL("https://mydomain/icon.png"),
  // Set the bio:
  bio: text`Hi, there! I'm a simple fediverse bot created by ${
    mention("@hongminhee@hollo.social").}`,
  // Use Redis as a key-value store:
  kv: new RedisKvStore(new Redis()),
  // Use Redis as a message queue:
  queue: new RedisMessageQueue(() => new Redis()),
});

// A bot can respond to a mention:
bot.on(/hi|hello|what'?s\s+up/i, (ctx) => {
  return ctx.reply(text`Hi, ${ctx.actor}!`);
});

// Or, a bot also can actively publish a post:
setInterval(async () => {
  await bot.publish(text`Hi, forks! It's an hourly greeting.`);
}, 1000 * 60 * 60);

export default bot;
import { createBot, mention, text } from "@fedify/botkit"; import { RedisKvStore } from "@fedify/redis"; import { Redis } from "ioredis"; // Create a bot instance: const bot = createBot({ // The bot will have fediverse handle "@greetbot@mydomain": username: "greetbot", // Set the profile icon (avatar): icon: new URL("https://mydomain/icon.png"), // Set the bio: bio: text`Hi, there! I'm a simple fediverse bot created by ${ mention("@[email protected]").}`, // Use Redis as a key-value store: kv: new RedisKvStore(new Redis()), // Use Redis as a message queue: queue: new RedisMessageQueue(() => new Redis()), }); // A bot can respond to a mention: bot.on(/hi|hello|what'?s\s+up/i, (ctx) => { return ctx.reply(text`Hi, ${ctx.actor}!`); }); // Or, a bot also can actively publish a post: setInterval(async () => { await bot.publish(text`Hi, forks! It's an hourly greeting.`); }, 1000 * 60 * 60); export default bot;
RGOU's avatar
RGOU

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee

That looks amazing.

It's ok to be somewhat opinionated with smart defaults, IMHO.

dansup the creator's avatar
dansup the creator

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee this is amazing!!

Russell 🏴󠁧󠁢󠁳󠁣󠁴󠁿's avatar
Russell 🏴󠁧󠁢󠁳󠁣󠁴󠁿

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee

Why create bots?

Elena Rossini ⁂'s avatar
Elena Rossini ⁂

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee this is awesome! CC’ing here @stefan - I think you’d find this interesting ✨

Quincy's avatar
Quincy

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee This looks like something that I would like to use. Very nice 😃

ポット🫖's avatar
ポット🫖

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

A stand-alone AP bot framework might be a great niche that is underserved. I think many Mastodon instances (understandably) aren't enthusiastic about accepting bot accounts.

botwiki.org's avatar
botwiki.org

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee Very cool!

Just a heads-up though about a somewhat similar (but recently discontinued?) project with the same name.

github.com/howdyai/botkit

洪 民憙 (Hong Minhee)'s avatar
洪 民憙 (Hong Minhee)

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

Fedify 基盤(기반)의 BotKit이라는 이름의 聯合宇宙(연합우주)(fediverse) 봇을 만드는 프레임워크를 브레인스토밍해보고 있어요. Fedify보다 柔軟性(유연성)은 떨어질테지만, 그래도 훨씬 짧은 코드로 簡單(간단)聯合宇宙(연합우주) 봇을 만들 수 있게 하는 게 目標(목표)입니다. 어떻게들 보시나요?

import { createBot, mention, text } from "@fedify/botkit";
import { RedisKvStore } from "@fedify/redis";
import { Redis } from "ioredis";

// Create a bot instance:
const bot = createBot({
  // The bot will have fediverse handle "@greetbot@mydomain":
  username: "greetbot",
  // Set the profile icon (avatar):
  icon: new URL("https://mydomain/icon.png"),
  // Set the bio:
  bio: text`Hi, there! I'm a simple fediverse bot created by ${
    mention("@hongminhee@hollo.social").}`,
  // Use Redis as a key-value store:
  kv: new RedisKvStore(new Redis()),
  // Use Redis as a message queue:
  queue: new RedisMessageQueue(() => new Redis()),
});

// A bot can respond to a mention:
bot.on(/hi|hello|what'?s\s+up/i, (ctx) => {
  return ctx.reply(text`Hi, ${ctx.actor}!`);
});

// Or, a bot also can actively publish a post:
setInterval(async () => {
  await bot.publish(text`Hi, forks! It's an hourly greeting.`);
}, 1000 * 60 * 60);

export default bot;
import { createBot, mention, text } from "@fedify/botkit"; import { RedisKvStore } from "@fedify/redis"; import { Redis } from "ioredis"; // Create a bot instance: const bot = createBot({ // The bot will have fediverse handle "@greetbot@mydomain": username: "greetbot", // Set the profile icon (avatar): icon: new URL("https://mydomain/icon.png"), // Set the bio: bio: text`Hi, there! I'm a simple fediverse bot created by ${ mention("@[email protected]").}`, // Use Redis as a key-value store: kv: new RedisKvStore(new Redis()), // Use Redis as a message queue: queue: new RedisMessageQueue(() => new Redis()), }); // A bot can respond to a mention: bot.on(/hi|hello|what'?s\s+up/i, (ctx) => { return ctx.reply(text`Hi, ${ctx.actor}!`); }); // Or, a bot also can actively publish a post: setInterval(async () => { await bot.publish(text`Hi, forks! It's an hourly greeting.`); }, 1000 * 60 * 60); export default bot;
Scammo's avatar
Scammo

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee I really would if something like this would exist.
Also starting with an opinated version is fine, especially in the beginning:)
Thx for your work!!

洪 民憙 (Hong Minhee)'s avatar
洪 民憙 (Hong Minhee)

@[email protected] · Reply to 洪 民憙 (Hong Minhee)'s post

Considering whether to make Deno-only or support Node.js and Bun as well. Making it Deno-only would simplify a lot of things, but … 🤔