speedtest-cli Plugin
This commit is contained in:
parent
f7f996ea2e
commit
98226679a9
25
miku/plugins/speedtest_cli.lua
Normal file
25
miku/plugins/speedtest_cli.lua
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
--[[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(self, msg.chat.id, 'typing')
|
||||||
|
local result = run_command('speedtest-cli --share')
|
||||||
|
local url = result:match("Share results: (.*)")
|
||||||
|
utilities.send_typing(self, msg.chat.id, 'upload_photo')
|
||||||
|
local photo = download_to_file(url, 'speedtest_cli.png')
|
||||||
|
if not photo then
|
||||||
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
utilities.send_photo(self, msg.chat.id, photo, nil, msg.message_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
return speedtest_cli
|
Reference in New Issue
Block a user