Updated readme with insallation instructions
This commit is contained in:
parent
49c0793ba7
commit
b2f088d4e1
61
README.md
61
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
|
Commands:
|
||||||
with a URL. The bot will make a `GET` request to that URL, and respond with some
|
- ping
|
||||||
timings about how long parts of that request took: DNS lookup, time to first
|
- trace google.com
|
||||||
byte, and so on.
|
- math 32*9
|
||||||
|
|
||||||
The functionality of the bot is basic. But this example shows how you can:
|
The functionality of the bot is basic. But this example shows how you can:
|
||||||
|
|
||||||
- Start an HTTP service to listen on a bot endpoint
|
- Start an HTTP service to listen on a bot endpoint
|
||||||
- Parse the JSON from the message request
|
- Parse the JSON from the message request
|
||||||
- Respond to that request with some HTML-formatted text
|
- 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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user