summaryrefslogtreecommitdiff
path: root/Plugins/Ping.hs
blob: 46351aa1673f62b0bc2e4c4a7a85a46aaf25029f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Plugins.Ping
    ( mainPing
    ) where

import Control.Concurrent.Chan

import Hsbot.Types

mainPing :: Chan BotMsg -> Chan BotMsg -> IO ()
mainPing serverChan chan = do
    loop
    where
        loop = do
            input <- readChan chan
            eval input
            loop
        eval :: BotMsg -> IO ()
        eval (InputMsg msg)
            | (command msg) == "PING" = writeChan serverChan $ OutputMsg $ IrcMsg Nothing "PONG" (parameters msg)
            | otherwise = return ()
        eval _ = return ()