Mercurial > prosody-modules
annotate mod_motd_sequential/mod_motd_sequential.lua @ 890:7ac1b8a799be
mod_carbons_adhoc: Initial commit.
This module will add an Adhoc-command by which a user can see if Message
Carbons (XEP-0280) are generated for his clients and also which version
is used for the individual client. Clients which receive copies as per
mod_carbons_copies will be listed as Version 0 carbons.
author | Michael Holzt <kju@fqdn.org> |
---|---|
date | Sun, 23 Dec 2012 19:36:31 +0100 |
parents | abcb59ab355c |
children | 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); |