clix/vcard.lua

Fri, 17 Aug 2012 18:15:20 +0200

author
Kim Alvefur <zash@zash.se>
date
Fri, 17 Aug 2012 18:15:20 +0200
changeset 97
83cd777fb294
parent 67
776d97484dc5
child 98
5ad042476235
permissions
-rw-r--r--

clix.publish_atom: Add a way to attach Activitystrea.ms metadata to the entry

64
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local t_insert, t_concat = table.insert, table.concat;
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 return function (opts, arg)
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 if opts.short_help then
67
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
5 print("Fetch someones vCard or set your own");
64
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 return;
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 end
67
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
8 if ((#arg == 0 and not opts.set) or opts.help) then
64
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 return 0;
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 end
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 local function on_connect(conn)
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 conn:add_plugin("vcard");
67
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
13 if not opts.set then -- get
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
14 conn:get_vcard(arg[1], function(vCard)
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
15 print(vCard and vCard._text or "No vCard returned")
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
16 conn:close();
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
17 end);
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
18 else
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
19 conn:set_vcard(opts.stdin and io.stdin:read"*a"
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
20 or (opts.file and io.open(opts.file):read"*a") or arg[1],
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
21 function() conn:close() end)
776d97484dc5 clix.vcard: Use util.vcard, add ability to change your vcard.
Kim Alvefur <zash@zash.se>
parents: 65
diff changeset
22 end
64
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 end
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 clix_connect(opts, on_connect);
582afbb2b23d clix.vcard, squishy: Add plugin that fetches and converts peoples vCards to the text format.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 end

mercurial