# HG changeset patch # User Marc Fauser # Date 1408529146 -7200 # Node ID f1166645a56c1dff4c7709097ab82f792e1714c1 # Parent 956242b7d5dfe9f099304b9a7121662d8d204c5e new sendfilecontent plugin - todo: add full or relative path possibility. not only current path diff -r 956242b7d5df -r f1166645a56c clix.lua --- a/clix.lua Sun Mar 31 02:56:39 2013 +0100 +++ b/clix.lua Wed Aug 20 12:05:46 2014 +0200 @@ -10,7 +10,8 @@ -- Global to allow commands to add to it short_opts = { v = "verbose", q = "quiet", t = "to", f = "from", e = "type", - a = "account", p = "password", r = "resource", o = "presence", c = "chatroom", i = "interactive" } + a = "account", p = "password", r = "resource", o = "presence", c = "chatroom", i = "interactive", + f = "file" } if #arg < 1 then print("Command Line XMPP, available commands:"); diff -r 956242b7d5df -r f1166645a56c clix/sendfilecontent.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clix/sendfilecontent.lua Wed Aug 20 12:05:46 2014 +0200 @@ -0,0 +1,25 @@ +return function (opts, arg) + if opts.short_help then + print("Send file content"); + return; + end + local function on_connect(conn) + local function send_message(text) + conn:send(verse.message({ to = opts.to, + type = opts.type or (opts.chatroom and "groupchat") or "chat" }) + :body(text)); + end + if opts.file then + local f = io.open(opts.file, "rb") + local content = f:read("*all") + f:close() + if content:len() < 2000 then + send_message(content); + else + conn:error("File size too large. Cannot send file"); + end + conn:close(); + end + end + clix_connect(opts, on_connect); +end diff -r 956242b7d5df -r f1166645a56c squishy --- a/squishy Sun Mar 31 02:56:39 2013 +0100 +++ b/squishy Wed Aug 20 12:05:46 2014 +0200 @@ -1,5 +1,6 @@ local commands = { "send"; + "sendfilecontent"; "receive"; "version"; "bounce";