Changeset f094fc4


Ignore:
Timestamp:
May 5, 2008, 2:56:52 PM (16 years ago)
Author:
Geoffrey Thomas <geofft@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
8df6cbb
Parents:
811ad93
Message:
IRC: /list, /who, and /stats commands
File:
1 edited

Legend:

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

    r919535f rf094fc4  
    114114    BarnOwl::new_command('irc-whois'      => \&cmd_whois);
    115115    BarnOwl::new_command('irc-motd'       => \&cmd_motd);
     116    BarnOwl::new_command('irc-list'       => \&cmd_list);
     117    BarnOwl::new_command('irc-who'        => \&cmd_who);
     118    BarnOwl::new_command('irc-stats'      => \&cmd_stats);
    116119}
    117120
     
    146149        $host = shift @ARGV or die("Usage: $cmd HOST\n");
    147150        if(!$alias) {
    148             if($host =~ /^(?:irc[.])?(\w+)[.]\w+$/) {
     151            if($host =~ /^(?:irc[.])?([\w-]+)[.]\w+$/) {
    149152                $alias = $1;
    150153            } else {
     
    152155            }
    153156        }
    154         $port = shift @ARGV || 6667;
    155157        $ssl ||= 0;
     158        $port = shift @ARGV || ($ssl ? 6697 : 6667);
    156159    }
    157160
     
    275278}
    276279
     280sub cmd_list {
     281    my $cmd = shift;
     282    my $message = BarnOwl::Style::boldify('Current IRC networks:') . "\n";
     283    while (my ($alias, $conn) = each %ircnets) {
     284        $message .= '  ' . $alias . ' => ' . $conn->nick . '@' . $conn->server . "\n";
     285    }
     286    BarnOwl::popless_ztext($message);
     287}
     288
     289sub cmd_who {
     290    my $cmd = shift;
     291    my $conn = get_connection(\@_);
     292    my $who = shift || die("Usage: $cmd <user>\n");
     293    $conn->conn->who($who);
     294}
     295
     296sub cmd_stats {
     297    my $cmd = shift;
     298    my $conn = get_connection(\@_);
     299    my $type = shift || die("Usage: $cmd <chiklmouy> [server] \n");
     300    $conn->conn->stats($type, @_);
     301}
     302
    277303################################################################################
    278304########################### Utilities/Helpers ##################################
Note: See TracChangeset for help on using the changeset viewer.