From ca06a7fbef722feb59246d3743790f2191250593 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 8 Apr 2020 11:54:01 +0000 Subject: [PATCH] Remove example module Also removes the 'WegaBoard' module that accidentally snuck into haboli.cabal --- CHANGELOG.md | 1 + haboli.cabal | 4 +- src/Haboli/Euphoria/Example.hs | 74 ---------------------------------- 3 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 src/Haboli/Euphoria/Example.hs diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d72c89..fdc31e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - add `Haboli.Euphoria.Command` module - clean up project - fix nick of example bot in readme +- remove `Haboli.Euphoria.Examples` module ## 0.3.1.0 - add `Haboli.Euphoria` module diff --git a/haboli.cabal b/haboli.cabal index 9c730ed..e663342 100644 --- a/haboli.cabal +++ b/haboli.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: bcd1c482ca0554443e9e0523bf9eb0cc65354ef37c4aec33570b5ab9a22502bf +-- hash: 93e0477ebf814906c7ad7dcd56922b71fa3189833865db6f5d4442811983b1c7 name: haboli version: 0.3.1.0 @@ -33,8 +33,6 @@ library Haboli.Euphoria.Api Haboli.Euphoria.Client Haboli.Euphoria.Command - Haboli.Euphoria.Example - Haboli.Euphoria.WegaBorad other-modules: Paths_haboli hs-source-dirs: diff --git a/src/Haboli/Euphoria/Example.hs b/src/Haboli/Euphoria/Example.hs deleted file mode 100644 index 1435fe9..0000000 --- a/src/Haboli/Euphoria/Example.hs +++ /dev/null @@ -1,74 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - --- | This module contains a few basic example bots. -module Haboli.Euphoria.Example where - -import Control.Concurrent -import Control.Monad -import Control.Monad.IO.Class -import Data.Foldable -import Haboli.Euphoria - -printAllEventsBot :: Client () () -printAllEventsBot = forever $ do - liftIO $ putStrLn "\nWaiting for the next event...\n" - liftIO . print =<< respondingToPing nextEvent - -setNickAndThenWaitBot :: Client () () -setNickAndThenWaitBot = forever $ do - event <- respondingToPing nextEvent - case event of - EventSnapshot _ -> void $ nick "HaboliTestBot" - _ -> pure () - -throwCustomExceptionBot :: Client String () -throwCustomExceptionBot = throw "Hello world" - -immediatelyDisconnectBot :: Client () () -immediatelyDisconnectBot = pure () - -sendMessagesUntilThrottledBot :: Client () () -sendMessagesUntilThrottledBot = forever $ do - event <- respondingToPing nextEvent - case event of - EventSnapshot _ -> do - void $ nick "SpamBot" - msg <- send "start thread" - void $ fork $ handle (\_ -> reply msg "got throttled") $ - forever $ reply msg "continue thread" - _ -> pure () - -sendMessagesThreadedBot :: Client () () -sendMessagesThreadedBot = forever $ do - event <- respondingToPing nextEvent - case event of - EventSnapshot _ -> void $ nick "TreeBot" - EventSend e -> - let msg = sendMessage e - in when (msgContent msg == "!tree") $ - void $ fork $ buildTree msg - _ -> pure () - where - buildTree msg = do - t1 <- fork $ reply msg "subtree 1" - t2 <- fork $ reply msg "subtree 2" - subtree1 <- wait t1 - subtree2 <- wait t2 - t3 <- fork $ reply subtree1 "subtree 1.1" - t4 <- fork $ reply subtree1 "subtree 1.2" - t5 <- fork $ reply subtree2 "subtree 2.1" - t6 <- fork $ reply subtree2 "subtree 2.2" - for_ [t3, t4, t5, t6] wait - reply msg "tree done" - -cloneItselfBot :: Client () () -cloneItselfBot = forever $ do - event <- respondingToPing nextEvent - case event of - EventSnapshot _ -> void $ nick "CloneBot" - EventSend e - | msgContent (sendMessage e) == "!clone" -> do - config <- getConnectionConfig - void $ liftIO $ forkIO $ void $ runClient config cloneItselfBot - | otherwise -> pure () - _ -> pure ()