All pastes #338216 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-03 07:31 UTC
rendered paste body
sub getrule {
	my $pos = @_;
	printf ":LAKJDS: %d\n", @_;
	print $rules[2];
	printf ":LAKJDS: %s\n", $rules[$pos];
	return $rules[@_];
}

sub on_public {
    my ($self, $event) = @_;
    my @to = $event->to;
    my ($nick, $mynick) = ($event->nick, $self->nick);
    my ($arg) = ($event->args);

    # Note that $event->to() returns a list (or arrayref, in scalar
    # context) of the message's recipients, since there can easily be
    # more than one.
    
    print "<$nick> $arg\n";
	
	# Cut off whitespace
	$arg =~ s/^\s+//;
	$arg =~ s/\s+$//;

	
	if ($arg =~ /^\!rule([0-9]+)$/i) {
		if ($last <= time() - 5) {
			if ($1 > 0 && $1 <= scalar @rules) {
				my $pos = $1 - 1;
				my $posprint = $1;
				$self->privmsg($tojoin, "Rule $posprint: " . getrule($pos));
			}
			
			$last = time();
		}
	} elsif ($arg =~ /^\!rulesearch (.+)$/i) {
		my $string = $1;
		
		if ($last <= time() - 5) {
			my $x = 1;
			print getrule(9);
			foreach my $rule (@rules) {
				if ($rule =~ /$string/gi) {
					$self->privmsg($tojoin, "Rule $x: " . getrule(3));
				}
				$x++;
			}

			$last = time();
		}
	} elsif ($arg =~ /($bold|$underline|$color|$reverse)/) {
		$self->privmsg($tojoin, "No text formatting allowed, $nick.");
		$self->privmsg($tojoin, "Rule 3: " . getrule(3));
	}
}