Added password support
This commit is contained in:
parent
7e2179f3d8
commit
0b84c0c837
@ -2,6 +2,7 @@ server = "irc.freenode.net"
|
|||||||
port = 6667
|
port = 6667
|
||||||
channel = "#testtesttest"
|
channel = "#testtesttest"
|
||||||
nick = "haskman"
|
nick = "haskman"
|
||||||
|
password = "xxxsss"
|
||||||
timeout = 130
|
timeout = 130
|
||||||
msghandlers = ["greeter", "welcomer", "messagelogger", "songsearch", "auth", "nicktracker", "tell"]
|
msghandlers = ["greeter", "welcomer", "messagelogger", "songsearch", "auth", "nicktracker", "tell"]
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ module Network.IRC.Bot
|
|||||||
, messageProcessLoop )
|
, messageProcessLoop )
|
||||||
where
|
where
|
||||||
|
|
||||||
|
import qualified Data.Configurator as CF
|
||||||
import qualified Data.Text.Format as TF
|
import qualified Data.Text.Format as TF
|
||||||
import qualified System.Log.Logger as HSL
|
import qualified System.Log.Logger as HSL
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ messageProcessLoop = go 0
|
|||||||
status <- get
|
status <- get
|
||||||
Bot { .. } <- ask
|
Bot { .. } <- ask
|
||||||
let nick = botNick botConfig
|
let nick = botNick botConfig
|
||||||
|
mpass <- io $ CF.lookup (config botConfig) "password"
|
||||||
|
|
||||||
nStatus <- io . mask_ $
|
nStatus <- io . mask_ $
|
||||||
if idleFor >= (oneSec * botTimeout botConfig)
|
if idleFor >= (oneSec * botTimeout botConfig)
|
||||||
@ -101,7 +103,7 @@ messageProcessLoop = go 0
|
|||||||
Timeout -> newMessage IdleMsg >>= sendMessage messageChan >> return Idle
|
Timeout -> newMessage IdleMsg >>= sendMessage messageChan >> return Idle
|
||||||
EOD -> infoM "Connection closed" >> return Disconnected
|
EOD -> infoM "Connection closed" >> return Disconnected
|
||||||
Msg (msg@Message { .. }) -> do
|
Msg (msg@Message { .. }) -> do
|
||||||
nStatus <- handleMsg nick message
|
nStatus <- handleMsg nick message mpass
|
||||||
sendMessage messageChan msg
|
sendMessage messageChan msg
|
||||||
return nStatus
|
return nStatus
|
||||||
|
|
||||||
@ -113,14 +115,18 @@ messageProcessLoop = go 0
|
|||||||
_ -> go 0 inChan messageChan
|
_ -> go 0 inChan messageChan
|
||||||
|
|
||||||
where
|
where
|
||||||
handleMsg nick message
|
handleMsg nick message mpass
|
||||||
| Just (JoinMsg user) <- fromMessage message, userNick user == nick =
|
| Just (JoinMsg user) <- fromMessage message, userNick user == nick =
|
||||||
infoM "Joined" >> return Joined
|
infoM "Joined" >> return Joined
|
||||||
| Just (KickMsg { .. }) <- fromMessage message, kickedNick == nick =
|
| Just (KickMsg { .. }) <- fromMessage message, kickedNick == nick =
|
||||||
infoM "Kicked" >> return Kicked
|
infoM "Kicked" >> return Kicked
|
||||||
| Just NickInUseMsg <- fromMessage message =
|
| Just NickInUseMsg <- fromMessage message =
|
||||||
infoM "Nick already in use" >> return NickNotAvailable
|
infoM "Nick already in use" >> return NickNotAvailable
|
||||||
| Just (ModeMsg { .. }) <- fromMessage message, modeUser == Self =
|
| Just (ModeMsg { .. }) <- fromMessage message, modeUser == Self = do
|
||||||
newMessage JoinCmd >>= sendMessage messageChan >> return Connected
|
whenJust mpass $ \pass -> do
|
||||||
|
msg <- newMessage $ PrivMsgReply (User (Nick "NickServ") "") $ "IDENTIFY " ++ pass
|
||||||
|
sendMessage messageChan msg
|
||||||
|
newMessage JoinCmd >>= sendMessage messageChan
|
||||||
|
return Connected
|
||||||
| otherwise =
|
| otherwise =
|
||||||
return Connected
|
return Connected
|
||||||
|
Loading…
Reference in New Issue
Block a user