|
| 1 | +# Amygdala |
| 2 | + |
| 3 | +Computer asisted brain stem. |
| 4 | + |
| 5 | +This project is comprised of a handful of tools that allow me to automate common |
| 6 | +tasks. The main tool (`amygdala`) is currently deployed to Heroku, but it could |
| 7 | +be deployed anywhere. This isn't written to run for more than one user or to |
| 8 | +meet any needs but my own. It receives input from Twilio so I can just text the |
| 9 | +thing and get either a response or have it do what I asked. |
| 10 | + |
| 11 | +## Commands |
| 12 | + |
| 13 | +### cmd |
| 14 | + |
| 15 | +Explains all the commands online. |
| 16 | + |
| 17 | +### todo |
| 18 | + |
| 19 | +This is the most generically useful of the tools. Any string that doesn't match |
| 20 | +anything else is assumed to be a todo. Simply creates a document tagged `inbox` |
| 21 | +in my Dropbox. Any attachment included in the message is linked to; if the |
| 22 | +attachment is an image it is linked to with an `img` tag. |
| 23 | + |
| 24 | +### `defer til` |
| 25 | + |
| 26 | +A command matching the following general pattern "defer til 2019-01-01" or |
| 27 | +"defer some message til 2019-01-01" will enqueue messages to be |
| 28 | +[undefered](https://github.com/frioux/leatherman#undefer) later. |
| 29 | + |
| 30 | +### `inspire me` |
| 31 | + |
| 32 | +The string `inspire me` will repy with [a random inspirational |
| 33 | +link](https://frioux.github.io/notes/posts/inspiration/). |
| 34 | + |
| 35 | +### `remind me` |
| 36 | + |
| 37 | +Remind me commands are created with an sms to amygdala of the form: |
| 38 | + |
| 39 | + * remind me to power name at 3pm |
| 40 | + * remind me to wake up at 3:05pm |
| 41 | + * remind me to make dinner in 1h |
| 42 | + * remind me to get dessert in 1h30m |
| 43 | + |
| 44 | +Files are created in a directory in Dropbox and are the acted upon by |
| 45 | +`enqueue-at` |
| 46 | + |
| 47 | +## Configuration |
| 48 | + |
| 49 | +All configuration is done via environment variables. |
| 50 | + |
| 51 | +### `DROPBOX_ACCESS_TOKEN` |
| 52 | + |
| 53 | +Used by `amygdala` to access Dropbox. |
| 54 | + |
| 55 | +### `MY_CELL` |
| 56 | + |
| 57 | +Used by `amygdala` to limit access to my own phone. |
| 58 | + |
| 59 | +### Pushover |
| 60 | + |
| 61 | +All of these are used by `wuphf` to send notifications to my phone: |
| 62 | + |
| 63 | + * `PUSHOVER_TOKEN` |
| 64 | + * `PUSHOVER_USER` |
| 65 | + * `PUSHOVER_DEVICE` |
| 66 | + |
| 67 | +### `TWILIO_AUTH_TOKEN` |
| 68 | + |
| 69 | +Used by `amygdala` to validate that requests actually came from Twilio. |
| 70 | + |
| 71 | +### `TWILIO_URL` |
| 72 | + |
| 73 | +Also used by `amygdala` to validate that requests actually came from Twilio. In |
| 74 | +theory this could be inferred from the request, but due to http proxies it must |
| 75 | +be configured instead. |
| 76 | + |
| 77 | +## Design |
| 78 | + |
| 79 | +As mentioned before, this project is a few distinct tools. Simplicity is a |
| 80 | +priority for all of them, but I've tried to keep things relatively neat. |
| 81 | + |
| 82 | +### `amygdala` |
| 83 | + |
| 84 | +The top level tool, which initiates all the other stuff, is currently organized |
| 85 | +around my personal notes system, which is not yet documented other than [this |
| 86 | +blog |
| 87 | +post](https://blog.afoolishmanifesto.com/posts/a-love-letter-to-plain-text/). |
| 88 | +With that in mind it uses an ordered, regexp based dispatcher in the |
| 89 | +`internal/notes` package. |
| 90 | + |
| 91 | +My notes are structured text in Dropbox, so the `internal/notes` package talks |
| 92 | +directly to Dropbox to download and upload files. |
| 93 | + |
| 94 | +### `enqueue-at` |
| 95 | + |
| 96 | +This runs on my laptop. If I find that I use it often I want to figure out how |
| 97 | +to run this in the cloud (without a VM.) |
| 98 | + |
| 99 | +I run it like this: |
| 100 | + |
| 101 | +```bash |
| 102 | +$ minotaur ~/Dropbox/notes/.alerts -- bin/enqueue-at |
| 103 | +``` |
| 104 | + |
| 105 | +[`minotaur` comes with my |
| 106 | +Leatherman](https://github.com/frioux/leatherman#minotaur). |
| 107 | + |
| 108 | +`enqueue-at` simply enqueues notifications via `atd`, using a tool called |
| 109 | +`wuphf`, which is included with this project. |
| 110 | + |
| 111 | +[See docs for `remind me`](#remind-me) for more details. |
| 112 | + |
| 113 | +### `wuphf` |
| 114 | + |
| 115 | +Currently this tool sends alerts via both `wall` and |
| 116 | +[pushover](https://pushover.net). All arguments are concatenated to produce the |
| 117 | +sent message. |
| 118 | + |
| 119 | +## Development |
| 120 | + |
| 121 | +Here's a list of places to look when you need to add functionality: |
| 122 | + |
| 123 | + * [NewRules](https://godoc.org/github.com/frioux/amygdala/internal/notes#NewRules) |
| 124 | + is where you can create a new command. |
| 125 | + * [Dropbox package](https://godoc.org/github.com/frioux/amygdala/internal/dropbox) |
| 126 | + * [Twilio package](https://godoc.org/github.com/frioux/amygdala/internal/twilio) |
| 127 | + |
| 128 | +It's always wise to run `go test ./...` before pushing any changes. After |
| 129 | +that, using `cmd/brain-stem` to verify changes without needing the full stack |
| 130 | +is useful. If you want more, you can run the main app (`amygdala`) and poke at |
| 131 | +it with `cmd/twilio`. There's no dropbox mock yet so you'll need to actually |
| 132 | +use the real dropbox token, but other than that you should be able to develop |
| 133 | +almost 100% locally. |
| 134 | + |
| 135 | +## History |
| 136 | + |
| 137 | +This is meant to be a simpler replacement to [my lizard |
| 138 | +brain](https://github.com/frioux/Lizard-Brain), both because the world has |
| 139 | +improved and so have I. |
| 140 | + |
| 141 | +The old system's design was around allowing arbitrary inputs and outputs; the |
| 142 | +new system is only decoupled as I see fit, instead of enforcing that arbitrarily |
| 143 | +from the start. |
0 commit comments