Changeset 2c40dc0 for perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
- Timestamp:
- Jan 8, 2008, 11:24:09 PM (17 years ago)
- 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:
- 0e52069
- Parents:
- c0f9e30
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
rb38b0b2 r2c40dc0 6 6 =head1 NAME 7 7 8 BarnOwl::Module:: Jabber8 BarnOwl::Module::IRC 9 9 10 10 =head1 DESCRIPTION 11 11 12 This module implements Jabbersupport for barnowl.12 This module implements IRC support for barnowl. 13 13 14 14 =cut … … 22 22 use Getopt::Long; 23 23 24 our $VERSION = 0.0 1;24 our $VERSION = 0.02; 25 25 26 26 our $irc; … … 30 30 31 31 sub startup { 32 BarnOwl::new_variable_string(ircnick => {default => $ENV{USER}}); 33 BarnOwl::new_variable_string(ircuser => {default => $ENV{USER}}); 34 BarnOwl::new_variable_string(ircname => {default => ""}); 32 BarnOwl::new_variable_string('irc:nick', {default => $ENV{USER}}); 33 BarnOwl::new_variable_string('irc:user', {default => $ENV{USER}}); 34 BarnOwl::new_variable_string('irc:name', {default => ""}); 35 BarnOwl::new_variable_bool('irc:spew', {default => 0}); 35 36 register_commands(); 36 37 register_handlers(); … … 40 41 sub shutdown { 41 42 for my $conn (values %ircnets) { 42 $conn->disconnect ;43 $conn->disconnect(); 43 44 } 44 45 } … … 63 64 BarnOwl::new_command('irc-disconnect' => \&cmd_disconnect); 64 65 BarnOwl::new_command('irc-msg' => \&cmd_msg); 66 BarnOwl::new_command('irc-join' => \&cmd_join); 65 67 } 66 68 … … 76 78 my $cmd = shift; 77 79 78 my $nick = BarnOwl::getvar('irc nick');79 my $username = BarnOwl::getvar('irc user');80 my $ircname = BarnOwl::getvar('irc name');80 my $nick = BarnOwl::getvar('irc:nick'); 81 my $username = BarnOwl::getvar('irc:user'); 82 my $ircname = BarnOwl::getvar('irc:name'); 81 83 my $host; 82 84 my $port; … … 90 92 "alias=s" => \$alias, 91 93 "ssl" => \$ssl, 92 "password=s" => \$password); 94 "password=s" => \$password, 95 "port=i" => \$port, 96 ); 93 97 $host = shift @ARGV or die("Usage: $cmd HOST\n"); 94 98 if(!$alias) { … … 126 130 my $conn = get_connection(\@_); 127 131 my $to = shift or die("Usage: $cmd NICK\n"); 132 # handle multiple recipients? 128 133 if(@_) { 129 134 process_msg($conn, $to, join(" ", @_)); … … 148 153 body => $body, 149 154 sender => $conn->nick, 150 isprivate => 'true', 155 is_private($to) ? 156 (isprivate => 'true') : (), 151 157 replycmd => "irc-msg $to", 152 replysendercmd => "irc-msg " . $conn->nick158 replysendercmd => "irc-msg $to" 153 159 ); 154 160 BarnOwl::queue_message($msg); 155 161 } 156 162 163 sub cmd_join { 164 my $cmd = shift; 165 my $conn = get_connection(\@_); 166 my $chan = shift or die("Usage: $cmd channel\n"); 167 $conn->join($chan); 168 } 157 169 158 170 ################################################################################ … … 177 189 178 190 sub get_connection_by_alias { 179 die("No such ircnet: $alias\n") unless exists $ircnets{$key}; 191 my $key = shift; 192 die("No such ircnet: $key\n") unless exists $ircnets{$key}; 180 193 return $ircnets{$key}; 181 194 } 182 195 196 # Determines if the given message recipient is a username, as opposed to 197 # a channel that starts with # or &. 198 sub is_private { 199 return shift !~ /^[\#\&]/; 200 } 201 183 202 1;
Note: See TracChangeset
for help on using the changeset viewer.