Wrote the ping pong stuff
This commit is contained in:
parent
2f270f8bdf
commit
14f87adb8b
3 changed files with 28 additions and 2 deletions
11
Hsbot/IRC.hs
11
Hsbot/IRC.hs
|
@ -4,9 +4,12 @@ module Hsbot.IRC
|
|||
, connectServer
|
||||
, initServer
|
||||
, parseIrcMsg
|
||||
, ping
|
||||
, pong
|
||||
)where
|
||||
|
||||
import Control.Monad
|
||||
import Data.List(isPrefixOf)
|
||||
import Network
|
||||
import qualified Network.IRC as IRC
|
||||
import System.IO
|
||||
|
@ -56,3 +59,11 @@ initServer (server, handle) = do
|
|||
mapM_ (sendstr handle . IRC.encode . IRC.joinChan) (channels server)
|
||||
return ()
|
||||
|
||||
-- | Check if a message is a PING
|
||||
ping :: String -> Bool
|
||||
ping = isPrefixOf "PING :"
|
||||
|
||||
-- | Send a pong message given a ping message
|
||||
pong :: Handle -> String -> IO ()
|
||||
pong handle str = sendstr handle $ "PONG " ++ (drop 5 str)
|
||||
|
||||
|
|
Reference in a new issue