-- Identify for the server

module Handlers.Identify
( handler
) where

import Network.Socket
import Request

defaultIdent = "ShrubBot"
defaultNick = "ShrubBot"
defaultRealName = "Mr. Shrubbery"

identify :: EventHandler
identify (Just sender, _, ["AUTH", "*** Checking Ident"]) botState = do
  putStrLn "Identifying with server and setting nick"
  send socket (formatRequest (Nothing, "USER", [defaultIdent, defaultNick, "*", defaultRealName]))
  send socket (formatRequest (Nothing, "NICK", [defaultNick]))
  return (botState {botNick = defaultNick, botIdent = defaultIdent, botRealName = defaultRealName, botIdentified = True})
  where socket = botSocket botState
identify _ botState = return botState

handler = identify
          
