|
- module IrcBot.BotNetworkCommands where
-
- import IrcBot.BotNetwork (writeToSocket)
- import Network.Socket hiding (send, sendTo, recv, recvFrom)
- import Network.Connection
- import Data.List.Utils (replace)
-
- sendMessage :: Connection -> String -> String -> IO ()
- sendMessage sock targetChannel stringData =
- do
- -- print "SENT STRING: "
- -- print combiendStringData
- writeToSocket sock (prepareSendMessage targetChannel stringData)
-
-
- prepareSendMessage :: String -> String -> String
- prepareSendMessage targetChannel stringData = "PRIVMSG " ++ targetChannel ++ " :" ++ stringData
-
-
-
- quitFromServer :: Connection -> String -> IO ()
-
- quitFromServer sock targetChannel =
- do
- writeToSocket sock prepareQuit
-
- prepareQuit :: String
- prepareQuit = "QUIT"
-
-
- disconnectFromChannel :: Connection -> String -> IO ()
- disconnectFromChannel sock targetChannel =
- do
- writeToSocket sock (prepareDisconnectFromChannel targetChannel)
-
-
- prepareDisconnectFromChannel :: String -> String
- prepareDisconnectFromChannel targetChannel = ("PART " ++ targetChannel)
-
-
- initAuthNickServ :: Connection -> String -> String -> IO()
- initAuthNickServ sock userName password =
- do
- sendMessage sock "NickServ" (prepareInitAuthNickServ userName password)
-
-
- prepareInitAuthNickServ :: String -> String -> String
- prepareInitAuthNickServ userName password = "IDENTIFY " ++ userName ++ " " ++ password
-
- initBotName :: Connection -> String -> IO ()
- initBotName sock botName = writeToSocket sock (prepareInitBotName botName)
-
-
- prepareInitBotName :: String -> String
- prepareInitBotName botName = "USER "++ botName ++" "++ botName ++" "++ botName ++" :learning purpose bot"
-
- initBotNick :: Connection -> String -> IO ()
- initBotNick sock botNick =
- do
- writeToSocket sock (preparetInitBotNick botNick)
-
-
- preparetInitBotNick :: String -> String
- preparetInitBotNick botNick = "NICK " ++ botNick
-
-
- joinChannel :: Connection -> String -> IO ()
- joinChannel sock channelName =
- do
- writeToSocket sock (prepareJoinChannel channelName)
-
- prepareJoinChannel :: String -> String
- prepareJoinChannel channelName = "JOIN " ++ channelName
-
-
- pong :: Connection -> String -> IO ()
- pong sock receivedStringData = do
- writeToSocket sock (preparePong receivedStringData)
-
- preparePong :: String -> String
- preparePong receivedStringData = replace "PING" "PONG" receivedStringData
|