From 56b9985fa39cacedd9692ace5a63d72d0f042de9 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 4 Dec 2015 15:59:47 -0500 Subject: [PATCH] Do not tell me I joined when I'm already in Especially when I'm changing my nickname. Closes #20 --- Main.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Main.hs b/Main.hs index d5f58e2..7f296c0 100644 --- a/Main.hs +++ b/Main.hs @@ -200,10 +200,14 @@ handleJoinPartRoom db toVitelity toComponent existingRoom from to tel payloads j else code "201" status - when (null code201) $ do - writeStanzaChan toVitelity $ mkSMS tel (mconcat [fromString "* You have joined ", bareMUC, fromString " as ", resourceFrom]) - presence <- fmap (fromMaybe [] . (readZ =<<)) (TC.runTCM $ TC.get db (T.unpack bareMUC <> "\0presence")) - writeStanzaChan toVitelity $ mkSMS tel $ fromString $ "Group participants: " <> intercalate ", " presence + presence <- fmap (fromMaybe [] . (readZ =<<)) (TC.runTCM $ TC.get db (T.unpack bareMUC <> "\0presence")) + when (null code201 && not (resourceFrom `elem` presence)) $ + writeStanzaChan toVitelity $ mkSMS tel (mconcat [ + fromString "* You have joined ", bareMUC, + fromString " as ", resourceFrom, + fromString " along with\n", + intercalate ", " (filter (/= resourceFrom) presence) + ]) queryDisco toComponent room to | not join, -- 2.38.5