Add patch-hangouts
[prosody-hacks.git] / modules / mod_csi_on_away.lua
1 local st = require "util.stanza";
2
3
4 -- Make sure we only load this module when CSI itself is deployed
5 module:depends("csi");
6
7
8 local function on_presence(event)
9         if not event.origin.username then
10                 return nil;
11         end
12
13         local child = event.stanza:get_child("show");
14
15         if child and child:get_text() == "away" then
16                 module:log("debug", "User is now away, simulating CSI.");
17                 module:fire_event("csi-client-inactive", event);
18         else
19                 module:log("debug", "User is no longer away, ending simulated CSI.");
20                 module:fire_event("csi-client-active", event);
21         end
22 end
23
24
25 -- outgoing
26 module:hook("pre-presence/bare", on_presence);
27 module:hook("pre-presence/full", on_presence);
28 module:hook("pre-presence/host", on_presence);
29