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/Plugins/Ping.hs
Julien Dessaux fd8d5faf5f Began a complete rewrite of command and plugin management.
Wrote a command routing statement, added an IrcPlugin monad.
2010-02-04 21:05:37 +01:00

29 lines
729 B
Haskell

module Plugins.Ping
( mainPing
) where
import Control.Concurrent.Chan
import Control.Monad.State
import Hsbot.IRCPlugin
import Hsbot.Types
-- | The plugin's main entry point
mainPing :: Chan BotMsg -> Chan BotMsg -> IO ()
mainPing serverChan chan = do
let plugin = PluginInstance "Ping" serverChan chan
(runStateT run plugin) `catch` (const $ return ((), plugin))
return ()
-- | The IrcPlugin monad main function
run :: IrcPlugin ()
run = forever $ do
msg <- readMsg
eval msg
where
eval :: BotMsg -> IrcPlugin ()
eval (InputMsg msg)
| (command msg) == "PING" = writeMsg $ OutputMsg $ IrcMsg Nothing "PONG" (parameters msg)
| otherwise = return ()
eval _ = return ()