Changeset 7099

Show
Ignore:
Timestamp:
02/24/08 17:34:50 (5 years ago)
Author:
woremacx
Message:

lang/perl/POE-Component-Client-Nowa: support reply

Location:
lang/perl/POE-Component-Client-Nowa/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/POE-Component-Client-Nowa/trunk/bin/nowa2ircd.pl

    r6621 r7099  
    9595    $heap->{channel_nicknames} = {}; 
    9696    $heap->{joined}    = 0; 
    97     $heap->{stack}     = []; 
    9897 
    9998    undef; 
     
    104103 
    105104    msg 'delay_nowa_recent'; 
    106     $heap->{nowa}->yield('recent'); 
     105    if ($heap->{joined}) { 
     106        $heap->{nowa}->yield('recent'); 
     107    } 
    107108} 
    108109 
     
    167168        } 
    168169    } 
    169     $kernel->delay('delay_nowa_recent', 1200); 
     170    $heap->{nowa}->{topics} = $res; 
     171    $kernel->delay('delay_nowa_channels', 1200); 
    170172} 
    171173 
     
    177179    return if $heap->{nicknames}->{$nick}; 
    178180    return if $nick eq $conf->{botname}; 
     181    $heap->{ircd}->yield(add_spoofed_nick => { nick => $nick }); 
    179182    if ($ch eq $conf->{channel}) { 
    180183        $heap->{joined} = 1; 
    181184        $heap->{nowa}->yield(update => 'hello, world') if $heap->{config}->{greeting}; 
    182185 
    183         for my $data (@{ $heap->{stack} }) { 
    184             $heap->{ircd}->yield(daemon_cmd_privmsg => $data->{name}, $conf->{channel}, $data->{text}); 
    185         } 
    186         $heap->{stack} = []; 
    187186        $kernel->delay('delay_nowa_recent', 5); 
    188187    } else { 
     
    220219    my $conf = $heap->{config}->{irc}; 
    221220 
    222     my $nick = ( $user =~ m/^(.*)!/)[0]; 
    223     unless ($channel eq $conf->{channel}) { 
    224         $text = "$channel $text"; 
    225     } 
    226     $heap->{nowa}->yield(update => $text); 
     221    my $status = { status => $text }; 
     222 
     223    if ($channel ne $conf->{channel}) { 
     224        $status->{status} = "$channel $status->{text}"; 
     225 
     226    } elsif ($text =~ /^[\@\>]([a-z0-9\-]+):?\s+(.+)$/i) { 
     227        my ($nick, $body) = (lc($1), $2); 
     228        my %cache = map { $_->{user} => $_->{id} } reverse( @{ $heap->{previous_recent} } ); 
     229 
     230        if ($cache{$nick}) { 
     231            $status = { 
     232                parent_id => $cache{$nick}, 
     233                status    => $body, 
     234            }; 
     235        } else { 
     236            $status->{status} = "$nick: $body", 
     237        } 
     238    } 
     239 
     240    $heap->{nowa}->yield(update => $status); 
    227241} 
    228242 
     
    248262            } 
    249263 
    250 #            next if $heap->{config}->{nowa}->{nowa_id} eq $name; 
    251             if ($heap->{joined}) { 
     264            if ($heap->{config}->{nowa}->{nowa_id} eq $name) { 
     265                $heap->{ircd}->yield(daemon_cmd_topic => $conf->{botname}, $conf->{channel}, $text); 
     266            } else { 
    252267                $heap->{ircd}->yield(daemon_cmd_privmsg => $name, $conf->{channel}, $text); 
    253             } else { 
    254                 push @{ $heap->{stack} }, { name => $name, text => $text } 
    255268            } 
    256269        } 
    257270 
    258271        $heap->{previous_recent} = $ret; 
     272 
     273    } else { 
     274        $heap->{previous_recent} = []; 
    259275    } 
    260276 
     
    285301            } 
    286302 
    287 #            next if $heap->{config}->{nowa}->{nowa_id} eq $name; 
    288             $heap->{ircd}->yield(daemon_cmd_privmsg => $name, $channel, $text); 
     303            if ($heap->{config}->{nowa}->{nowa_id} eq $name) { 
     304                $heap->{ircd}->yield(daemon_cmd_topic => $conf->{botname}, $channel, $text); 
     305            } else { 
     306                $heap->{ircd}->yield(daemon_cmd_privmsg => $name, $channel, $text); 
     307            } 
    289308        } 
    290309 
  • lang/perl/POE-Component-Client-Nowa/trunk/config.yaml-dist

    r5295 r7099  
    33  servername: nowa.localhost 
    44  serverport: 6667 
    5   botname: nowa 
     5  botname: '[nowa]' 
    66  nickname: woremacx 
    77  password: your-ircd-pass 
     
    1010 
    1111nowa: 
    12   retry: 300 
     12  retry: 180 
    1313  nowa_id: your-nowa-id 
    1414  password: your-nowa-pass 
     15  api_pass: your-nowa-api-pass 
    1516  greeting: 0