From 98226679a996572c3bb8e6444648a25556a9739f Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Tue, 16 Aug 2016 14:39:06 +0200 Subject: [PATCH] speedtest-cli Plugin --- miku/plugins/speedtest_cli.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 miku/plugins/speedtest_cli.lua diff --git a/miku/plugins/speedtest_cli.lua b/miku/plugins/speedtest_cli.lua new file mode 100644 index 0000000..ee52958 --- /dev/null +++ b/miku/plugins/speedtest_cli.lua @@ -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 \ No newline at end of file