summaryrefslogtreecommitdiff
path: root/Hsbot/IRC.hs
diff options
context:
space:
mode:
authorJulien Dessaux2009-08-07 00:19:14 +0200
committerJulien Dessaux2009-08-07 00:19:14 +0200
commit14f87adb8b3cfc019b7de7f082e3851a91b6a364 (patch)
tree6860704ec357ebcba4518cfd354a880907073800 /Hsbot/IRC.hs
parentRefactored some minor stuff (diff)
downloadhsbot-14f87adb8b3cfc019b7de7f082e3851a91b6a364.tar.gz
hsbot-14f87adb8b3cfc019b7de7f082e3851a91b6a364.tar.bz2
hsbot-14f87adb8b3cfc019b7de7f082e3851a91b6a364.zip
Wrote the ping pong stuff
Diffstat (limited to '')
-rw-r--r--Hsbot/IRC.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Hsbot/IRC.hs b/Hsbot/IRC.hs
index d397456..cd6b7b8 100644
--- a/Hsbot/IRC.hs
+++ b/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)
+