Changeset 6858d2d for perl


Ignore:
Timestamp:
Jan 9, 2008, 11:14:20 PM (13 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
47b6a5f
Parents:
6286f26
git-author:
Nelson Elhage <nelhage@mit.edu> (01/09/08 23:13:52)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/09/08 23:14:20)
Message:
Implement /part and /names. We don't parse the /names response yet
File:
1 edited

Legend:

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

    r6286f26 r6858d2d  
    6464    BarnOwl::new_command('irc-disconnect' => \&cmd_disconnect);
    6565    BarnOwl::new_command('irc-msg'     => \&cmd_msg);
    66     BarnOwl::new_command('irc-join' => \&cmd_join);
    67     BarnOwl::new_command('irc-nick' => \&cmd_nick);
     66    BarnOwl::new_command('irc-join'    => \&cmd_join);
     67    BarnOwl::new_command('irc-part'    => \&cmd_part);
     68    BarnOwl::new_command('irc-nick'    => \&cmd_nick);
     69    BarnOwl::new_command('irc-names'   => \&cmd_names);
    6870}
    6971
     
    148150    my $msg = BarnOwl::Message->new(
    149151        type        => 'IRC',
    150         direction   => 'out',
     152        direction   => is_private($to) ? 'out' : 'in',
    151153        server      => $conn->server,
    152154        network     => $conn->alias,
     
    169171}
    170172
     173sub cmd_part {
     174    my $cmd = shift;
     175    my $conn = get_connection(\@_);
     176    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>");
     177    $conn->part($chan);
     178}
     179
    171180sub cmd_nick {
    172181    my $cmd = shift;
     
    174183    my $nick = shift or die("Usage: $cmd <new nick>");
    175184    $conn->nick($nick);
     185}
     186
     187sub cmd_names {
     188    my $cmd = shift;
     189    my $conn = get_connection(\@_);
     190    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>");
     191    $conn->names($chan);
    176192}
    177193
     
    196212}
    197213
     214sub get_channel {
     215    my $args = shift;
     216    if(scalar @$args) {
     217        return shift @$args;
     218    }
     219    my $m = BarnOwl::getcurmsg();
     220    if($m && $m->type eq 'IRC') {
     221        return $m->channel if !$m->is_private;
     222    }
     223    return undef;
     224}
     225
    198226sub get_connection_by_alias {
    199227    my $key = shift;
Note: See TracChangeset for help on using the changeset viewer.