From eacee5539280568b3d3b06653b43fd8546804842 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 24 Nov 2015 15:50:06 -0500 Subject: [PATCH] Detect when have left a room --- Main.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Main.hs b/Main.hs index e641293..579f66b 100644 --- a/Main.hs +++ b/Main.hs @@ -133,6 +133,16 @@ componentStanza db toVitelity _ (ReceivedPresence p@(Presence { presenceFrom = J where bareMUC = bareTxt from roomNick = fromMaybe mempty (strResource <$> jidResource from) +componentStanza db toVitelity _ (ReceivedPresence p@(Presence { presenceType = PresenceUnavailable, presenceFrom = Just from, presenceTo = Just to })) + | Just tel <- strNode <$> jidNode to = do + existingRoom <- (parseJID . fromString =<<) <$> TC.runTCM (TC.get db $ T.unpack tel) + when (existingRoom == Just from) $ do + True <- TC.runTCM $ TC.out db $ T.unpack tel + writeStanzaChan toVitelity $ (emptyMessage MessageChat) { + messageTo = parseJID (tel <> fromString "@sms"), + messagePayloads = [Element (fromString "{jabber:client}body") [] [NodeContent $ ContentText $ fromString "* You have left " <> bareTxt from]] + } + return () componentStanza _ _ toComponent (ReceivedIQ (IQ { iqType = typ, iqFrom = Just from, iqTo = to, iqID = id })) | typ `elem` [IQGet, IQSet] = writeStanzaChan toComponent $ (emptyIQ IQError) { -- 2.38.5