21 lines
		
	
	
		
			729 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			729 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
| 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 --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 |