From ccb7501ec47a14e91f1418c03f90336d1d1011b4 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sat, 28 Nov 2015 16:43:32 -0500 Subject: [PATCH] Welcome new users --- Main.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 9247920..0c4f155 100644 --- a/Main.hs +++ b/Main.hs @@ -480,9 +480,16 @@ viteltiy db chunks toVitelity toComponent componentHost = do putStanza $ emptyPresence PresenceAvailable forkXMPP $ forever $ flip catchError (liftIO . print) $ do + wait <- liftIO $ getStdRandom (randomR (400000,1500000)) stanza <- liftIO $ atomically $ readTChan toVitelity + forM_ (strNode <$> (jidNode =<< stanzaTo stanza)) $ \tel -> do + welcomed <- maybe False toEnum <$> liftIO (TC.runTCM $ TC.get db $ tcKey tel "welcomed") + when (not welcomed) $ do + putStanza $ mkSMS tel $ fromString "Welcome to CheoGram! You can chat with groups of your friends, right here by SMS. Send /help to learn more." + True <- liftIO (TC.runTCM $ TC.put db (tcKey tel "welcomed") (fromEnum True)) + liftIO $ threadDelay wait + putStanza $ stanza - wait <- liftIO $ getStdRandom (randomR (400000,1500000)) liftIO $ threadDelay wait forever $ flip catchError (liftIO . print) $ do -- 2.38.5