Mercurial > prosody-modules
comparison mod_twitter/mod_twitter.lua @ 2887:65082d91950e
Many modules: Simplify st.message(…):tag("body"):text(…):up() into st.message(…, …)
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Sat, 17 Feb 2018 08:42:10 +0100 |
| parents | ac9bf3fcbcfe |
| children |
comparison
equal
deleted
inserted
replaced
| 2886:5ca6d53d3186 | 2887:65082d91950e |
|---|---|
| 23 end | 23 end |
| 24 | 24 |
| 25 function dmsg(jid, msg) | 25 function dmsg(jid, msg) |
| 26 module:log("debug", msg or "nil"); | 26 module:log("debug", msg or "nil"); |
| 27 if jid ~= nil then | 27 if jid ~= nil then |
| 28 module:send(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(msg or "nil"):up()); | 28 module:send(st.message({to=jid, from=component_host, type='chat'}, msg or "nil")); |
| 29 end | 29 end |
| 30 end | 30 end |
| 31 | 31 |
| 32 function substring(string, start_string, ending_string) | 32 function substring(string, start_string, ending_string) |
| 33 local s_value_start, s_value_finish = nil, nil; | 33 local s_value_start, s_value_finish = nil, nil; |
| 98 if self.data.dosync == 1 then | 98 if self.data.dosync == 1 then |
| 99 self.dosync = true; | 99 self.dosync = true; |
| 100 timer.add_task(self.data.refreshrate, function() return users[self.jid]:sync(); end) | 100 timer.add_task(self.data.refreshrate, function() return users[self.jid]:sync(); end) |
| 101 end | 101 end |
| 102 else | 102 else |
| 103 module:send(st.message({to=self.jid, from=component_host, type='chat'}):tag("body"):text("You are not signed in.")); | 103 module:send(st.message({to=self.jid, from=component_host, type='chat'}, "You are not signed in.")); |
| 104 end | 104 end |
| 105 end | 105 end |
| 106 | 106 |
| 107 function user:logout() | 107 function user:logout() |
| 108 datamanager.store(self.jid, component_host, "data", self.data); | 108 datamanager.store(self.jid, component_host, "data", self.data); |
| 194 if action.method == "GET" and post ~= {} then | 194 if action.method == "GET" and post ~= {} then |
| 195 url = url.."?"..http.formencode(post); | 195 url = url.."?"..http.formencode(post); |
| 196 end | 196 end |
| 197 http_add_action(line, url, action.method, post, function(...) self:twitterActionResult(...) end); | 197 http_add_action(line, url, action.method, post, function(...) self:twitterActionResult(...) end); |
| 198 else | 198 else |
| 199 module:send(st.message({to=self.jid, from=component_host, type='chat'}):tag("body"):text("Wrong twitter action!"):up()); | 199 module:send(st.message({to=self.jid, from=component_host, type='chat'}, "Wrong twitter action!")); |
| 200 end | 200 end |
| 201 end | 201 end |
| 202 | 202 |
| 203 local twitterActionResultMap = { | 203 local twitterActionResultMap = { |
| 204 PublicTimeline = {exec=function(jid, response) | 204 PublicTimeline = {exec=function(jid, response) |
| 205 --module:send(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(print_r(response)):up()); | 205 --module:send(st.message({to=jid, from=component_host, type='chat'}, print_r(response))); |
| 206 return | 206 return |
| 207 end}, | 207 end}, |
| 208 HomeTimeline = {exec=function(jid, response) | 208 HomeTimeline = {exec=function(jid, response) |
| 209 --module:send(st.message({to=jid, from=component_host, type='chat'}):tag("body"):text(print_r(response)):up()); | 209 --module:send(st.message({to=jid, from=component_host, type='chat'}, print_r(response))); |
| 210 return | 210 return |
| 211 end}, | 211 end}, |
| 212 FriendsTimeline = {function(jid, response) | 212 FriendsTimeline = {function(jid, response) |
| 213 return | 213 return |
| 214 end}, | 214 end}, |
| 414 end | 414 end |
| 415 -- Now parse the message | 415 -- Now parse the message |
| 416 if stanza.attr.to == component_host then | 416 if stanza.attr.to == component_host then |
| 417 if msg.body == "!myinfo" then | 417 if msg.body == "!myinfo" then |
| 418 if users[from_bjid] ~= nil then | 418 if users[from_bjid] ~= nil then |
| 419 origin.send(st.message({to=stanza.attr.from, from=component_host, type='chat'}):tag("body"):text(print_r(users[from_bjid])):up()); | 419 origin.send(st.message({to=stanza.attr.from, from=component_host, type='chat'}, print_r(users[from_bjid]))); |
| 420 end | 420 end |
| 421 end | 421 end |
| 422 -- Other messages go to twitter | 422 -- Other messages go to twitter |
| 423 user:twitterAction("UpdateStatus", {status=msg.body}); | 423 user:twitterAction("UpdateStatus", {status=msg.body}); |
| 424 else | 424 else |
