Software / code / prosody
Comparison
prosodyctl @ 3234:2d61773d7ab4
Merge 0.7->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 11 Jun 2010 14:25:54 +0100 |
| parent | 3161:73e93a48c0c1 |
| parent | 3233:8f78e8164032 |
| child | 3337:4bccec3c24e5 |
comparison
equal
deleted
inserted
replaced
| 3232:c47bfd62701c | 3234:2d61773d7ab4 |
|---|---|
| 536 | 536 |
| 537 show_message(error_messages[msg]) | 537 show_message(error_messages[msg]) |
| 538 return 1; | 538 return 1; |
| 539 end | 539 end |
| 540 | 540 |
| 541 local http_errors = { | |
| 542 [404] = "Plugin not found, did you type the address correctly?" | |
| 543 }; | |
| 544 | |
| 545 function commands.addplugin(arg) | |
| 546 if not arg[1] or arg[1] == "--help" then | |
| 547 show_usage("addplugin URL", "Download and install a plugin from a URL"); | |
| 548 return 1; | |
| 549 end | |
| 550 local url = arg[1]; | |
| 551 if url:match("^http://") then | |
| 552 local http = require "socket.http"; | |
| 553 show_message("Fetching..."); | |
| 554 local code, err = http.request(url); | |
| 555 if not code or not tostring(err):match("^[23]") then | |
| 556 show_message("Failed: "..(http_errors[err] or ("HTTP error "..err))); | |
| 557 return 1; | |
| 558 end | |
| 559 if url:match("%.lua$") then | |
| 560 local ok, err = datamanager.store(url:match("/mod_([^/]+)$"), "*", "plugins", {code}); | |
| 561 if not ok then | |
| 562 show_message("Failed to save to data store: "..err); | |
| 563 return 1; | |
| 564 end | |
| 565 end | |
| 566 show_message("Saved. Don't forget to load the module using the config file or admin console!"); | |
| 567 else | |
| 568 show_message("Sorry, I don't understand how to fetch plugins from there."); | |
| 569 end | |
| 570 end | |
| 571 | |
| 572 --------------------- | 541 --------------------- |
| 573 | 542 |
| 574 if command and command:match("^mod_") then -- Is a command in a module | 543 if command and command:match("^mod_") then -- Is a command in a module |
| 575 local module_name = command:match("^mod_(.+)"); | 544 local module_name = command:match("^mod_(.+)"); |
| 576 local ret, err = modulemanager.load("*", module_name); | 545 local ret, err = modulemanager.load("*", module_name); |