summary refs log tree commit diff
path: root/src/our.md
blob: 415202af74695f05d5b2f7178cac19d89bb21012 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
---
title: /town/our, a tildebrained irc bot
date: 2023-07-23
---

tl;dr: `<our>` is an IRC bot on tilde.town. Commands are just executables in a
world-writeable directory. If you're on town, you can create new commands just
by putting a script in `/town/our`.

Lowering the barrier to entry by so much gave us a pretty nice bot ecosystem,
and has just proven to overall be a bunch of fun.

## genesis
```
2022-04-19:
18:56 <dzwdz> i like the idea of having every command be a separate binary
18:59 <opfez> it does make for rather composable programs (in some cases)
18:59 <opfez> netcat is neat
18:59 <dzwdz> i meant in a [irc] bot
18:59 <dzwdz> you could create new commands very quickly
[...]
19:01 <dzwdz> wait do we have bwrap on here
19:01 <dzwdz> idea: a bot which works like this
19:01 <dzwdz> where the command directory is public
19:01 <dzwdz> so anyone could drop a script there to create a new command
19:01 <opfez> sounds pretty cool
19:01 <opfez> very pubnixy
19:03 <opfez> every command gets run with arguments specifying the user that called the command and (if necessary), additional arguments to the command
```
Basically, at the time I've been thinking about making an `sh(1)` bot framework
which would store each command in a separate script. But, I've realized:

1. if the commands are in separate scripts, they could as well just be arbitrary executables
2. the command directory could be world-writeable

I grabbed a basic Ruby bot framework I've made the other day, and quickly
prototyped  [jsbot](https://drewdevault.com/2021/03/29/The-worlds-dumbest-IRC-bot.html)'s
weird cousin.

```
19:49 --> our (beep boop) (dzwdz@localhost) has joined #tildetown
19:49 <dzwdz> our/greet
19:49 <our> hi dzwdz!dzwdz@localhost from #tildetown
19:49 <opfez> \o/
19:49 <dzwdz> /home/dzwdz/code/town/our/cmds
19:49 <dzwdz> world writeable
19:49 <dzwdz> have fun
19:50 <@vilmibm> whee
```

Others soon started playing with it. [~vilmibm](https://tilde.town/~vilmibm)
immediately made some commands in Go, for example.

```
19:56 <elly> our/../../../../../../../bin/ls
19:56 <elly> hm! definitely thought that would work :P
[...]
19:56 <dzwdz> first off
19:56 <dzwdz> how dare you assume i'm such a bad programmer
19:56 <dzwdz> second off
19:56 <dzwdz> our/../../../bin/echo lol
19:56 <our> dzwdz!dzwdz@localhost lol #tildetown

20:13 <@vilmibm> dzwdz: i linked /home/dzwdz/code/town/our/cmds to /town/our
```

## another (kind) bot

After making the proof of concept bot, I just left it running with no other changes.
If it ain't broke, don't fix it.

Except it was broke and I wasn't fixing it. Thus, [~kindrobot](https://tilde.town/~kindrobot)
took over.

```
2022-08-24:
04:01 <kindrobot> our/timefor dzwdz
04:01 <our> Wed, 24 Aug 2022 06:01:15 +0200
04:14 <kindrobot> dzwdz: (when you wake up) for your consideration: I added forking, a persistence data dir, and limited configuration to our. You can check it out in #bots
04:15 <kindrobot> You can use "your/..." followed by "your/town" (or any other command) to test forking
04:15 <kindrobot> You can use "your/count" to test persistence.
```

<br>

...then `our` got her a job at Wikimedia.

```
2022-10-13:
19:59 <kindrobot> When I was interviewed at Wikimedia, I talked about the "our" project that I've contributed a bit to. It seemed like the most relevant to what they were doing which is user defined functions for Wikipedia.
19:59 <dzwdz> i can't believe i got the job at wikipedia
19:59 <kindrobot> Yeah good job dzwdz :)
```

## sample commands
Look, our is just like any other IRC bot, and the commands people have made are
about what you'd expect.
Some are just typical utility commands:
```
<dzwdz> our/timefor dzwdz
<our> Sun, 23 Jul 2023 18:47:44 +0200
<dzwdz> our/w Kraków
<our> Cracow, , Poland | Sunny 28°C (82°F) (feels 29°C (84°F)) | 33% humidity | 1012 hPa
```

Some are fortune-style commands.
```
<dzwdz> our/qotd
<our> 00:50:58 <daisy> "i like to practise my bakery baking bakery in the bakery"
<dzwdz> our/plan9/fortune
<our> Did you know ... that no-one ever reads these things?
```

Some play well-known sports.
```
<our> your/ping 
<your> our/pong 
<our> your/ping 
<your> our/pong 
<our> your/ping 
<your> our/pong 
<our> your/ping 
<your> our/pong 
```

The one I personally use the most, though, is `our/sh`. It's handy both to
explain \*nix stuff live, and to just do all sorts of ad-hoc stuff.

```
2023-07-23:
[...] [someone was learning about /dev/shm and tmpfs]
<dzwdz> /dev/shm IS tmpfs
<dzwdz> our/sh grep /dev/shm /proc/mounts
<our> tmpfs /dev/shm tmpfs ro,nosuid,nodev,inode64 0 0

2023-07-24:
<dzwdz> i'm going to try to write a small article about our
<dzwdz> how bad of a title is "/town/our, a tildebrained irc bot"
<dzwdz> also does anyone have #tildetown logs from around 1650394568
<dzwdz> our/sh date -d @1650394568
<our> Tue Apr 19 18:56:08 UTC 2022
<dzwdz> login, maybe?
[~login did turn out to have the logs. thanks for sending them over <3]
```

## "sandboxes are for little children with tonka trucks"

```
2022-04-20:
14:37 <nihilazo> our/sh rm *
14:37 <dzwdz> nico what the fuck
```

First off---don't get the wrong idea here. This wasn't malicious.
[~nihilazo](https://itwont.work) was just messing around, knowing that I
implemented sandboxing.
(also, note that this happened not even 24 hours after the bot went live)

But yeah, it's safely sandboxed using [bubblewrap](https://github.com/containers/bubblewrap).
The entire filesystem is remounted ro, except a single directory for persistent
data, a fresh `/tmp/`, and a fresh devtmpfs (for `/dev/null`).
The uid is also spoofed to 0, but that's just for shits and giggles.

That being said, the IRC is only accessible internally, so if you can send `our`
commands, you can also just run the commands yourself. Everything's logged, too.

## where's the source
If you must, the source's at [git.tilde.town](https://git.tilde.town/kindrobot/our).
Note that:

* I believe that version is outdated
* the `cmds/` directory in the repo only includes a small subset of **old** commands
* it's still, at its core, a hastily thrown together proof-of-concept