From b2f088d4e12f375c565fb00b3daaae402b86d00e Mon Sep 17 00:00:00 2001 From: Waldo <099waldo@gmail.com> Date: Sat, 17 Jan 2026 16:20:12 -0700 Subject: [PATCH] Updated readme with insallation instructions --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d4ffe11..49ed6b6 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,63 @@ -# Go bot example +# Sox -This directory contains an example of a simple Campfire bot written in Go. +This directory contains an example of a simple Campfire bot named Sox written in Go. -This bot implments a single endpoint, `/trace`. You can message this endpoint -with a URL. The bot will make a `GET` request to that URL, and respond with some -timings about how long parts of that request took: DNS lookup, time to first -byte, and so on. +Commands: +- ping +- trace google.com +- math 32*9 The functionality of the bot is basic. But this example shows how you can: - Start an HTTP service to listen on a bot endpoint - Parse the JSON from the message request - Respond to that request with some HTML-formatted text + +## Installation +### Nixos + +Add this to flake.nix +```nix + inputs = { + sox.url = "git+https://gitea.rmtn.top/waldo/sox"; + } + outputs = { self, nixpkgs, sox, ...}: { + nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem { + specialArgs = { + inherit sox; + }; + }; + } +``` + +Add this to sox.nix and include it somewhere in your config + +```nix +{ pkgs, config, lib, cfg, sox, ... }: + +rec { + systemd.services."soxbotservice" = { + enable = true; + wants = [ "network-online.target" ]; + after = [ "syslog.target" "network-online.target" ]; + description = "Start Sox Campfire bot service"; + path = [ pkgs.libqalculate ]; + serviceConfig = { + Type = "simple"; + ExecStart = sox.packages.${pkgs.system}.sox + "/bin/sox"; + Restart = "always"; + RestartSec = 10; + KillMode = "process"; + }; + wantedBy = [ "multi-user.target" ]; # required or won't start automatically + }; +} +``` + +Point the Campfire bot webhook at your ip with port 8096 and everything should work. + +Ping the bot with @Sox or DM for a response. + +In group: @Sox ping +or in DM: ping +