Remove example module

Also removes the 'WegaBoard' module that accidentally snuck into haboli.cabal
This commit is contained in:
Joscha 2020-04-08 11:54:01 +00:00
parent 644ebcefc9
commit ca06a7fbef
3 changed files with 2 additions and 77 deletions

View file

@ -4,6 +4,7 @@
- add `Haboli.Euphoria.Command` module - add `Haboli.Euphoria.Command` module
- clean up project - clean up project
- fix nick of example bot in readme - fix nick of example bot in readme
- remove `Haboli.Euphoria.Examples` module
## 0.3.1.0 ## 0.3.1.0
- add `Haboli.Euphoria` module - add `Haboli.Euphoria` module

View file

@ -4,7 +4,7 @@ cabal-version: 1.12
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
-- --
-- hash: bcd1c482ca0554443e9e0523bf9eb0cc65354ef37c4aec33570b5ab9a22502bf -- hash: 93e0477ebf814906c7ad7dcd56922b71fa3189833865db6f5d4442811983b1c7
name: haboli name: haboli
version: 0.3.1.0 version: 0.3.1.0
@ -33,8 +33,6 @@ library
Haboli.Euphoria.Api Haboli.Euphoria.Api
Haboli.Euphoria.Client Haboli.Euphoria.Client
Haboli.Euphoria.Command Haboli.Euphoria.Command
Haboli.Euphoria.Example
Haboli.Euphoria.WegaBorad
other-modules: other-modules:
Paths_haboli Paths_haboli
hs-source-dirs: hs-source-dirs:

View file

@ -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 ()