Skip to content

Commit fd65e95

Browse files
* fixed a bug where we would end up with an unwanted whitespace at the
beginning of all args passed to the custom lua commands * added some notes to the readme
1 parent 81469bb commit fd65e95

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

README.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,8 @@ end
677677
rss_feed()
678678
```
679679

680+
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/>
681+
680682
```lua
681683
milla.send_message(msg, target)
682684
```
@@ -752,13 +754,33 @@ milla.register_cmd("/plugins/ip.lua", "ip", "milla_get_ip")
752754

753755
This will allow us to do:<br/>
754756

755-
```
757+
```txt
756758
terra: /ip 1.1.1.1
757759
```
758760

759-
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/>
761+
And get this in response:<br/>
762+
763+
```txt
764+
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. --
765+
```
766+
767+
### NOTES
768+
769+
- Each lua plugin gets its own lua state and will run in a goroutine.<br/>
770+
- 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:
771+
- `ALL_PROXY`
772+
- `HTTPS_PROXY`
773+
- `HTTP_PROXY`
774+
- `https_proxy`
775+
- `http_proxy`
776+
777+
`http` and `socks5` proxies are supported. unfortunately, the `socks5h` proxy is not supported.<br/>
778+
779+
```sh
780+
ALL_PROXY=socks5://172.17.0.1:9050
781+
```
760782

761-
More of milla's functionality will be available through milla's lua module over time.<br/>'
783+
More of milla's functionality will be available through milla's lua module over time.<br/>
762784

763785
The following libraries are loaded by milla by default:
764786

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ func runCommand(
558558
luaArgs = strings.TrimSpace(luaArgs)
559559
luaArgs = strings.TrimPrefix(luaArgs, "/")
560560
luaArgs = strings.TrimPrefix(luaArgs, args[0])
561+
luaArgs = strings.TrimSpace(luaArgs)
561562

562563
result := RunLuaFunc(args[0], luaArgs, client, appConfig)
563564
client.Cmd.Reply(event, result)

plugins/ip.lua

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function milla_get_ip(arg)
1414

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

17+
print("Requesting: " .. url)
18+
1719
local response, err = http.request("GET", url)
1820
if err ~= nil then print(err) end
1921

0 commit comments

Comments
 (0)