Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- speedtest-cli must be installed
- -- run "pip speedtest-cli" to install
- local function grab(id)
- if id then
- share = " --share"
- else
- share = ""
- end
- local handle = io.popen("speedtest-cli --simple"..share)
- local result = handle:read("*a")
- handle:close()
- if id then
- local match = string.match(result, "(https?://[%w-_%.%?%.:/%+=&]+%.(png))")
- if not match then
- return "Not able to grab the result image."
- end
- local file = download_to_file(match)
- local cb_extra = {file_path=file}
- local send = send_photo(id, file, rmtmp_cb, cb_extra)
- print(id, send)
- return
- else
- return result
- end
- end
- local function speed(id)
- if id then
- return grab(id)
- else
- return grab()
- end
- end
- local function run(msg, matches)
- if matches[1] == 'share' then
- return speed(get_receiver(msg))
- else
- return speed()
- end
- end
- return {
- description = "",
- usage = "",
- patterns = {
- "^!speed$",
- "^!speed (share)",
- "^!speed (.+)$"
- },
- run = run,
- privileged = true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement