summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-04-11 23:08:24 +0200
committertv <tv@krebsco.de>2017-04-11 23:08:24 +0200
commit5b943bca6adad9941c1745acf9abff6ba0e080e1 (patch)
treedad46155f4c5fd15216bc5ff7025cad8294aa116
parente6d8b646d243a7110a8c58bcc0dd90a713472419 (diff)
soften nick, chan, server hostname and port
-rw-r--r--main.hs27
1 files changed, 21 insertions, 6 deletions
diff --git a/main.hs b/main.hs
index b178370..1dbec06 100644
--- a/main.hs
+++ b/main.hs
@@ -2,21 +2,36 @@
import Control.Monad (forever)
import Network (withSocketsDo, PortID(..), connectTo)
+import Network.Socket (HostName, PortNumber)
import System.IO (hSetBuffering, hSetNewlineMode, hPutStrLn, hClose, hGetLine, BufferMode(LineBuffering), universalNewlineMode, Handle)
import Control.Concurrent.Async (race)
import Control.Exception.Base (finally)
import Data.Text (isPrefixOf, pack, replace, unpack)
+
+nick :: String
+nick = "ni"
+
+chan :: String
+chan = "#retiolum"
+
+server_hostname :: HostName
+server_hostname = "ni.r"
+
+server_port :: PortNumber
+server_port = 6667;
+
+
main :: IO ()
main = withSocketsDo $ do
- h <- connectTo "ni.r" (PortNumber 6667)
+ h <- connectTo server_hostname (PortNumber server_port)
talk h `finally` hClose h
handshake :: Handle -> IO ()
handshake h = do
- hPutStrLn h "NICK test"
- hPutStrLn h "USER test * 0 :test"
- hPutStrLn h "JOIN #retiolum"
+ hPutStrLn h ("NICK " ++ nick)
+ hPutStrLn h ("USER " ++ nick ++ " * 0 :" ++ nick)
+ hPutStrLn h ("JOIN " ++ chan)
talk :: Handle -> IO ()
talk h = do
@@ -36,5 +51,5 @@ talk h = do
toServer = do
line <- getLine
case line of
- ":quit" -> do hPutStrLn h "/quit"; return "Quit"
- _ -> do hPutStrLn h ("PRIVMSG #retiolum :" ++ line); toServer
+ ":quit" -> do hPutStrLn h "/quit"; return ()
+ _ -> do hPutStrLn h ("PRIVMSG " ++ chan ++ " :" ++ line); toServer