summaryrefslogtreecommitdiffstats
path: root/Hirc/Format.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-10-17 19:08:15 +0200
committertv <tv@shackspace.de>2015-10-17 19:25:29 +0200
commitef344c57945d455c6752c2032c701d7f9315f69b (patch)
tree21139cf0cd844eb661e80978c04f91de48b93907 /Hirc/Format.hs
parent3a2775bc5bd132109c8cfbd84b11a1e7cf633311 (diff)
replace hirc.hs by main.hs
Diffstat (limited to 'Hirc/Format.hs')
-rw-r--r--Hirc/Format.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Hirc/Format.hs b/Hirc/Format.hs
new file mode 100644
index 0000000..bf6546a
--- /dev/null
+++ b/Hirc/Format.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE RecordWildCards #-}
+module Hirc.Format where
+
+import Hirc.Types
+
+formatMessage :: Message -> String
+formatMessage Message{..} =
+ maybe "" prefix m_prefix ++ m_command ++ params
+ where
+ prefix Prefix{..} =
+ ":" ++ p_name ++ maybe "" user p_user ++ maybe "" host p_host ++ " "
+ user x = "!" ++ x
+ host x = "@" ++ x
+ params = concatMap (" "++) (init m_params) ++ " :" ++ last m_params