Ignore:
Timestamp:
Mar 30, 2013, 7:37:11 PM (8 years ago)
Author:
William Throwe <wtt6@cornell.edu>
Children:
55758dc
Parents:
0a6a2d6
git-author:
William Throwe <wtt6@cornell.edu> (03/30/13 19:16:22)
git-committer:
William Throwe <wtt6@cornell.edu> (03/30/13 19:37:11)
Message:
Make the -a option to irc-msg more optional

The code now tries to determine the alias from the #channel argument
if one is provided.
File:
1 edited

Legend:

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

    rb8a3e00 r8a22ff2  
    134134with C<CHANNEL_ARG>.
    135135
     136=item C<CHANNEL_EXPLICIT>
     137
     138Do not determine the channel from the current message. Only relevant
     139with C<CHANNEL_ARG>.
     140
    136141=item C<ALLOW_DISCONNECTED>
    137142
     
    145150use constant CHANNEL_ARG        => 1;
    146151use constant CHANNEL_OPTIONAL   => 2;
    147 
    148 use constant ALLOW_DISCONNECTED => 4;
     152use constant CHANNEL_EXPLICIT   => 4;
     153
     154use constant ALLOW_DISCONNECTED => 8;
    149155
    150156sub register_commands {
     
    188194
    189195    BarnOwl::new_command(
    190         'irc-msg' => mk_irc_command( \&cmd_msg ),
     196        'irc-msg' => mk_irc_command( \&cmd_msg, CHANNEL_ARG|CHANNEL_OPTIONAL|CHANNEL_EXPLICIT ),
    191197        {
    192198            summary => 'Send an IRC message',
    193             usage   => 'irc-msg [-a ALIAS] DESTINATION MESSAGE',
     199            usage   => 'irc-msg [-a ALIAS] DESTINATION [MESSAGE]',
    194200
    195201            description => <<END_DESCR
     
    407413    my $cmd  = shift;
    408414    my $conn = shift;
    409     my $to = shift or die("Usage: $cmd [NICK|CHANNEL]\n");
     415    my $to = shift || shift or die("Usage: $cmd [NICK|CHANNEL]\n");
    410416    # handle multiple recipients?
    411417    if(@_) {
     
    587593            $channel = $ARGV[0];
    588594            if(defined($channel) && $channel =~ /^#/) {
     595                shift @ARGV;
    589596                if(my $c = find_channel($channel)) {
    590                     shift @ARGV;
    591597                    $conn ||= $c;
    592598                }
    593             } elsif ($m && $m->type eq 'IRC' && !$m->is_private) {
     599            } elsif (!($flags & CHANNEL_EXPLICIT) &&
     600                     $m && $m->type eq 'IRC' && !$m->is_private) {
    594601                $channel = $m->channel;
    595602            } else {
Note: See TracChangeset for help on using the changeset viewer.