Changeset dace02a for perl/modules


Ignore:
Timestamp:
Apr 3, 2011, 3:06:02 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
ab6d8f0
Parents:
b9a642a
git-author:
Nelson Elhage <nelhage@mit.edu> (03/12/11 11:41:48)
git-committer:
Nelson Elhage <nelhage@mit.edu> (04/03/11 15:06:02)
Message:
Use AnyEvent::IRC::Client's channel tracking, instead our own.
Location:
perl/modules/IRC/lib/BarnOwl/Module
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r3713b86 rdace02a  
    3030# Hash alias -> BarnOwl::Module::IRC::Connection object
    3131our %ircnets;
    32 our %channels;
    3332
    3433sub startup {
     
    9695        $list .= "\n";
    9796
    98         for my $chan (keys %channels) {
    99             next unless grep $_ eq $conn, @{$channels{$chan}};
     97        for my $chan (keys %{$conn->conn->{channel_list}}) {
    10098            $list .= "  $chan\n";
    10199        }
     
    466464    my $conn = shift;
    467465    my $chan = shift or die("Usage: $cmd channel\n");
    468     $channels{$chan} ||= [];
    469     push @{$channels{$chan}}, $conn;
    470466    $conn->conn->send_msg(join => $chan, @_);
    471467    return;
     
    476472    my $conn = shift;
    477473    my $chan = shift;
    478     $channels{$chan} = [grep {$_ ne $conn} @{$channels{$chan} || []}];
    479474    $conn->conn->send_msg(part => $chan);
    480475    return;
     
    557552########################### Utilities/Helpers ##################################
    558553################################################################################
     554
     555sub find_channel {
     556    my $channel = shift;
     557    my @found;
     558    for my $conn (values %ircnets) {
     559        if($conn->conn->{channel_list}{lc $channel}) {
     560            push @found, $conn;
     561        }
     562    }
     563    return $found[0] if(scalar @found == 1);
     564}
    559565
    560566sub mk_irc_command {
     
    580586            $channel = $ARGV[0];
    581587            if(defined($channel) && $channel =~ /^#/) {
    582                 if($channels{$channel} && @{$channels{$channel}} == 1) {
     588                if(my $c = find_channel($channel)) {
    583589                    shift @ARGV;
    584                     $conn = $channels{$channel}[0] unless $conn;
     590                    $conn ||= $c;
    585591                }
    586592            } elsif ($m && $m->type eq 'IRC' && !$m->is_private) {
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Completion.pm

    r955a36e rdace02a  
    1111sub complete_networks { keys %BarnOwl::Module::IRC::ircnets }
    1212sub complete_dests    { keys %users, complete_channels() }
    13 sub complete_channels { keys %BarnOwl::Module::IRC::channels }
     13sub complete_channels {
     14    my %channels;
     15    for my $conn (values %BarnOwl::Module::IRC::ircnets) {
     16        for my $chan (keys %{$conn->conn->{channel_list}}) {
     17            $channels{$chan} = 1;
     18        }
     19    }
     20    return keys %channels;
     21}
    1422sub complete_nicks    { keys %users }
    1523sub complete_servers  { keys %servers }
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    rb9a642a rdace02a  
    452452    my $backoff = shift;
    453453
    454     $self->autoconnect_channels([keys(%{$self->channel_list})]);
     454    $self->autoconnect_channels([keys(%{$self->{channel_list}})]);
    455455    $self->conn->connect;
    456456    if ($self->conn->connected) {
Note: See TracChangeset for help on using the changeset viewer.