blob: e768bf9cf6a5e9f1c1ae9ecae445f959916a1d7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# slopbot
Zulip bot for [meshheads.org](https://zulip.meshheads.org) that replies with stock prices when it sees `$TICKER` patterns and calls `agent` for `@slop` mentions.
## Usage
Post `$NVDA` or `$AAPL is mooning` in any stream and slopbot replies with the current price. Mention `@slop` and it runs a one-shot `agent` subprocess with recent Zulip topic history.
## Setup
```bash
pip install -r requirements.txt
cp .zuliprc.example .zuliprc
cp .env.example .env
# edit .zuliprc with your bot credentials
# edit .env with agent/provider settings if needed
python main.py
```
Run tests:
```bash
./test.sh
```
Install the pre-commit hook:
```bash
./scripts/install-git-hooks.sh
```
Deploy as a user-level systemd service:
```bash
./deploy.sh
journalctl --user -u slopbot -f
```
To keep the user service running after logout, run once:
```bash
sudo loginctl enable-linger $USER
```
Get your `.zuliprc` from Zulip: Settings → Bots → your bot → download config.
## Architecture
- `main.py` — single-file bot, raw `zulip` event loop (no framework)
- `fetch_price(ticker)` — isolated data layer, easy to swap yfinance for a real API
- `ask_agent(msg, content)` — runs the Rust `agent` binary once per mention
- `prompts/system.md` — bot persona, research workflow, and response behavior
- `slop-search QUERY` — Kagi search helper available to the agent shell
- `slop-fetch URL` — trafilatura page extraction helper available to the agent shell
- `.env.example` — operational defaults, including `KAGI_API_KEY`
- Regex: `\$([A-Z]{1,5})` — matches 1-5 uppercase letters after `$`
- Deduplicates tickers per message, replies in-place (same stream + topic)
- `flake.nix` — packages slopbot with `agent` from `github:bsima/agentd` as a Nix input
- `SLOPBOT_DIR` — working directory the packaged `slopbot` runs from (default `/home/ben/src/bsima/slopbot`)
## Extending
Future ideas:
- Swap `fetch_price` for Finnhub/Polygon for real-time data
- Add LLM commentary on price moves
- Support crypto tickers
- Add `@slopbot summarize $NVDA` command style
|