/
plugin_vcard.ml
39 lines (34 loc) · 1.23 KB
/
plugin_vcard.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(*
* (c) 2005-2009 Anastasia Gornostaeva. <ermine@ermine.pp.ru>
*)
open Xep_vcard
open Hooks
open Plugin_command
let result_vcard vcard =
let nick, desc, email, bday, url =
List.fold_left (fun (nick, desc, email, bday, url) -> function
| Nickname nick ->
(nick, desc, email, bday, url)
| Desc desc ->
(nick, desc, email, bday, url)
| URL url ->
(nick, desc, email, bday, url)
| BDay bday ->
(nick, desc, email, bday, url)
| Email email ->
(nick, desc, email.userid, bday, url)
| _ ->
(nick, desc, email, bday, url)
) ("", "", "", "", "") vcard.fields
in
String.concat "--" [vcard.fn; nick; email; url; desc; bday]
let vsearch =
let success _env _text _entity = function
| None -> "no info"
| Some el -> result_vcard (Xep_vcard.decode el)
in
Iq.simple_query_entity success ~payload:(Xep_vcard.make_iq_get ())
let plugin opts =
add_commands [("vcard", vsearch)] opts
let _ =
add_plugin "vcard" plugin