blob: 6d28ef995e5b683bb3442499b8aaea46253b1f6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
module Hsbot.Plugin.Ping
( ping
, thePing
) where
import Control.Concurrent.Chan ()
import Control.Monad.Reader
import qualified Network.IRC as IRC
import Prelude hiding (catch)
import Hsbot.Message
import Hsbot.Types
ping :: PluginId
ping = PluginId
{ pluginName = "ping"
, pluginEp = thePing }
-- | The IrcPlugin monad main function
thePing :: Plugin (Env IO) ()
thePing = forever $ readMsg >>= eval
where
eval :: Message -> Plugin (Env IO) ()
eval (IncomingMsg msg)
| IRC.msg_command msg == "PING" = writeMsg . OutgoingMsg . IRC.Message Nothing "PONG" $ IRC.msg_params msg
| otherwise = return ()
eval _ = return ()
|