Sun, 24 Aug 2014 20:34:04 +0100
sendfilecontent: Fix indentation and show error if file cannot be opened
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, err = io.open(opts.file, "rb") if not f then conn:error("Unable to open file: %s", err); else 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 end end conn:close(); end clix_connect(opts, on_connect); end