Changeset 416241f
- Timestamp:
- Dec 28, 2009, 12:25:00 AM (15 years ago)
- Branches:
- master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 85fa6e4
- Parents:
- 3acab0e
- git-author:
- Nelson Elhage <nelhage@mit.edu> (12/23/09 12:28:51)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (12/28/09 00:25:00)
- Location:
- perl/modules/IRC/lib/BarnOwl/Module
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r54b4a87 r416241f 161 161 with C<CHANNEL_ARG>. 162 162 163 =item C<ALLOW_DISCONNECTED> 164 165 C<IRC-CONNECTION> may be a disconnected connection object that is 166 currently pending a reconnect. 167 163 168 =back 164 169 … … 167 172 use constant CHANNEL_ARG => 1; 168 173 use constant CHANNEL_OPTIONAL => 2; 174 175 use constant ALLOW_DISCONNECTED => 4; 169 176 170 177 sub register_commands { … … 195 202 196 203 BarnOwl::new_command( 197 'irc-disconnect' => mk_irc_command( \&cmd_disconnect ),204 'irc-disconnect' => mk_irc_command( \&cmd_disconnect, ALLOW_DISCONNECTED ), 198 205 { 199 206 summary => 'Disconnect from an IRC server', … … 421 428 my $cmd = shift; 422 429 my $conn = shift; 423 $conn->conn->disconnect; 424 return; 430 if ($conn->conn->connected) { 431 $conn->conn->disconnect; 432 } elsif ($reconnect{$conn->alias}) { 433 BarnOwl::admin_message('IRC', 434 "[" . $conn->alias . "] Reconnect cancelled"); 435 $conn->cancel_reconnect; 436 } 425 437 } 426 438 … … 589 601 590 602 if(defined($alias)) { 591 $conn = get_connection_by_alias($alias); 603 $conn = get_connection_by_alias($alias, 604 $flags & ALLOW_DISCONNECTED); 592 605 } 593 606 if($flags & CHANNEL_ARG) { … … 612 625 if(!$conn) { 613 626 if($m && $m->type eq 'IRC') { 614 $conn = get_connection_by_alias($m->network); 627 $conn = get_connection_by_alias($m->network, 628 $flags & ALLOW_DISCONNECTED); 615 629 } 616 630 } … … 631 645 sub get_connection_by_alias { 632 646 my $key = shift; 633 die("No such ircnet: $key\n") unless exists $ircnets{$key}; 634 return $ircnets{$key}; 647 my $allow_disconnected = shift; 648 649 return $ircnets{$key} if exists $ircnets{$key}; 650 return $reconnect{$key} if $allow_disconnected && exists $reconnect{$key}; 651 die("No such ircnet: $key\n") 635 652 } 636 653 -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
r3acab0e r416241f 328 328 } 329 329 330 sub cancel_reconnect { 331 my $self = shift; 332 delete $BarnOwl::Module::IRC::reconnect{$self->alias}; 333 delete $self->{reconnect_timer}; 334 } 335 330 336 sub connected { 331 337 my $self = shift; 332 338 my $msg = shift; 333 339 BarnOwl::admin_message("IRC", $msg); 334 delete $BarnOwl::Module::IRC::reconnect{$self->alias}; 335 delete $self->{reconnect_timer}; 340 $self->cancel_reconnect; 336 341 $BarnOwl::Module::IRC::ircnets{$self->alias} = $self; 337 342 my $fd = $self->getSocket()->fileno();
Note: See TracChangeset
for help on using the changeset viewer.