]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.client: Send password on connect if provided
authorBruno Deferrari <utizoc@gmail.com>
Fri, 29 May 2009 03:01:22 +0000 (00:01 -0300)
committerBruno Deferrari <utizoc@gmail.com>
Fri, 29 May 2009 03:01:22 +0000 (00:01 -0300)
extra/irc/client/internals/internals-tests.factor
extra/irc/client/internals/internals.factor

index 2c26188e0450ad0446e04a24ab162b4aabe5121b..a591fe9ce0fcd8aab5fb8aaadcd7b44646d67d98 100644 (file)
@@ -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" <irc-profile> <irc-client>
+    [ 2drop <test-stream> ] >>connect
+    [
+        (connect-irc)
+        (do-login)
+        irc> stream>> out>> lines>>
+        (terminate-irc)
+    ] with-irc
+] unit-test
+
 ! Test join
 [ { "JOIN #factortest" } [
       "#factortest" %join %pop-output-line
index 0a4fe118309d36fd4de989220bff6142c3b5984b..1b4a4550dc5503547de2f9eed6434b483639e577 100644 (file)
@@ -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 ;