Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

81 Zeilen
2.4KB

  1. module IrcBot.BotNetworkCommands where
  2. import IrcBot.BotNetwork (writeToSocket)
  3. import Network.Socket hiding (send, sendTo, recv, recvFrom)
  4. import Network.Connection
  5. import Data.List.Utils (replace)
  6. sendMessage :: Connection -> String -> String -> IO ()
  7. sendMessage sock targetChannel stringData =
  8. do
  9. -- print "SENT STRING: "
  10. -- print combiendStringData
  11. writeToSocket sock (prepareSendMessage targetChannel stringData)
  12. prepareSendMessage :: String -> String -> String
  13. prepareSendMessage targetChannel stringData = "PRIVMSG " ++ targetChannel ++ " :" ++ stringData
  14. quitFromServer :: Connection -> String -> IO ()
  15. quitFromServer sock targetChannel =
  16. do
  17. writeToSocket sock prepareQuit
  18. prepareQuit :: String
  19. prepareQuit = "QUIT"
  20. disconnectFromChannel :: Connection -> String -> IO ()
  21. disconnectFromChannel sock targetChannel =
  22. do
  23. writeToSocket sock (prepareDisconnectFromChannel targetChannel)
  24. prepareDisconnectFromChannel :: String -> String
  25. prepareDisconnectFromChannel targetChannel = ("PART " ++ targetChannel)
  26. initAuthNickServ :: Connection -> String -> String -> IO()
  27. initAuthNickServ sock userName password =
  28. do
  29. sendMessage sock "NickServ" (prepareInitAuthNickServ userName password)
  30. prepareInitAuthNickServ :: String -> String -> String
  31. prepareInitAuthNickServ userName password = "IDENTIFY " ++ userName ++ " " ++ password
  32. initBotName :: Connection -> String -> IO ()
  33. initBotName sock botName = writeToSocket sock (prepareInitBotName botName)
  34. prepareInitBotName :: String -> String
  35. prepareInitBotName botName = "USER "++ botName ++" "++ botName ++" "++ botName ++" :learning purpose bot"
  36. initBotNick :: Connection -> String -> IO ()
  37. initBotNick sock botNick =
  38. do
  39. writeToSocket sock (preparetInitBotNick botNick)
  40. preparetInitBotNick :: String -> String
  41. preparetInitBotNick botNick = "NICK " ++ botNick
  42. joinChannel :: Connection -> String -> IO ()
  43. joinChannel sock channelName =
  44. do
  45. writeToSocket sock (prepareJoinChannel channelName)
  46. prepareJoinChannel :: String -> String
  47. prepareJoinChannel channelName = "JOIN " ++ channelName
  48. pong :: Connection -> String -> IO ()
  49. pong sock receivedStringData = do
  50. writeToSocket sock (preparePong receivedStringData)
  51. preparePong :: String -> String
  52. preparePong receivedStringData = replace "PING" "PONG" receivedStringData