annotate mod_motd_sequential/mod_motd_sequential.lua @ 3777:26559776a87e

mod_easy_invite: New module that implements XEP-0401/XEP-0379
author Matthew Wild <mwild1@gmail.com>
date Fri, 27 Dec 2019 10:41:01 +0000
parents 8412592f3011
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
234
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
1 -- Prosody IM
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
3 -- Copyright (C) 2008-2010 Waqas Hussain
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
4 -- Copyright (C) 2010 Jeff Mitchell
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 234
diff changeset
5 --
234
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
6 -- This project is MIT/X11 licensed. Please see the
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
7 -- COPYING file in the source package for more information.
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
8 --
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
9
3400
272908ea99c9 mod_motd_sequential: Fix for deprecation of global routing functions (fixes #1258)
Kim Alvefur <zash@zash.se>
parents: 2887
diff changeset
10 local core_route_stanza = prosody.core_route_stanza;
234
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
11 local host = module:get_host();
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
12 local motd_jid = module:get_option("motd_jid") or host;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
13 local datamanager = require "util.datamanager";
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
14 local ipairs = ipairs;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
15 local motd_sequential_messages = module:get_option("motd_sequential_messages") or {};
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
16 local motd_messagesets = {};
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
17 local max = 1;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
18 for i, message in ipairs(motd_sequential_messages) do
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
19 motd_messagesets[i] = message;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
20 max = i;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
21 end
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
22
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
23 local st = require "util.stanza";
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
24
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
25 module:hook("resource-bind",
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
26 function (event)
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
27 local session = event.session;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
28 local alreadyseen_list = datamanager.load(session.username, session.host, "motd_sequential_seen") or { max = 0 };
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
29 local alreadyseen = alreadyseen_list["max"] + 1;
3401
8412592f3011 mod_motd_sequential: Fix typo (fixes unintentional global access)
Kim Alvefur <zash@zash.se>
parents: 3400
diff changeset
30 local motd_stanza;
234
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
31 for i = alreadyseen, max do
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
32 motd_stanza =
2887
65082d91950e Many modules: Simplify st.message(…):tag("body"):text(…):up() into st.message(…, …)
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 1343
diff changeset
33 st.message({ to = session.username..'@'..session.host, from = motd_jid },
65082d91950e Many modules: Simplify st.message(…):tag("body"):text(…):up() into st.message(…, …)
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 1343
diff changeset
34 motd_messagesets[i]);
234
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
35 core_route_stanza(hosts[host], motd_stanza);
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
36 module:log("debug", "MOTD send to user %s@%s", session.username, session.host);
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
37 end
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
38 alreadyseen_list["max"] = max;
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
39 datamanager.store(session.username, session.host, "motd_sequential_seen", alreadyseen_list);
abcb59ab355c Add new motd_sequential module. This module lets you define numbered messages shown to each user in order, but only once per user, and persistent across server restarts. Useful for notifying users of added features and changes in an
Jeff Mitchell <jeffrey.mitchell@gmail.com>
parents:
diff changeset
40 end);