Add "PART" command as compliment to JOIN, along with corresponding support in the...
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 29 Aug 2007 21:39:53 +0000 (21:39 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 29 Aug 2007 21:39:53 +0000 (21:39 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@8 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml
irc.pl

index e68d11b..1d88461 100644 (file)
@@ -848,6 +848,17 @@ JOIN: |-
     }
   }
 
+PART: |-
+  sub {
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    if( $what =~ /^[#&][^ ,]+$/ ) {
+      $kernel->post( "mod_irc", "do_part", $what );
+      $kernel->post( $src, $replypath, "Okay.", $dest );
+    } else {
+      $kernel->post( $src, $replypath, "'$what' is not a valid channel name.", $dest );
+    }
+  }
+
 IGNORE: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
diff --git a/irc.pl b/irc.pl
index 87f598b..55f9ac0 100644 (file)
--- a/irc.pl
+++ b/irc.pl
@@ -53,6 +53,7 @@ sub new {
                        send_public_to => \&send_public_to,
                        do_abort        => \&do_abort,
                        do_join         => \&do_join,
+                       do_part         => \&do_part,
                        do_mode         => \&do_mode,
                        watchdog => \&watchdog,
                },
@@ -75,6 +76,15 @@ sub do_join {
        }
 }
 
+sub do_part {
+       my( $kernel, $heap, $what ) = @_[ KERNEL, HEAP, ARG0 ];
+       if( $what =~ /^[#&][^ ,]+$/ ) {
+               $kernel->post( $heap->{ 'ircobject' }->session_id(), "part", $what );
+       } else {
+               warn( "'$what' is an invalid channel name" );
+       }
+}
+
 sub do_abort {
        my( $kernel, $heap ) = @_[ KERNEL, HEAP ];
        $heap->{ 'ircobject' }->{ 'send_queue' } = [];