Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
hsbot/Hsbot/Plugin/Ping.hs

30 lines
694 B
Haskell

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 $ do
msg <- readMsg
eval msg
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 ()