Software /
code /
prosody-modules
Annotate
mod_motd_sequential/mod_motd_sequential.lua @ 709:151743149f07
mod_client_certs: Follow the rules in XEP-0178 about the inclusion of the username when using EXTERNAL, instead of mapping one certificate to one user.
author | Thijs Alkemade <thijsalkemade@gmail.com> |
---|---|
date | Sat, 09 Jun 2012 23:15:44 +0200 |
parent | 234:abcb59ab355c |
child | 1343:7dbde05b48a9 |
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 |
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
|
5 -- |
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 |
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
|
10 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
|
11 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
|
12 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
|
13 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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 |
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 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
|
23 |
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 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
|
25 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
|
26 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
|
27 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
|
28 local alreadyseen = alreadyseen_list["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
|
29 local mod_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
|
30 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
|
31 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
|
32 st.message({ to = session.username..'@'..session.host, from = motd_jid }) |
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
|
33 :tag("body"):text(motd_messagesets[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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 end); |