Skip to content

Commit

Permalink
* fixed a bug where we would end up with an unwanted whitespace at the
Browse files Browse the repository at this point in the history
  beginning of all args passed to the custom lua commands
* added some notes to the readme
  • Loading branch information
terminaldweller committed Jul 30, 2024
1 parent 81469bb commit fd65e95
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ end
rss_feed()
```

The example rss plugin, accepts a yaml file as input, reeds the provided rss feeds once, extracts the title, author name and link to the resource, sends the feed over to the `#rssfeed` irc channel and exits.<br/>

```lua
milla.send_message(msg, target)
```
Expand Down Expand Up @@ -752,13 +754,33 @@ milla.register_cmd("/plugins/ip.lua", "ip", "milla_get_ip")

This will allow us to do:<br/>

```
```txt
terra: /ip 1.1.1.1
```

The example rss plugin, accepts a yaml file as input, reeds the provided rss feeds once, extracts the title, author name and link to the resource, sends the feed over to the `#rssfeed` irc channel and exits.<br/>
And get this in response:<br/>

```txt
isp: Cloudflare, Inc -- query: 1.1.1.1 -- status: success -- regionName: Queensland -- lat: -27.4766 -- timezone: Australia/Brisbane -- region: QLD -- lon: 153.0166 -- country: Australia -- countryCode: AU -- city: South Brisbane --ip: 4101 -- org: APNIC and Cloudflare DNS Resolver project -- as: AS13335 Cloudflare, Inc. --
```

### NOTES

- Each lua plugin gets its own lua state and will run in a goroutine.<br/>
- Lua plugins will not go through a proxy if they are not instructed to do so. If you are using the provided http module, you can set the proxy value before loading the http module as provided in the examples under `plugins`. The module will read and set the following environment variables in the order given:
- `ALL_PROXY`
- `HTTPS_PROXY`
- `HTTP_PROXY`
- `https_proxy`
- `http_proxy`

`http` and `socks5` proxies are supported. unfortunately, the `socks5h` proxy is not supported.<br/>

```sh
ALL_PROXY=socks5://172.17.0.1:9050
```

More of milla's functionality will be available through milla's lua module over time.<br/>'
More of milla's functionality will be available through milla's lua module over time.<br/>

The following libraries are loaded by milla by default:

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ func runCommand(
luaArgs = strings.TrimSpace(luaArgs)
luaArgs = strings.TrimPrefix(luaArgs, "/")
luaArgs = strings.TrimPrefix(luaArgs, args[0])
luaArgs = strings.TrimSpace(luaArgs)

result := RunLuaFunc(args[0], luaArgs, client, appConfig)
client.Cmd.Reply(event, result)
Expand Down
2 changes: 2 additions & 0 deletions plugins/ip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function milla_get_ip(arg)

local url = "http://ip-api.com/json/" .. arg

print("Requesting: " .. url)

local response, err = http.request("GET", url)
if err ~= nil then print(err) end

Expand Down

0 comments on commit fd65e95

Please sign in to comment.