npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

birchbot

v0.1.2

Published

An easy to use bot framrwork for [owncast]("https://owncast.online/")

Downloads

2

Readme

birchbot

An easy to use bot framrwork for owncast

env variables

| Variable | Default Value | |---------------------|---------------| | BIRCH_PORT | 8008 | | BIRCH_HOST | localhost | | BIRCH_CMD_DIR | commands | | BIRCH_HANDLER_DIR | handlers | | BIRCH_CMD_PREFIX | ! | | BIRCH_REMOTE | | | BIRCH_TOKEN | |

installation

docker compose (recommended)

Docker Compose is an easy way to orchestrate docker containers. There is an example compose file in this repo that you can adapt to you needs or use as is. The quickest way to get started is to clone this repo:

git clone https://codeberg.org/AnActualEmerald/birchbot.git

Then:

cd birchbot
docker-compose up

And BirchBot should be up an running! See the usage section below for ways to add commands and customize behavior.

manual

If you want you can also run BirchBot witout docker. The only prerequisite is that you have bun installed. Then clone the repo and run:

bun install --production

This will install any dependencies without all the types and stuff used for development. Then you can start the server with:

bun run src

usage

By default BirchBot doesn't do anything when it recieves a WebHook from owncast. Its job is to dispatch the WebHook payloads to user-defined handlers. There are two main ways to define behavior for BirchBot: chat commands and webhook handlers. The breakdown is like this:

| Event Type | Handler (.ts|.js|.cjs) | |------------------------|--------------------------| | CHAT | commands/* | | CHAT | handlers/chat | | NAME_CHANGED | handlers/nameChanged | | USER_JOINED | handlers/userJoined | | STREAM_STARTED | handlers/streamStart | | STREAM_STOPPED | handlers/streamStop | | STREAM_TITLE_UPDATED | handlers/streamTitle | | VISIBILITY-UPDATE | handlers/visibility |

Each file on the right should have a .ts, .js, or .cjs extension and must export a run function. That function should accept an argument that will be a Context<T> object, where the generic type is the value of Event Type in the table. The Context will contain the data from the webhook, as well as methods for sending API requests to the server.

chat commands

Handlers in the commands folder are treated somewhat differently. The name of the file will be the name of the command that it responds to. Command handlers also have a second argument passed to their run function which contains the rest of the text of the message in an array, split by spaces, excluding the name of the command itself. In order for an event to trigger a chat command the message must begin with the value of BIRCH_CMD_PREFIX, which defaults to !. The Context passed to a command handler also has some additional methods for replying to the user that invoked the command.

example handler

This is a very basic example that just logs out each chat message recieved

import type { Context } from "birchbot";
//handlers/chat.ts
export const run = async (ctx: Context<"CHAT">) => {
    console.log(ctx.event.user.displayName, "said", ctx.event.body, "at", ctx.event.timestamp);
}