From e3a8421f445a0a676c28a228306cd46e0b52b811 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Fri, 29 May 2009 00:01:22 -0300 Subject: [PATCH] irc.client: Send password on connect if provided --- extra/irc/client/internals/internals-tests.factor | 12 ++++++++++++ extra/irc/client/internals/internals.factor | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/extra/irc/client/internals/internals-tests.factor b/extra/irc/client/internals/internals-tests.factor index 2c26188e04..a591fe9ce0 100644 --- a/extra/irc/client/internals/internals-tests.factor +++ b/extra/irc/client/internals/internals-tests.factor @@ -85,6 +85,18 @@ M: mb-writer dispose drop ; ] with-irc ] unit-test +! Test connect with password +{ V{ "PASS password" "NICK factorbot" "USER factorbot hostname servername :irc.factor" } } [ + "someserver" irc-port "factorbot" "password" + [ 2drop ] >>connect + [ + (connect-irc) + (do-login) + irc> stream>> out>> lines>> + (terminate-irc) + ] with-irc +] unit-test + ! Test join [ { "JOIN #factortest" } [ "#factortest" %join %pop-output-line diff --git a/extra/irc/client/internals/internals.factor b/extra/irc/client/internals/internals.factor index 0a4fe11830..1b4a4550dc 100644 --- a/extra/irc/client/internals/internals.factor +++ b/extra/irc/client/internals/internals.factor @@ -16,6 +16,7 @@ IN: irc.client.internals : /NICK ( nick -- ) "NICK " prepend irc-print ; : /PONG ( text -- ) "PONG " prepend irc-print ; +: /PASS ( password -- ) "PASS " prepend irc-print ; : /LOGIN ( nick -- ) dup /NICK @@ -44,7 +45,11 @@ IN: irc.client.internals in-messages>> [ irc-connected ] dip mailbox-put ] [ (terminate-irc) ] if* ; -: (do-login) ( -- ) irc> nick>> /LOGIN ; +: (do-login) ( -- ) + irc> + [ profile>> password>> [ /PASS ] when* ] + [ nick>> /LOGIN ] + bi ; GENERIC: initialize-chat ( chat -- ) M: irc-chat initialize-chat drop ;