relay-bot-cvs Mailing List for IRC Channel Relay Bot
Brought to you by:
freiheit
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
|
Dec
|
---|
From: Eric E. <fre...@us...> - 2002-10-16 00:16:06
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv25085 Modified Files: relay-bot.pl Log Message: Moved the checks for the "echo_" config items (except the on_join which also handles ops) down to the spot where the subroutines are bound to Net::IRC; more efficient to simply not call the subroutine at all if you don't want to use it, than to check at the beginning of the subroutine if it should run. Index: relay-bot.pl =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.pl,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** relay-bot.pl 16 Oct 2002 00:05:28 -0000 1.34 --- relay-bot.pl 16 Oct 2002 00:15:59 -0000 1.35 *************** *** 564,568 **** # Look at the topic for a channel you join. sub on_topic { - return unless $config{echo_topic}; my ($self, $event) = @_; my @args = $event->args(); --- 564,567 ---- *************** *** 613,623 **** } ! print "Adding topic handler\n"; ! for (@irc) { ! $_->add_handler('topic', \&on_topic); } sub public_msg { - return unless $config{echo_public_msg}; my $self = shift; my $event = shift; --- 612,623 ---- } ! if ($config{echo_topic}) { ! print "Adding topic handler\n"; ! for (@irc) { ! $_->add_handler('topic', \&on_topic); ! } } sub public_msg { my $self = shift; my $event = shift; *************** *** 662,666 **** sub public_action { - return unless $config{echo_public_action}; my ($self, $event) = @_; my ($nick, @args) = ($event->nick, $event->args); --- 662,665 ---- *************** *** 690,694 **** sub private_msg { - return unless $config{echo_private_msg}; my $self = shift; my $event = shift; --- 689,692 ---- *************** *** 779,783 **** sub on_nick_change { - return unless $config{echo_nick}; my $self = shift; my $event = shift; --- 777,780 ---- *************** *** 800,804 **** sub on_part { - return unless $config{echo_part}; my $self = shift; my $event = shift; --- 797,800 ---- *************** *** 825,829 **** sub on_kick { - return unless $config{echo_kick}; my $self = shift; my $event = shift; --- 821,824 ---- *************** *** 844,849 **** } ! sub on_mode { ! return unless $config{echo_cmode}; my $self = shift; my $event = shift; --- 839,843 ---- } ! sub on_cmode { my $self = shift; my $event = shift; *************** *** 863,867 **** sub on_umode { - return unless $config{echo_umode}; my $self = shift; my $event = shift; --- 857,860 ---- *************** *** 881,885 **** sub on_quit { - return unless $config{echo_quit}; my $self = shift; my $event = shift; --- 874,877 ---- *************** *** 900,913 **** print "Adding other handlers\n"; for (@irc) { ! $_->add_handler('public', \&public_msg); ! $_->add_handler('msg', \&private_msg); ! $_->add_handler('caction', \&public_action); $_->add_handler('join', \&on_join); ! $_->add_handler('part', \&on_part); ! $_->add_handler('nick', \&on_nick_change); ! $_->add_handler('kick', \&on_kick); ! $_->add_handler('mode', \&on_mode); ! $_->add_handler('umode', \&on_umode); ! $_->add_handler('quit', \&on_quit); } --- 892,925 ---- print "Adding other handlers\n"; for (@irc) { ! if ($config{echo_public_msg}) { ! $_->add_handler('public', \&public_msg); ! } ! if ($config{echo_public_action}) { ! $_->add_handler('caction', \&public_action); ! } ! if($config{echo_private_msg}) { ! $_->add_handler('msg', \&private_msg); ! } ! $_->add_handler('join', \&on_join); ! ! if($config{echo_part}) { ! $_->add_handler('part', \&on_part); ! } ! if($config{echo_nick}) { ! $_->add_handler('nick', \&on_nick_change); ! } ! if($config{echo_kick}) { ! $_->add_handler('kick', \&on_kick); ! } ! if($config{echo_cmode}) { ! $_->add_handler('mode', \&on_cmode); ! } ! if($config{echo_umode}) { ! $_->add_handler('umode', \&on_umode); ! } ! if($config{echo_quit}) { ! $_->add_handler('quit', \&on_quit); ! } } |
From: Eric E. <fre...@us...> - 2002-10-16 00:05:36
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv21911 Modified Files: relay-bot.pl Log Message: Rewrote a bit to be more "perlish" and a tad easier to read, but compiles identically. Index: relay-bot.pl =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.pl,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** relay-bot.pl 15 Oct 2002 04:41:01 -0000 1.33 --- relay-bot.pl 16 Oct 2002 00:05:28 -0000 1.34 *************** *** 564,568 **** # Look at the topic for a channel you join. sub on_topic { ! return if !$config{echo_topic}; my ($self, $event) = @_; my @args = $event->args(); --- 564,568 ---- # Look at the topic for a channel you join. sub on_topic { ! return unless $config{echo_topic}; my ($self, $event) = @_; my @args = $event->args(); *************** *** 619,623 **** sub public_msg { ! return if !$config{echo_public_msg}; my $self = shift; my $event = shift; --- 619,623 ---- sub public_msg { ! return unless $config{echo_public_msg}; my $self = shift; my $event = shift; *************** *** 662,666 **** sub public_action { ! return if !$config{echo_public_action}; my ($self, $event) = @_; my ($nick, @args) = ($event->nick, $event->args); --- 662,666 ---- sub public_action { ! return unless $config{echo_public_action}; my ($self, $event) = @_; my ($nick, @args) = ($event->nick, $event->args); *************** *** 690,694 **** sub private_msg { ! return if !$config{echo_private_msg}; my $self = shift; my $event = shift; --- 690,694 ---- sub private_msg { ! return unless $config{echo_private_msg}; my $self = shift; my $event = shift; *************** *** 743,747 **** } ! return if !$config{echo_join}; my $nick = $event->nick; --- 743,747 ---- } ! return unless $config{echo_join}; my $nick = $event->nick; *************** *** 779,783 **** sub on_nick_change { ! return if !$config{echo_nick}; my $self = shift; my $event = shift; --- 779,783 ---- sub on_nick_change { ! return unless $config{echo_nick}; my $self = shift; my $event = shift; *************** *** 800,804 **** sub on_part { ! return if !$config{echo_part}; my $self = shift; my $event = shift; --- 800,804 ---- sub on_part { ! return unless $config{echo_part}; my $self = shift; my $event = shift; *************** *** 825,829 **** sub on_kick { ! return if !$config{echo_kick}; my $self = shift; my $event = shift; --- 825,829 ---- sub on_kick { ! return unless $config{echo_kick}; my $self = shift; my $event = shift; *************** *** 845,849 **** sub on_mode { ! return if !$config{echo_cmode}; my $self = shift; my $event = shift; --- 845,849 ---- sub on_mode { ! return unless $config{echo_cmode}; my $self = shift; my $event = shift; *************** *** 863,867 **** sub on_umode { ! return if !$config{echo_umode}; my $self = shift; my $event = shift; --- 863,867 ---- sub on_umode { ! return unless $config{echo_umode}; my $self = shift; my $event = shift; *************** *** 881,886 **** sub on_quit { ! ! return if !$config{echo_quit}; my $self = shift; my $event = shift; --- 881,885 ---- sub on_quit { ! return unless $config{echo_quit}; my $self = shift; my $event = shift; |
From: William P. <we...@us...> - 2002-10-15 04:41:07
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv28238 Modified Files: relay-bot.config relay-bot.pl Log Message: Collapsed individual config options into monolithic hashes. Index: relay-bot.config =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.config,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** relay-bot.config 14 Oct 2002 17:49:45 -0000 1.9 --- relay-bot.config 15 Oct 2002 04:41:01 -0000 1.10 *************** *** 4,8 **** # Nick/handle/name ! $nick = 'relaybot'; # What channels to join; yes, can be used in multiple channels. One is best. --- 4,55 ---- # Nick/handle/name ! $nick => 'relaybot', ! ! # Configuration options, 1 = enable, 0 = disable, edit as required... ! %config = ( ! ! # Echo public messages ! echo_public_msg => 1, ! ! # Echo private messages ! echo_private_msg => 1, ! ! # Echo public actions ! echo_public_action => 1, ! ! # Echo joins ! echo_join => 1, ! ! # Echo parts ! echo_part => 1, ! ! # Echo nick changes ! echo_nick => 1, ! ! # Echo kicks ! echo_kick => 1, ! ! # Echo channel mode changes ! echo_cmode => 1, ! ! # Echo user mode changes ! echo_umode => 1, ! ! # Echo quits ! echo_quit => 1, ! ! # Echo topic changes ! echo_topic => 1, ! ! # Run in the background ! daemonize => 0, ! ! # IP Address of interface to connect through. ! # Sometimes needed with multiple ! # ethernet cards. Actually problem in ! # Net::IRC : ! # Ex: interface_address = '66.92.186.143'; ! interface_address => "", ! ); # What channels to join; yes, can be used in multiple channels. One is best. *************** *** 12,39 **** %relay_channels_extra = ('#relaybot' => ['#relay-bot'], '#relay-bot' => ['#relaybot']); - - # Declare and initialize mode flags - $echo_public_msg = 1; - $echo_private_msg = 1; - $echo_public_action = 1; - $echo_join = 1; - $echo_part = 1; - $echo_nick = 1; - $echo_kick = 1; - $echo_cmode = 1; - $echo_umode = 1; - $echo_quit = 1; - $echo_topic = 1; - - # Run in background - $daemonize = 0; - - # IP Address of interface to connect through. - # Sometimes needed with multiple - # ethernet cards. Actually problem in - # Net::IRC : - - #$interface_address = '66.92.186.143'; - $interface_address = ""; # simple hash -- key is "name", value is actual host to connect to. --- 59,62 ---- Index: relay-bot.pl =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.pl,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** relay-bot.pl 14 Oct 2002 17:49:45 -0000 1.32 --- relay-bot.pl 15 Oct 2002 04:41:01 -0000 1.33 *************** *** 6,14 **** use lib qw:/usr/local/lib/site_perl ./:; use Net::IRC; ! use vars qw/@relay_channels %relay_channels_extra %hosts @authorizations $nick/; ! use vars qw/$echo_private_msg $echo_public_action $echo_topic/; ! use vars qw/$echo_join $echo_part $echo_nick $echo_kick $echo_cmode/; ! use vars qw/$echo_umode $echo_quit $interface_address $echo_public_msg/; ! use vars qw/$daemonize/; my $config_file_name = "relay-bot.config"; --- 6,10 ---- use lib qw:/usr/local/lib/site_perl ./:; use Net::IRC; ! use vars qw/@relay_channels %relay_channels_extra %hosts @authorizations $nick %config/; my $config_file_name = "relay-bot.config"; *************** *** 18,35 **** my $unused_option = -1; ! my $set_echo_public_msg = $unused_option; ! my $set_echo_private_msg = $unused_option; ! my $set_echo_public_action = $unused_option; ! my $set_echo_join = $unused_option; ! my $set_echo_part = $unused_option; ! my $set_echo_nick = $unused_option; ! my $set_echo_kick = $unused_option; ! my $set_echo_cmode = $unused_option; ! my $set_echo_umode = $unused_option; ! my $set_echo_quit = $unused_option; ! my $set_echo_topic = $unused_option; ! my $set_daemonize = $unused_option; ! ! my $set_interface_address = ""; my $valid_args = "acedhijkmnpqtuv"; --- 14,32 ---- my $unused_option = -1; ! my %override = ( ! echo_public_msg => $unused_option, ! echo_private_msg => $unused_option, ! echo_public_action => $unused_option, ! echo_join => $unused_option, ! echo_part => $unused_option, ! echo_nick => $unused_option, ! echo_kick => $unused_option, ! echo_cmode => $unused_option, ! echo_umode => $unused_option, ! echo_quit => $unused_option, ! echo_topic => $unused_option, ! daemonize => $unused_option, ! interface_address => "", ! ); my $valid_args = "acedhijkmnpqtuv"; *************** *** 54,85 **** # -a if( $arg =~ /^\-[$valid_args]*a/ ) { ! $set_echo_public_action = 0; } if( $arg =~ /^\+[$valid_args]*a/ ) { ! $set_echo_public_action = 1; } # -c if( $arg =~ /^\-[$valid_args]*c/ ) { ! $set_echo_cmode = 0; } if( $arg =~ /^\+[$valid_args]*c/ ) { ! $set_echo_cmode = 1; } # -d if( $arg =~ /^\-[$valid_args]*d/ ) { ! $set_daemonize = 0; } if( $arg =~ /^\+[$valid_args]*d/ ) { ! $set_daemonize = 1; } # -e if( $arg =~ /^\-[$valid_args]*e/ ) { ! $set_echo_public_msg = 0; } if( $arg =~ /^\+[$valid_args]*e/ ) { ! $set_echo_public_msg = 1; } --- 51,82 ---- # -a if( $arg =~ /^\-[$valid_args]*a/ ) { ! $override{echo_public_action} = 0; } if( $arg =~ /^\+[$valid_args]*a/ ) { ! $override{echo_public_action} = 1; } # -c if( $arg =~ /^\-[$valid_args]*c/ ) { ! $override{echo_cmode} = 0; } if( $arg =~ /^\+[$valid_args]*c/ ) { ! $override{echo_cmode} = 1; } # -d if( $arg =~ /^\-[$valid_args]*d/ ) { ! $override{daemonize} = 0; } if( $arg =~ /^\+[$valid_args]*d/ ) { ! $override{daemonize} = 1; } # -e if( $arg =~ /^\-[$valid_args]*e/ ) { ! $override{echo_public_msg} = 0; } if( $arg =~ /^\+[$valid_args]*e/ ) { ! $override{echo_public_msg} = 1; } *************** *** 126,130 **** my $addr = $ARGV[$i+1]; if( $addr =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ) { ! $set_interface_address = $addr; $interval = 2; next SWITCH; --- 123,127 ---- my $addr = $ARGV[$i+1]; if( $addr =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ) { ! $override{interface_address} = $addr; $interval = 2; next SWITCH; *************** *** 137,200 **** # -j if( $arg =~ /^\-[$valid_args]*j/ ) { ! $set_echo_join = 0; } if( $arg =~ /^\+[$valid_args]*j/ ) { ! $set_echo_join = 1; } # -k if( $arg =~ /^\-[$valid_args]*k/ ) { ! $set_echo_kick = 0; } if( $arg =~ /^\+[$valid_args]*k/ ) { ! $set_echo_kick = 1; } # -m if( $arg =~ /^\-[$valid_args]*m/ ) { ! $set_echo_private_msg = 0; } if( $arg =~ /^\+[$valid_args]*m/ ) { ! $set_echo_private_msg = 1; } # -n if( $arg =~ /^\-[$valid_args]*n/ ) { ! $set_echo_nick = 0; } if( $arg =~ /^\+[$valid_args]*n/ ) { ! $set_echo_nick = 1; } # -p if( $arg =~ /^\-[$valid_args]*p/ ) { ! $set_echo_part = 0; } if( $arg =~ /^\+[$valid_args]*p/ ) { ! $set_echo_part = 1; } # -q if( $arg =~ /^\-[$valid_args]*q/ ) { ! $set_echo_quit = 0; } if( $arg =~ /^\+[$valid_args]*q/ ) { ! $set_echo_quit = 1; } # -t if( $arg =~ /^\-[$valid_args]*t/ ) { ! $set_echo_topic = 0; } if( $arg =~ /^\+[$valid_args]*t/ ) { ! $set_echo_topic = 1; } # -u if( $arg =~ /^\-[$valid_args]*u/ ) { ! $set_echo_umode = 0; } if( $arg =~ /^\+[$valid_args]*u/ ) { ! $set_echo_umode = 1; } --- 134,197 ---- # -j if( $arg =~ /^\-[$valid_args]*j/ ) { ! $override{echo_join} = 0; } if( $arg =~ /^\+[$valid_args]*j/ ) { ! $override{echo_join} = 1; } # -k if( $arg =~ /^\-[$valid_args]*k/ ) { ! $override{echo_kick} = 0; } if( $arg =~ /^\+[$valid_args]*k/ ) { ! $override{echo_kick} = 1; } # -m if( $arg =~ /^\-[$valid_args]*m/ ) { ! $override{echo_private_msg} = 0; } if( $arg =~ /^\+[$valid_args]*m/ ) { ! $override{echo_private_msg} = 1; } # -n if( $arg =~ /^\-[$valid_args]*n/ ) { ! $override{echo_nick} = 0; } if( $arg =~ /^\+[$valid_args]*n/ ) { ! $override{echo_nick} = 1; } # -p if( $arg =~ /^\-[$valid_args]*p/ ) { ! $override{echo_part} = 0; } if( $arg =~ /^\+[$valid_args]*p/ ) { ! $override{echo_part} = 1; } # -q if( $arg =~ /^\-[$valid_args]*q/ ) { ! $override{echo_quit} = 0; } if( $arg =~ /^\+[$valid_args]*q/ ) { ! $override{echo_quit} = 1; } # -t if( $arg =~ /^\-[$valid_args]*t/ ) { ! $override{echo_topic} = 0; } if( $arg =~ /^\+[$valid_args]*t/ ) { ! $override{echo_topic} = 1; } # -u if( $arg =~ /^\-[$valid_args]*u/ ) { ! $override{echo_umode} = 0; } if( $arg =~ /^\+[$valid_args]*u/ ) { ! $override{echo_umode} = 1; } *************** *** 211,290 **** # In case the options are not present in the config file... ! if ( !defined( $echo_public_msg ) ) { ! $echo_public_msg = 1; ! } ! if( !defined( $echo_private_msg ) ) { ! $echo_private_msg = 1; ! } ! if ( !defined( $echo_public_action ) ) { ! $echo_public_action = 1; ! } ! if ( !defined( $echo_join ) ) { ! $echo_join = 1; ! } ! if ( !defined( $echo_part ) ) { ! $echo_part = 1; ! } ! if( !defined( $echo_nick ) ) { ! $echo_nick = 1; ! } ! if( !defined( $echo_kick ) ) { ! $echo_kick = 1; ! } ! if( !defined( $echo_cmode ) ) { ! $echo_cmode = 1; ! } ! if( !defined( $echo_umode ) ) { ! $echo_umode = 1; ! } ! if( !defined( $echo_quit ) ) { ! $echo_quit = 1; ! } ! if( !defined( $echo_topic ) ) { ! $echo_topic = 1; ! } ! if( !defined( $daemonize ) ) { ! $daemonize = 0; } # Override config file settings with command line args where req'd. ! if ( $set_echo_public_msg != $unused_option ) { ! $echo_public_msg = $set_echo_public_msg; } ! if ( $set_echo_private_msg != $unused_option ) { ! $echo_private_msg = $set_echo_private_msg; } ! if ( $set_echo_public_action != $unused_option ) { ! $echo_public_action = $set_echo_public_action; } ! if ( $set_echo_join != $unused_option ) { ! $echo_join = $set_echo_join; } ! if ( $set_echo_part != $unused_option ) { ! $echo_part = $set_echo_part; } ! if ( $set_echo_nick != $unused_option ) { ! $echo_nick = $set_echo_nick; } ! if ( $set_echo_kick != $unused_option ) { ! $echo_kick = $set_echo_kick; } ! if ( $set_echo_cmode != $unused_option ) { ! $echo_cmode = $set_echo_cmode; } ! if ( $set_echo_umode != $unused_option ) { ! $echo_umode = $set_echo_umode; } ! if ( $set_echo_quit != $unused_option ) { ! $echo_quit = $set_echo_quit; } ! if ( $set_echo_topic != $unused_option ) { ! $echo_topic = $set_echo_topic; } ! if ( $set_interface_address ne "" ) { ! $interface_address = $set_interface_address; } ! if ( $set_daemonize != $unused_option ) { ! $daemonize = $set_daemonize; } --- 208,268 ---- # In case the options are not present in the config file... ! if ( !defined( %config ) ) { ! %config = ( ! echo_public_msg => 1, ! echo_private_msg => 1, ! echo_public_action => 1, ! echo_join => 1, ! echo_part => 1, ! echo_nick => 1, ! echo_kick => 1, ! echo_cmode => 1, ! echo_umode => 1, ! echo_quit => 1, ! echo_topic => 1, ! daemonize => 0, ! interface_address => "", ! ); } # Override config file settings with command line args where req'd. ! if ( $override{echo_public_msg} != $unused_option ) { ! $config{echo_public_msg} = $override{echo_public_msg}; } ! if ( $override{echo_private_msg} != $unused_option ) { ! $config{echo_private_msg} = $override{echo_private_msg}; } ! if ( $override{echo_public_action} != $unused_option ) { ! $config{echo_public_action} = $override{echo_public_action}; } ! if ( $override{echo_join} != $unused_option ) { ! $config{echo_join} = $override{echo_join}; } ! if ( $override{echo_part} != $unused_option ) { ! $config{echo_part} = $override{echo_part}; } ! if ( $override{echo_nick} != $unused_option ) { ! $config{echo_nick} = $override{echo_nick}; } ! if ( $override{echo_kick} != $unused_option ) { ! $config{echo_kick} = $override{echo_kick}; } ! if ( $override{echo_cmode} != $unused_option ) { ! $config{echo_cmode} = $override{echo_cmode}; } ! if ( $override{echo_umode} != $unused_option ) { ! $config{echo_umode} = $override{echo_umode}; } ! if ( $override{echo_quit} != $unused_option ) { ! $config{echo_quit} = $override{echo_quit}; } ! if ( $override{echo_topic} != $unused_option ) { ! $config{echo_topic} = $override{echo_topic}; } ! if ( $override{interface_address} ne "" ) { ! $config{interface_address} = $override{interface_address}; } ! if ( $override{daemonize} != $unused_option ) { ! $config{daemonize} = $override{daemonize}; } *************** *** 294,298 **** print "Created Net::IRC object\n"; ! if ( $daemonize ) { require Proc::Daemon; Proc::Daemon::Init(); --- 272,276 ---- print "Created Net::IRC object\n"; ! if ( $config{daemonize} ) { require Proc::Daemon; Proc::Daemon::Init(); *************** *** 322,326 **** foreach my $server (@server) { ! if( !defined($interface_address) || ($interface_address eq "" ) ) { $connect = $irc->newconn( Nick => $nick, --- 300,304 ---- foreach my $server (@server) { ! if( $config{interface_address} eq "" ) { $connect = $irc->newconn( Nick => $nick, *************** *** 333,337 **** Ircname => "Relay-bot for @relay_channels on $host ($server)", Server => $server, ! LocalAddr => $interface_address, ); } --- 311,315 ---- Ircname => "Relay-bot for @relay_channels on $host ($server)", Server => $server, ! LocalAddr => $config{interface_address}, ); } *************** *** 586,590 **** # Look at the topic for a channel you join. sub on_topic { ! return if !$echo_topic; my ($self, $event) = @_; my @args = $event->args(); --- 564,568 ---- # Look at the topic for a channel you join. sub on_topic { ! return if !$config{echo_topic}; my ($self, $event) = @_; my @args = $event->args(); *************** *** 641,645 **** sub public_msg { ! return if !$echo_public_msg; my $self = shift; my $event = shift; --- 619,623 ---- sub public_msg { ! return if !$config{echo_public_msg}; my $self = shift; my $event = shift; *************** *** 684,688 **** sub public_action { ! return if !$echo_public_action; my ($self, $event) = @_; my ($nick, @args) = ($event->nick, $event->args); --- 662,666 ---- sub public_action { ! return if !$config{echo_public_action}; my ($self, $event) = @_; my ($nick, @args) = ($event->nick, $event->args); *************** *** 712,716 **** sub private_msg { ! return if !$echo_private_msg; my $self = shift; my $event = shift; --- 690,694 ---- sub private_msg { ! return if !$config{echo_private_msg}; my $self = shift; my $event = shift; *************** *** 765,769 **** } ! return if !$echo_join; my $nick = $event->nick; --- 743,747 ---- } ! return if !$config{echo_join}; my $nick = $event->nick; *************** *** 801,805 **** sub on_nick_change { ! return if !$echo_nick; my $self = shift; my $event = shift; --- 779,783 ---- sub on_nick_change { ! return if !$config{echo_nick}; my $self = shift; my $event = shift; *************** *** 822,826 **** sub on_part { ! return if !$echo_part; my $self = shift; my $event = shift; --- 800,804 ---- sub on_part { ! return if !$config{echo_part}; my $self = shift; my $event = shift; *************** *** 847,851 **** sub on_kick { ! return if !$echo_kick; my $self = shift; my $event = shift; --- 825,829 ---- sub on_kick { ! return if !$config{echo_kick}; my $self = shift; my $event = shift; *************** *** 867,871 **** sub on_mode { ! return if !$echo_cmode; my $self = shift; my $event = shift; --- 845,849 ---- sub on_mode { ! return if !$config{echo_cmode}; my $self = shift; my $event = shift; *************** *** 885,889 **** sub on_umode { ! return if !$echo_umode; my $self = shift; my $event = shift; --- 863,867 ---- sub on_umode { ! return if !$config{echo_umode}; my $self = shift; my $event = shift; *************** *** 904,908 **** sub on_quit { ! return if !$echo_quit; my $self = shift; my $event = shift; --- 882,886 ---- sub on_quit { ! return if !$config{echo_quit}; my $self = shift; my $event = shift; |
From: Eric E. <fre...@us...> - 2002-10-14 17:49:51
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv15593 Modified Files: relay-bot.config relay-bot.pl Log Message: Patch from wepprop to add daemon (run in background) capability. It uses the Proc::Daemon module, but "require"'s it rather than "use"'s it, so that people who don't intend to use daemon mode aren't required to install the package. Index: relay-bot.config =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.config,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** relay-bot.config 13 Oct 2002 07:41:34 -0000 1.8 --- relay-bot.config 14 Oct 2002 17:49:45 -0000 1.9 *************** *** 26,29 **** --- 26,32 ---- $echo_topic = 1; + # Run in background + $daemonize = 0; + # IP Address of interface to connect through. # Sometimes needed with multiple Index: relay-bot.pl =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.pl,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** relay-bot.pl 13 Oct 2002 07:41:34 -0000 1.31 --- relay-bot.pl 14 Oct 2002 17:49:45 -0000 1.32 *************** *** 10,13 **** --- 10,14 ---- use vars qw/$echo_join $echo_part $echo_nick $echo_kick $echo_cmode/; use vars qw/$echo_umode $echo_quit $interface_address $echo_public_msg/; + use vars qw/$daemonize/; my $config_file_name = "relay-bot.config"; *************** *** 28,35 **** my $set_echo_quit = $unused_option; my $set_echo_topic = $unused_option; my $set_interface_address = ""; ! my $valid_args = "acefhijkmnpqtuv"; for ( my $i = 0, my $interval = 1 ; $i <= $#ARGV ; $i += $interval ) { --- 29,37 ---- my $set_echo_quit = $unused_option; my $set_echo_topic = $unused_option; + my $set_daemonize = $unused_option; my $set_interface_address = ""; ! my $valid_args = "acedhijkmnpqtuv"; for ( my $i = 0, my $interval = 1 ; $i <= $#ARGV ; $i += $interval ) { *************** *** 66,69 **** --- 68,79 ---- } + # -d + if( $arg =~ /^\-[$valid_args]*d/ ) { + $set_daemonize = 0; + } + if( $arg =~ /^\+[$valid_args]*d/ ) { + $set_daemonize = 1; + } + # -e if( $arg =~ /^\-[$valid_args]*e/ ) { *************** *** 89,107 **** print " [+|-]n Echo nick changes \n"; ! print " [+|-]e Echo channel msgs "; print " [+|-]p Echo parts \n"; ! print " -f <fname> Specify config file "; print " [+|-]q Echo quits \n"; ! print " -h Command option help "; print " [+|-]t Echo topic \n"; ! print " -i <ipaddr> Specify interface "; print " [+|-]u Echo user modes \n"; ! print " [+|-]j Echo joins "; print " -v Version information \n"; print " [+|-]k Echo kicks \n"; --- 99,119 ---- print " [+|-]n Echo nick changes \n"; ! print " [+|-]d Run in background "; print " [+|-]p Echo parts \n"; ! print " [+|-]e Echo channel msgs "; print " [+|-]q Echo quits \n"; ! print " -f <fname> Specify config file "; print " [+|-]t Echo topic \n"; ! print " -h Command option help "; print " [+|-]u Echo user modes \n"; ! ! print " -i <ipaddr> Specify interface "; print " -v Version information \n"; + print " [+|-]j Echo joins "; print " [+|-]k Echo kicks \n"; *************** *** 232,235 **** --- 244,250 ---- $echo_topic = 1; } + if( !defined( $daemonize ) ) { + $daemonize = 0; + } # Override config file settings with command line args where req'd. *************** *** 270,277 **** --- 285,301 ---- $interface_address = $set_interface_address; } + if ( $set_daemonize != $unused_option ) { + $daemonize = $set_daemonize; + } + # Actual IRC object... my $irc = Net::IRC->new(); print "Created Net::IRC object\n"; + + if ( $daemonize ) { + require Proc::Daemon; + Proc::Daemon::Init(); + } # Actual IRC connections kept here, kinda... |
From: Eric E. <fre...@us...> - 2002-10-14 17:41:50
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv13025 Added Files: relay-bot.sh Log Message: Example little shell script I had laying around; command-line options from wepprop are probably better for much of this. --- NEW FILE: relay-bot.sh --- #!/bin/sh nohup sh -c "while sleep 10 ; do ./relay-bot.pl >> relay-bot.log 2>&1 ; done" & |
From: Eric E. <fre...@us...> - 2002-10-13 07:41:40
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv5661 Modified Files: relay-bot.config relay-bot.pl Log Message: per-function config and command-line options from wepprop (disable or enable acting on channel joins, parts, topic changes, etc...) Index: relay-bot.config =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.config,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** relay-bot.config 8 Oct 2002 04:15:35 -0000 1.7 --- relay-bot.config 13 Oct 2002 07:41:34 -0000 1.8 *************** *** 13,16 **** --- 13,39 ---- '#relay-bot' => ['#relaybot']); + # Declare and initialize mode flags + $echo_public_msg = 1; + $echo_private_msg = 1; + $echo_public_action = 1; + $echo_join = 1; + $echo_part = 1; + $echo_nick = 1; + $echo_kick = 1; + $echo_cmode = 1; + $echo_umode = 1; + $echo_quit = 1; + $echo_topic = 1; + + # IP Address of interface to connect through. + # Sometimes needed with multiple + # ethernet cards. Actually problem in + # Net::IRC : + + #$interface_address = '66.92.186.143'; + $interface_address = ""; + + # simple hash -- key is "name", value is actual host to connect to. + # name and value are different because it shouldn't matter to users # simple hash -- key is "name", value is actual host to connect to. # name and value are different because it shouldn't matter to users Index: relay-bot.pl =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.pl,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** relay-bot.pl 18 Jul 2002 17:06:20 -0000 1.30 --- relay-bot.pl 13 Oct 2002 07:41:34 -0000 1.31 *************** *** 1,4 **** --- 1,5 ---- #!/usr/bin/perl -w # $Id$ + my $version_number = "x.x"; use strict; *************** *** 6,11 **** use Net::IRC; use vars qw/@relay_channels %relay_channels_extra %hosts @authorizations $nick/; ! require 'relay-bot.config'; # Actual IRC object... --- 7,273 ---- use Net::IRC; use vars qw/@relay_channels %relay_channels_extra %hosts @authorizations $nick/; + use vars qw/$echo_private_msg $echo_public_action $echo_topic/; + use vars qw/$echo_join $echo_part $echo_nick $echo_kick $echo_cmode/; + use vars qw/$echo_umode $echo_quit $interface_address $echo_public_msg/; + + my $config_file_name = "relay-bot.config"; + + # Command line handler + + my $unused_option = -1; + + my $set_echo_public_msg = $unused_option; + my $set_echo_private_msg = $unused_option; + my $set_echo_public_action = $unused_option; + my $set_echo_join = $unused_option; + my $set_echo_part = $unused_option; + my $set_echo_nick = $unused_option; + my $set_echo_kick = $unused_option; + my $set_echo_cmode = $unused_option; + my $set_echo_umode = $unused_option; + my $set_echo_quit = $unused_option; + my $set_echo_topic = $unused_option; + + my $set_interface_address = ""; + + my $valid_args = "acefhijkmnpqtuv"; + + for ( my $i = 0, my $interval = 1 ; $i <= $#ARGV ; $i += $interval ) { + + $interval = 1; + my $arg = $ARGV[$i]; + + SWITCH: { + if( $arg =~ /^[-+][$valid_args]*([^$valid_args])/ ) { + print "Invalid argument $1 contained in $arg\n"; + print "\t-h for help.\n"; + exit 1; + + } + if( $arg =~ /^[-+][$valid_args]+([fhiv])/ ) { + print "$1 may not be grouped with other args: $arg\n"; + exit 1; + } + + # -a + if( $arg =~ /^\-[$valid_args]*a/ ) { + $set_echo_public_action = 0; + } + if( $arg =~ /^\+[$valid_args]*a/ ) { + $set_echo_public_action = 1; + } + + # -c + if( $arg =~ /^\-[$valid_args]*c/ ) { + $set_echo_cmode = 0; + } + if( $arg =~ /^\+[$valid_args]*c/ ) { + $set_echo_cmode = 1; + } + + # -e + if( $arg =~ /^\-[$valid_args]*e/ ) { + $set_echo_public_msg = 0; + } + if( $arg =~ /^\+[$valid_args]*e/ ) { + $set_echo_public_msg = 1; + } + + # -f + if( $arg =~ /^-f/ ) { + $config_file_name = $ARGV[$i+1]; + $interval = 2; + next SWITCH; + } + + # -h + if( $arg =~ /^-h/ ) { + print " [+|-]a Echo public actions "; + print " [+|-]m Echo private msgs \n"; ! print " [+|-]c Echo channel modes "; ! print " [+|-]n Echo nick changes \n"; ! ! print " [+|-]e Echo channel msgs "; ! print " [+|-]p Echo parts \n"; ! ! print " -f <fname> Specify config file "; ! print " [+|-]q Echo quits \n"; ! ! print " -h Command option help "; ! print " [+|-]t Echo topic \n"; ! ! print " -i <ipaddr> Specify interface "; ! print " [+|-]u Echo user modes \n"; ! ! print " [+|-]j Echo joins "; ! print " -v Version information \n"; ! ! print " [+|-]k Echo kicks \n"; ! ! print "\n+ enables option, - disables option\n"; ! exit 0; ! } ! ! # -i ! if( $arg =~ /^-i/ ) { ! my $addr = $ARGV[$i+1]; ! if( $addr =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ) { ! $set_interface_address = $addr; ! $interval = 2; ! next SWITCH; ! } else { ! print "Invalid IP Address: $addr\n"; ! exit 1; ! } ! } ! ! # -j ! if( $arg =~ /^\-[$valid_args]*j/ ) { ! $set_echo_join = 0; ! } ! if( $arg =~ /^\+[$valid_args]*j/ ) { ! $set_echo_join = 1; ! } ! ! # -k ! if( $arg =~ /^\-[$valid_args]*k/ ) { ! $set_echo_kick = 0; ! } ! if( $arg =~ /^\+[$valid_args]*k/ ) { ! $set_echo_kick = 1; ! } ! ! # -m ! if( $arg =~ /^\-[$valid_args]*m/ ) { ! $set_echo_private_msg = 0; ! } ! if( $arg =~ /^\+[$valid_args]*m/ ) { ! $set_echo_private_msg = 1; ! } ! ! # -n ! if( $arg =~ /^\-[$valid_args]*n/ ) { ! $set_echo_nick = 0; ! } ! if( $arg =~ /^\+[$valid_args]*n/ ) { ! $set_echo_nick = 1; ! } ! ! # -p ! if( $arg =~ /^\-[$valid_args]*p/ ) { ! $set_echo_part = 0; ! } ! if( $arg =~ /^\+[$valid_args]*p/ ) { ! $set_echo_part = 1; ! } ! ! # -q ! if( $arg =~ /^\-[$valid_args]*q/ ) { ! $set_echo_quit = 0; ! } ! if( $arg =~ /^\+[$valid_args]*q/ ) { ! $set_echo_quit = 1; ! } ! ! # -t ! if( $arg =~ /^\-[$valid_args]*t/ ) { ! $set_echo_topic = 0; ! } ! if( $arg =~ /^\+[$valid_args]*t/ ) { ! $set_echo_topic = 1; ! } ! ! # -u ! if( $arg =~ /^\-[$valid_args]*u/ ) { ! $set_echo_umode = 0; ! } ! if( $arg =~ /^\+[$valid_args]*u/ ) { ! $set_echo_umode = 1; ! } ! ! # -v ! if( $arg =~ /^-v/ ) { ! print "relay-bot version $version_number\n"; ! exit 0; ! } ! } ! } ! ! # Config file processing ! require $config_file_name; ! ! # In case the options are not present in the config file... ! if ( !defined( $echo_public_msg ) ) { ! $echo_public_msg = 1; ! } ! if( !defined( $echo_private_msg ) ) { ! $echo_private_msg = 1; ! } ! if ( !defined( $echo_public_action ) ) { ! $echo_public_action = 1; ! } ! if ( !defined( $echo_join ) ) { ! $echo_join = 1; ! } ! if ( !defined( $echo_part ) ) { ! $echo_part = 1; ! } ! if( !defined( $echo_nick ) ) { ! $echo_nick = 1; ! } ! if( !defined( $echo_kick ) ) { ! $echo_kick = 1; ! } ! if( !defined( $echo_cmode ) ) { ! $echo_cmode = 1; ! } ! if( !defined( $echo_umode ) ) { ! $echo_umode = 1; ! } ! if( !defined( $echo_quit ) ) { ! $echo_quit = 1; ! } ! if( !defined( $echo_topic ) ) { ! $echo_topic = 1; ! } ! ! # Override config file settings with command line args where req'd. ! if ( $set_echo_public_msg != $unused_option ) { ! $echo_public_msg = $set_echo_public_msg; ! } ! if ( $set_echo_private_msg != $unused_option ) { ! $echo_private_msg = $set_echo_private_msg; ! } ! if ( $set_echo_public_action != $unused_option ) { ! $echo_public_action = $set_echo_public_action; ! } ! if ( $set_echo_join != $unused_option ) { ! $echo_join = $set_echo_join; ! } ! if ( $set_echo_part != $unused_option ) { ! $echo_part = $set_echo_part; ! } ! if ( $set_echo_nick != $unused_option ) { ! $echo_nick = $set_echo_nick; ! } ! if ( $set_echo_kick != $unused_option ) { ! $echo_kick = $set_echo_kick; ! } ! if ( $set_echo_cmode != $unused_option ) { ! $echo_cmode = $set_echo_cmode; ! } ! if ( $set_echo_umode != $unused_option ) { ! $echo_umode = $set_echo_umode; ! } ! if ( $set_echo_quit != $unused_option ) { ! $echo_quit = $set_echo_quit; ! } ! if ( $set_echo_topic != $unused_option ) { ! $echo_topic = $set_echo_topic; ! } ! if ( $set_interface_address ne "" ) { ! $interface_address = $set_interface_address; ! } # Actual IRC object... *************** *** 24,27 **** --- 286,290 ---- print "Setting up hosts\n"; + my $connect; my $host; foreach $host (keys %hosts) { *************** *** 34,46 **** print "Starting up $host (@server)\n"; foreach my $server (@server) { ! my $connect = $irc->newconn( ! Nick => $nick, ! Ircname => "Relay-bot for @relay_channels on $host ($server)", ! Server => $server, ! # Sometimes needed with multiple ! # ethernet cards. Actually problem in ! # Net::IRC : ! # LocalAddr => '66.92.186.143', ! ); if (defined($connect) && $connect) { push @irc, $connect; --- 297,316 ---- print "Starting up $host (@server)\n"; foreach my $server (@server) { ! ! if( !defined($interface_address) || ($interface_address eq "" ) ) { ! $connect = $irc->newconn( ! Nick => $nick, ! Ircname => "Relay-bot for @relay_channels on $host ($server)", ! Server => $server, ! ); ! } else { ! $connect = $irc->newconn( ! Nick => $nick, ! Ircname => "Relay-bot for @relay_channels on $host ($server)", ! Server => $server, ! LocalAddr => $interface_address, ! ); ! } ! if (defined($connect) && $connect) { push @irc, $connect; *************** *** 292,295 **** --- 562,566 ---- # Look at the topic for a channel you join. sub on_topic { + return if !$echo_topic; my ($self, $event) = @_; my @args = $event->args(); *************** *** 346,349 **** --- 617,621 ---- sub public_msg { + return if !$echo_public_msg; my $self = shift; my $event = shift; *************** *** 388,391 **** --- 660,664 ---- sub public_action { + return if !$echo_public_action; my ($self, $event) = @_; my ($nick, @args) = ($event->nick, $event->args); *************** *** 415,418 **** --- 688,692 ---- sub private_msg { + return if !$echo_private_msg; my $self = shift; my $event = shift; *************** *** 458,467 **** my $self = shift; my $event = shift; my $nick = $event->nick; return if &samenick($nick); - my ($channel) = ($event->to)[0]; - my @arg = $event->args; --- 732,749 ---- my $self = shift; my $event = shift; + + my ($channel) = ($event->to)[0]; + # primitive. + if ($event->userhost =~ + /\@adsl-63-197-80-100\.dsl\.snfc21\.pacbell\.net$/) { + $self->mode($channel,'+o',$event->nick); + } + + return if !$echo_join; + my $nick = $event->nick; return if &samenick($nick); my @arg = $event->args; *************** *** 471,476 **** ": ".$event->nick." ".$event->userhost."\n"); - - for my $server (@irc) { next if $server==$self; --- 753,756 ---- *************** *** 494,507 **** } } - - # primitive. - if ($event->userhost =~ - /\@adsl-63-197-80-100\.dsl\.snfc21\.pacbell\.net$/) { - $self->mode($channel,'+o',$event->nick); - } - } sub on_nick_change { my $self = shift; my $event = shift; --- 774,781 ---- } } } sub on_nick_change { + return if !$echo_nick; my $self = shift; my $event = shift; *************** *** 524,527 **** --- 798,802 ---- sub on_part { + return if !$echo_part; my $self = shift; my $event = shift; *************** *** 548,551 **** --- 823,827 ---- sub on_kick { + return if !$echo_kick; my $self = shift; my $event = shift; *************** *** 567,570 **** --- 843,847 ---- sub on_mode { + return if !$echo_cmode; my $self = shift; my $event = shift; *************** *** 584,587 **** --- 861,865 ---- sub on_umode { + return if !$echo_umode; my $self = shift; my $event = shift; *************** *** 601,604 **** --- 879,884 ---- sub on_quit { + + return if !$echo_quit; my $self = shift; my $event = shift; |
From: Eric E. <fre...@us...> - 2002-10-08 04:15:43
|
Update of /cvsroot/relay-bot/relay-bot In directory usw-pr-cvs1:/tmp/cvs-serv20562 Modified Files: relay-bot.config Log Message: Better examples of what can be done... Index: relay-bot.config =================================================================== RCS file: /cvsroot/relay-bot/relay-bot/relay-bot.config,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** relay-bot.config 4 Jul 2002 19:30:26 -0000 1.6 --- relay-bot.config 8 Oct 2002 04:15:35 -0000 1.7 *************** *** 8,12 **** # What channels to join; yes, can be used in multiple channels. One is best. # (Signons and signoffs have an issue with multiple channels) ! @relay_channels = ('#relaybot'); # simple hash -- key is "name", value is actual host to connect to. --- 8,15 ---- # What channels to join; yes, can be used in multiple channels. One is best. # (Signons and signoffs have an issue with multiple channels) ! @relay_channels = ('#relaybot', '#relay-bot'); ! ! %relay_channels_extra = ('#relaybot' => ['#relay-bot'], ! '#relay-bot' => ['#relaybot']); # simple hash -- key is "name", value is actual host to connect to. |