]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.client: Fix user quit notification
authorBruno Deferrari <utizoc@gmail.com>
Fri, 1 Aug 2008 22:59:18 +0000 (19:59 -0300)
committerBruno Deferrari <utizoc@gmail.com>
Fri, 1 Aug 2008 22:59:18 +0000 (19:59 -0300)
extra/irc/client/client-tests.factor
extra/irc/client/client.factor

index e021ff4ff4397683c9cdedc6d7b71242da54dd82..1b338df4429cc9cbca5cfd503269b17f8ffececb 100644 (file)
@@ -160,7 +160,7 @@ IN: irc.client.tests
     } cleave
     ] unit-test
 
-! Namelist notification
+! Namelist change notification
 { T{ participant-changed f f f } } [
     { ":ircserver.net 353 factorbot @ #factortest :@factorbot "
       ":ircserver.net 366 factorbot #factortest :End of /NAMES list." } make-client
@@ -172,4 +172,19 @@ IN: irc.client.tests
       [ listeners>> [ "#factortest" ] dip at [ read-message drop ] [ read-message ] bi ]
       [ terminate-irc ]
     } cleave
+    ] unit-test
+
+{ T{ participant-changed f "somedude" +part+ } } [
+    { ":somedude!n=user@isp.net QUIT" } make-client
+    { [ "factorbot" set-nick ]
+      [ listeners>>
+        [ "#factortest" [ <irc-channel-listener>
+                          H{ { "somedude" +normal+ } } clone >>participants ] keep
+        ] dip set-at ]
+      [ connect-irc ]
+      [ drop 0.1 seconds sleep ]
+      [ listeners>> [ "#factortest" ] dip at
+        [ read-message drop ] [ read-message drop ] [ read-message ] tri ]
+      [ terminate-irc ]
+    } cleave
     ] unit-test
\ No newline at end of file
index 813de0f57c44455e18eb0d0d471ce7c38f6ee8bc..99922b1fb5f175dd56174c8b748e6de67e918ff6 100644 (file)
@@ -88,10 +88,11 @@ SYMBOL: current-irc-client
 : irc-stream> ( -- stream ) irc> stream>> ;
 : irc-write ( s -- ) irc-stream> stream-write ;
 : irc-print ( s -- ) irc-stream> [ stream-print ] keep stream-flush ;
+: irc-send ( irc-message -- ) irc> out-messages>> mailbox-put ;
 : listener> ( name -- listener/f ) irc> listeners>> at ;
 
 : maybe-mailbox-get ( mailbox quot: ( irc-message -- ) -- )
-    [ dup mailbox-empty? [ drop yield ] ] dip '[ mailbox-get @ ] if ; inline
+    [ dup mailbox-empty? [ drop 0.1 sleep ] ] dip '[ mailbox-get @ ] if ; inline
 
 GENERIC: to-listener ( message obj -- )
 
@@ -147,24 +148,6 @@ DEFER: me?
     "JOIN " irc-write
     [ [ " :" ] dip 3append ] when* irc-print ;
 
-: /PART ( channel text -- )
-    [ "PART " irc-write irc-write ] dip
-    " :" irc-write irc-print ;
-
-: /KICK ( channel who -- )
-    [ "KICK " irc-write irc-write ] dip
-    " " irc-write irc-print ;
-
-: /PRIVMSG ( nick line -- )
-    [ "PRIVMSG " irc-write irc-write ] dip
-    " :" irc-write irc-print ;
-
-: /ACTION ( nick line -- )
-    [ 1 , "ACTION " % % 1 , ] "" make /PRIVMSG ;
-
-: /QUIT ( text -- )
-    "QUIT :" irc-write irc-print ;
-
 : /PONG ( text -- )
     "PONG " irc-write irc-print ;
 
@@ -240,10 +223,14 @@ M: kick handle-incoming-irc ( kick -- )
 M: quit handle-incoming-irc ( quit -- )
     [ dup prefix>> parse-name listeners-with-participant
       [ to-listener ] with each ]
-    [ prefix>> parse-name remove-participant-from-all ]
     [ handle-participant-change ]
+    [ prefix>> parse-name remove-participant-from-all ]
     tri ;
 
+! FIXME: implement this
+! M: mode handle-incoming-irc ( mode -- ) call-next-method ;
+! M: nick handle-incoming-irc ( nick -- ) call-next-method ;
+
 : >nick/mode ( string -- nick mode )
     dup first "+@" member? [ unclip ] [ 0 ] if participant-mode ;