|chrsm 1465265587 initial commit (port)||3 years ago|
|cmd/hombre||3 years ago|
|README.md||3 years ago|
|config.go||3 years ago|
|hombre.go||3 years ago|
|lua.go||3 years ago|
This is a Slack bot on drugs. If lua were drugs, I mean.
README is sorta bare right now, as this project is being massaged out of a project at work.
Lua is a pretty simple language. The VM implementation is based on Lua 5.1, even though there’s like a 5.3 now.
There are a few globals available to all scripts:
* hombre * conf * luaWorkingDir
And a few modules:
* re (regex) * http * json
The “service” scripts are initialized when hombre starts up. These receive a
go channel that accepts messages from Slack (
At this point, it’s time to stop any further execution, hence the standard loop:
local exit = false while not exit do local msg, ok = msgch:receive() if not ok then exit = true else -- do stuff with msg end end
If an error is encountered during service execution, the lua VM will cause a panic in the hombre “host”, requiring a restart.
One-off scripts are run on-demand when a !command matches what is configured in
These scripts receive a single global
Once the script is done, the VM is closed.
A quick way to get the “arguments” to a command is like so:
local cmd = "!hey " local query = string.sub(msg.Text, #cmd) -- msg = global