clix/receive.lua

Sun, 15 Nov 2020 20:45:50 +0100

author
Kim Alvefur <zash@zash.se>
date
Sun, 15 Nov 2020 20:45:50 +0100
changeset 140
8815232cbbeb
parent 27
5b58c002d6ad
permissions
-rw-r--r--

clix.watch_pep: Take PEP node as positional argument

Thanks MattJ

22
19c5a66837ed clix.receive: Suppress history from chatrooms unless -h/--history is supplied
Matthew Wild <mwild1@gmail.com>
parents: 17
diff changeset
1 short_opts.h = "history";
19c5a66837ed clix.receive: Suppress history from chatrooms unless -h/--history is supplied
Matthew Wild <mwild1@gmail.com>
parents: 17
diff changeset
2
12
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 return function (opts, args)
27
5b58c002d6ad clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
4 if opts.short_help then
5b58c002d6ad clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
5 print("Receive and display XMPP messages");
5b58c002d6ad clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
6 return;
5b58c002d6ad clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
7 end
12
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local function on_message(message)
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 local body = message:get_child("body");
22
19c5a66837ed clix.receive: Suppress history from chatrooms unless -h/--history is supplied
Matthew Wild <mwild1@gmail.com>
parents: 17
diff changeset
10 local delay = message:get_child("delay", "urn:xmpp:delay");
19c5a66837ed clix.receive: Suppress history from chatrooms unless -h/--history is supplied
Matthew Wild <mwild1@gmail.com>
parents: 17
diff changeset
11 if body and (not delay or opts.history) then
12
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 print(body:get_text());
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 end
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local function on_connect(conn)
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 conn:hook("message", on_message);
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 end
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 clix_connect(opts, on_connect);
1793fca3d707 clix.receive: New command to print text of received messages
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 end

mercurial