# ho_easykline.pl # # $Id: ho_easykline.pl,v 1.4 2004/09/14 16:49:02 jvunder REL_0_3 $ # # Part of the Hybrid Oper Script Collection # # Easy K-lines. # use strict; use vars qw($VERSION %IRSSI $SCRIPT_NAME); use Irssi; use Irssi::Irc; # necessary for redirect_register() use HOSC::again; use HOSC::again 'HOSC::Base'; use HOSC::again 'HOSC::Tools'; $SCRIPT_NAME = 'easykline'; ($VERSION) = '$Revision: 1.4 $' =~ / (\d+\.\d+) /; %IRSSI = ( authors => 'Garion', contact => 'garion@efnet.nl', name => 'ho_easykline', description => 'Makes K-lining drones as easy as cake.', license => 'Public Domain', url => 'http://www.garion.org/irssi/hosc.php', changed => '25/02/2003 19:29', ); # Master switch to prevent accidents. my $enabled = 0; my $klineuseronly = 1; # --------------------------------------------------------------------- # catch a line typed in the easykline window, and process it. sub event_send_text { my ($data, $server, $witem) = @_; my $active_window = Irssi::active_win(); return unless $active_window->{name} eq "easykline"; if ($data =~ /^on$/i || $data =~ /^enable$/i) { ho_print_active("Enabling easy K-lines."); $enabled = 1; Irssi::signal_stop(); return; } if ($data =~ /^off$/i || $data =~ /^disable$/i) { ho_print_active("Disabling easy K-lines."); $enabled = 0; Irssi::signal_stop(); return; } if ($data =~ /^help$/i) { print_help(); Irssi::signal_stop(); return; } if ($data =~ /^time ([0-9]+)$/i) { set_kline_time($1); ho_print_active("Setting K-line time to $1."); Irssi::signal_stop(); return; } if ($data =~ /^reason (.+)$/i) { ho_print_active("Setting K-line reason to $1."); set_kline_reason($1); Irssi::signal_stop(); return; } if ($data =~ /^klineuser ?(.*)$/i) { if ($1 =~ /on/i || $1 == 1) { Irssi::settings_set_bool('ho_easykline_useronly', 1); ho_print_active('K-lining *user@host.'); } else { Irssi::settings_set_bool('ho_easykline_useronly', 0); ho_print_active('K-lining *@host.'); } Irssi::signal_stop(); return; } if ($data =~ /^status$/i) { show_status(); Irssi::signal_stop(); return; } if ($enabled == 0) { ho_print_active("Easy K-lines disabled. Type 'help' for help and 'on' to enable."); Irssi::signal_stop(); return; } kline_from_line($server, $data); } sub am_i_opered { return 0 unless Irssi::active_server(); return 1 if Irssi::active_server()->{server_operator} or Irssi::active_server()->{'usermode'} =~ /o/i; return 0; } sub set_kline_time { my ($time) = @_; Irssi::settings_set_int('ho_easykline_time', $time); } sub set_kline_reason { my ($reason) = @_; Irssi::settings_set_str('ho_easykline_reason', $reason); } sub show_status { my $klineuseronly = Irssi::settings_get_bool('ho_easykline_useronly'); my $klinetime = Irssi::settings_get_int('ho_easykline_time'); my $klinereason = Irssi::settings_get_str('ho_easykline_reason'); ho_print_active("Enabled is $enabled. Time is $klinetime."); if ($klineuseronly) { ho_print_active('K-lining *user@host.'); } else { ho_print_active('K-lining *@host.'); } ho_print_active("Reason is $klinereason."); } sub print_help { ho_print_active("Short help for now."); ho_print_active('Anything you paste in this window gets searched for '. 'user@host and those hostnames get K-lined.'); ho_print_active("Available settings: enable/disable, time, reason, ". "klineuseronly."); ho_print_active("Typing the following into this window will change settings:"); ho_print_active("on|off: turns the script on or off."); ho_print_active("time