Show
Ignore:
Timestamp:
05/10/05 20:44:16 (4 years ago)
Author:
iblech
svk:copy_cache_prev:
4498
Message:

Net::IRC now tracks the topic of the channels joined, the users inside it, etc.
(but the code is still commented out, because of some (already tested for) bugs
in Pugs).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ext/Net-IRC/lib/Net/IRC.pm

    r2918 r2939  
    6868 
    6969  # Default (passive) handlers 
     70  # First event we get, indicating a successful login 
    7071  %handler<001> = [-> $event { 
    7172    $inside++; 
     
    7879    debug "Logged in to \"$servername\" as \"$curnick\"."; 
    7980  }]; 
     81 
     82  # Nick already used, so we permute our nick. 
    8083  %handler<433> = [-> $event { 
    8184    if $in_login_phase { 
     
    8386    } 
    8487  }]; 
     88 
     89  # /WHO (we /WHO ourselves so we can provide accurate username, hostname, and 
     90  # ircname information.) 
    8591  %handler<352> = [-> $event { 
    8692    my %rest; 
     
    9298    } 
    9399  }]; 
     100 
     101  # The topic of a chan. 
     102  %handler<332> = [-> $event { 
     103    my ($chan, $topic) = split " ", $event<rest>; 
     104    $topic = strip_colon($topic); 
     105 
     106    # %channels{normalize $chan}<topic> = $topic; 
     107  }]; 
     108  %handler<TOPIC> = [-> $event { 
     109    # %channels{normalize $event<object>}<topic> = $event<rest>; 
     110  }]; 
     111 
     112  # We track our status, especially the channels we've joined. 
    94113  %handler<JOIN> = [-> $event { 
    95114    if(normalize($event<from_nick>) eq normalize($curnick)) { 
     
    172191    channel       => -> Str $channel { %channels{normalize $channel} }, 
    173192 
    174     # Handler register methods 
     193    # Main handler register method 
    175194    add_handler => -> Str $code, Code $cb { %handler{$code}.push($cb) }, 
    176195 
     
    196215        debug "Disconnecting from $host:$port... "; 
    197216        try { $hdl.close } 
     217        # We want to have a sane state when we connect next time. 
    198218        $connected      = 0; 
    199219        $inside         = 0; 
     
    219239      if($connected) { 
    220240        $queue<enqueue>({ 
     241          # Indicate that we're currently logging in, so our nick_already_used 
     242          # handler can choose a different nick. $in_login_phase is reset to 0 
     243          # when we're successfully logged in. 
    221244          $in_login_phase++; 
    222245          $say("NICK {$nickgen<next>()}"); 
     
    241264      $line ~~ s:P5/[\015\012]*$//; # Hack to remove all "\r\n"s 
    242265      debug_recv $line if $debug_raw; 
     266      # We record the time the last traffic from the server was seen, so we can 
     267      # autoping the server if needed. 
    243268      $last_traffic = time; 
    244269 
     
    287312    }, 
    288313 
     314    # Handle pseudo events (runloop, loggedin) 
    289315    handle_pseudo => -> Str $pseudo, *@args { 
    290316      my $event = {