#!/usr/bin/perl
#use strict;
# Copyright (c) 2002 Willem Penninckx.  All rights reserved.  This
# program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.


#To install this script, just copy it to ~/.xchat
#To load it, type "/load ~/.xchat/wp.pl" (withoud the "")
#but it will be started when you start xchat :-)

#To use it, type /wp <text>
IRC::register ("WP script", "1.0", "", ""); 
#IRC::print ("WP script loaded");
IRC::add_command_handler('wp', wpcmd);
sub wpcmd{
	my($teller)=3;
	my($tijd)=chr(2);
	my($pl);
	$_[0]=~s/\A[ \t]*//;
	$_[0]=~s/[ \t]*\Z//;
	my(@a)=split('' , $_[0]);
	for (@a){
		if ($_ eq ' '){
			$tijd.=' ';
		}else{
			$teller+=$pl;
			if ($teller > 12){
				$teller=11;
				$pl=-1;
			}
			if ($teller < 4){
				$teller=5;
				$pl=1;
			}
			$tijd.=chr(3) . $teller . $_;
		}
	}
	IRC::command($tijd);
	return 1;
}
