From fd65e952b4443b9e516a9f4f8668aac9dc27cd48 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Tue, 30 Jul 2024 19:55:52 -0400 Subject: * 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 --- README.md | 28 +++++++++++++++++++++++++--- main.go | 1 + plugins/ip.lua | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 58713b1..f400d8d 100644 --- a/README.md +++ b/README.md @@ -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.
+ ```lua milla.send_message(msg, target) ``` @@ -752,13 +754,33 @@ milla.register_cmd("/plugins/ip.lua", "ip", "milla_get_ip") This will allow us to do:
-``` +```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.
+And get this in response:
+ +```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.
+- 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.
+ +```sh +ALL_PROXY=socks5://172.17.0.1:9050 +``` -More of milla's functionality will be available through milla's lua module over time.
' +More of milla's functionality will be available through milla's lua module over time.
The following libraries are loaded by milla by default: diff --git a/main.go b/main.go index 05133c0..e04bb85 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/plugins/ip.lua b/plugins/ip.lua index 79ac6e2..38c9f4e 100644 --- a/plugins/ip.lua +++ b/plugins/ip.lua @@ -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 -- cgit v1.2.3