Software / code / prosody
Comparison
prosodyctl @ 2277:c5d3905c98a6
prosodyctl: Experimental 'addplugin' command
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 02 Dec 2009 20:31:54 +0000 |
| parent | 2065:c384ae8ee17a |
| child | 2329:e497718194a3 |
comparison
equal
deleted
inserted
replaced
| 2276:d9302be05f86 | 2277:c5d3905c98a6 |
|---|---|
| 460 | 460 |
| 461 show_message(error_messages[msg]) | 461 show_message(error_messages[msg]) |
| 462 return 1; | 462 return 1; |
| 463 end | 463 end |
| 464 | 464 |
| 465 function commands.addplugin(arg) | |
| 466 local url = arg[1]; | |
| 467 if url:match("^http://") then | |
| 468 local http = require "socket.http"; | |
| 469 show_message("Fetching..."); | |
| 470 local code, err = http.request(url); | |
| 471 if not code then | |
| 472 show_message("Failed: "..err); | |
| 473 return 1; | |
| 474 end | |
| 475 if url:match("%.lua$") then | |
| 476 local ok, err = datamanager.store(url:match("/mod_([^/]+)$"), "*", "plugins", {code}); | |
| 477 if not ok then | |
| 478 show_message("Failed to save to data store: "..err); | |
| 479 return 1; | |
| 480 end | |
| 481 end | |
| 482 show_message("Saved. Don't forget to load the module using the config file or admin console!"); | |
| 483 else | |
| 484 show_message("Sorry, I don't understand how to fetch plugins from there."); | |
| 485 end | |
| 486 end | |
| 465 | 487 |
| 466 --------------------- | 488 --------------------- |
| 467 | 489 |
| 468 if command and command:match("^mod_") then -- Is a command in a module | 490 if command and command:match("^mod_") then -- Is a command in a module |
| 469 local module_name = command:match("^mod_(.+)"); | 491 local module_name = command:match("^mod_(.+)"); |