[Relay-bot-cvs] CVS: relay-bot relay-bot.config,1.7,1.8 relay-bot.pl,1.30,1.31
Brought to you by:
freiheit
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; |