# HG changeset patch # User Emmanuel Gil Peyrot # Date 1518853330 -3600 # Node ID 65082d91950e8d31efcbaf7fc58e22396deb8d82 # Parent 5ca6d53d3186f2a7a59b504dd9ec6a642cf8957e Many modules: Simplify st.message(…):tag("body"):text(…):up() into st.message(…, …) diff -r 5ca6d53d3186 -r 65082d91950e mod_admin_message/mod_admin_message.lua --- a/mod_admin_message/mod_admin_message.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_admin_message/mod_admin_message.lua Sat Feb 17 08:42:10 2018 +0100 @@ -89,8 +89,7 @@ -- Send the reply stanza local reply_stanza = st.message({ from = host, to = userjid, - type = "chat" }); - reply_stanza = reply_stanza:body(session.fulltext); + type = "chat" }, session.fulltext); module:send(reply_stanza); return true; diff -r 5ca6d53d3186 -r 65082d91950e mod_alias/mod_alias.lua --- a/mod_alias/mod_alias.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_alias/mod_alias.lua Sat Feb 17 08:42:10 2018 +0100 @@ -26,7 +26,7 @@ local error_message = alias_response:gsub("%$([%w_]+)", function (v) return replacements[v] or nil; end); - local message = st.message{ type = "chat", from = alias, to = event.stanza.attr.from }:tag("body"):text(error_message); + local message = st.message({ type = "chat", from = alias, to = event.stanza.attr.from }, error_message); module:send(message); return event.origin.send(st.error_reply(event.stanza, "cancel", "gone", error_message)); end diff -r 5ca6d53d3186 -r 65082d91950e mod_manifesto/mod_manifesto.lua --- a/mod_manifesto/mod_manifesto.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_manifesto/mod_manifesto.lua Sat Feb 17 08:42:10 2018 +0100 @@ -103,7 +103,7 @@ SERVICES = " "..table.concat(bad_hosts, "\n "); CONTACTVIA = contact_method, CONTACT = contact; }; - session.send(st.message({ type = "headline", from = host }):tag("body"):text(message:gsub("$(%w+)", vars))); + session.send(st.message({ type = "headline", from = host }, message:gsub("$(%w+)", vars))); notified[session.username] = now; end end); diff -r 5ca6d53d3186 -r 65082d91950e mod_motd_sequential/mod_motd_sequential.lua --- a/mod_motd_sequential/mod_motd_sequential.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_motd_sequential/mod_motd_sequential.lua Sat Feb 17 08:42:10 2018 +0100 @@ -29,8 +29,8 @@ local mod_stanza; for i = alreadyseen, max do motd_stanza = - st.message({ to = session.username..'@'..session.host, from = motd_jid }) - :tag("body"):text(motd_messagesets[i]); + st.message({ to = session.username..'@'..session.host, from = motd_jid }, + motd_messagesets[i]); core_route_stanza(hosts[host], motd_stanza); module:log("debug", "MOTD send to user %s@%s", session.username, session.host); end diff -r 5ca6d53d3186 -r 65082d91950e mod_sms_clickatell/mod_sms_clickatell.lua --- a/mod_sms_clickatell/mod_sms_clickatell.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_sms_clickatell/mod_sms_clickatell.lua Sat Feb 17 08:42:10 2018 +0100 @@ -150,7 +150,7 @@ function dmsg(jid, msg) module:log("debug", msg or "nil"); if jid ~= nil then - send_stanza(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(msg or "nil"):up()); + send_stanza(st.message({to=jid, from=component_host, type='chat'}, msg or "nil")); end end @@ -498,7 +498,7 @@ -- Now parse the message if stanza.attr.to == component_host then -- Messages directly to the component jget echoed - origin.send(st.message({to=stanza.attr.from, from=component_host, type='chat'}):tag("body"):text(msg.body):up()); + origin.send(st.message({to=stanza.attr.from, from=component_host, type='chat'}, msg.body)); elseif users[from_bjid].data.roster[to.node] ~= nil then -- If message contains a body, send message to SMS Test User if msg.body ~= nil then diff -r 5ca6d53d3186 -r 65082d91950e mod_twitter/mod_twitter.lua --- a/mod_twitter/mod_twitter.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_twitter/mod_twitter.lua Sat Feb 17 08:42:10 2018 +0100 @@ -25,7 +25,7 @@ function dmsg(jid, msg) module:log("debug", msg or "nil"); if jid ~= nil then - module:send(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(msg or "nil"):up()); + module:send(st.message({to=jid, from=component_host, type='chat'}, msg or "nil")); end end @@ -100,7 +100,7 @@ timer.add_task(self.data.refreshrate, function() return users[self.jid]:sync(); end) end else - module:send(st.message({to=self.jid, from=component_host, type='chat'}):tag("body"):text("You are not signed in.")); + module:send(st.message({to=self.jid, from=component_host, type='chat'}, "You are not signed in.")); end end @@ -196,17 +196,17 @@ end http_add_action(line, url, action.method, post, function(...) self:twitterActionResult(...) end); else - module:send(st.message({to=self.jid, from=component_host, type='chat'}):tag("body"):text("Wrong twitter action!"):up()); + module:send(st.message({to=self.jid, from=component_host, type='chat'}, "Wrong twitter action!")); end end local twitterActionResultMap = { PublicTimeline = {exec=function(jid, response) - --module:send(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(print_r(response)):up()); + --module:send(st.message({to=jid, from=component_host, type='chat'}, print_r(response))); return end}, HomeTimeline = {exec=function(jid, response) - --module:send(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(print_r(response)):up()); + --module:send(st.message({to=jid, from=component_host, type='chat'}, print_r(response))); return end}, FriendsTimeline = {function(jid, response) @@ -416,7 +416,7 @@ if stanza.attr.to == component_host then if msg.body == "!myinfo" then if users[from_bjid] ~= nil then - origin.send(st.message({to=stanza.attr.from, from=component_host, type='chat'}):tag("body"):text(print_r(users[from_bjid])):up()); + origin.send(st.message({to=stanza.attr.from, from=component_host, type='chat'}, print_r(users[from_bjid]))); end end -- Other messages go to twitter diff -r 5ca6d53d3186 -r 65082d91950e mod_watchuntrusted/mod_watchuntrusted.lua --- a/mod_watchuntrusted/mod_watchuntrusted.lua Tue Feb 20 17:30:17 2018 +0100 +++ b/mod_watchuntrusted/mod_watchuntrusted.lua Sat Feb 17 08:42:10 2018 +0100 @@ -49,11 +49,10 @@ errors = error_message }; - local message = st.message{ type = "chat", from = local_host } - :tag("body") - :text(untrusted_fail_notification:gsub("%$([%w_]+)", function (v) - return event[v] or session and session[v] or replacements and replacements[v] or nil; - end)); + local message = st.message({ type = "chat", from = local_host }, + untrusted_fail_notification:gsub("%$([%w_]+)", function (v) + return event[v] or session and session[v] or replacements and replacements[v] or nil; + end)); for jid in untrusted_fail_watchers do module:log("debug", "Notifying %s", jid); message.attr.to = jid;