Wed, 20 Aug 2014 12:05:46 +0200
new sendfilecontent plugin
- todo: add full or relative path possibility. not only current path
102 | 1 | return function (opts, arg) |
2 | if opts.short_help then | |
3 | print("Send file content"); | |
4 | return; | |
5 | end | |
6 | local function on_connect(conn) | |
7 | local function send_message(text) | |
8 | conn:send(verse.message({ to = opts.to, | |
9 | type = opts.type or (opts.chatroom and "groupchat") or "chat" }) | |
10 | :body(text)); | |
11 | end | |
12 | if opts.file then | |
13 | local f = io.open(opts.file, "rb") | |
14 | local content = f:read("*all") | |
15 | f:close() | |
16 | if content:len() < 2000 then | |
17 | send_message(content); | |
18 | else | |
19 | conn:error("File size too large. Cannot send file"); | |
20 | end | |
21 | conn:close(); | |
22 | end | |
23 | end | |
24 | clix_connect(opts, on_connect); | |
25 | end |