This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/miku/plugins/speedtest_cli.lua
2016-11-29 18:14:26 +01:00

26 lines
973 B
Lua

--[[Requires speedtest-cli (https://github.com/sivel/speedtest-cli)
$ wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
$ chmod +x speedtest-cli
$ sudo mv speedtest-cli /usr/local/bin/speedtest-cli
]]
local speedtest_cli = {}
function speedtest_cli:init(config)
speedtest_cli.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('speedtest', true).table
end
function speedtest_cli:action(msg, config)
utilities.send_typing(msg.chat.id, 'typing')
local result = run_command('speedtest-cli --share')
local url = result:match("Share results: (.*)")
print('URL: '..url)
local text = 'http://www.speedtest.net/my-result/'..url:match('http://www.speedtest.net/result/(.*).png')
utilities.send_typing(msg.chat.id, 'upload_photo')
if not url then
utilities.send_reply(msg, config.errors.connection)
return
end
utilities.send_photo(msg.chat.id, url, text, msg.message_id)
end
return speedtest_cli