All pastes #285830 Raw Edit

poke.pl

public text v1 · immutable
#285830 ·published 2006-12-20 02:24 UTC
rendered paste body
use Data::Dumper;
use strict;

use vars qw!$VERSION %IRSSI!;

use Irssi qw!signal_add!;

signal_add("event privmsg", "irc_privmsg");

$VERSION = '0.01';
%IRSSI = (
	authors		=> 'Justin Lee',
	contact		=> 'kool.name@gmail.com',
	name		=> 'pokething',
	description	=> 'Scipt for automessaging when poked!!',
	license		=> 'GPL',
);

sub irc_privmsg {
	my ($server, $data, $from, $address) = @_;
	my ($to, $msg) = split(/\s+:/, $data, 2);
	my $target = find_target($to, $from);
	if ($target) {
		if ($msg =~ /!poke/) {
			$server->command("MSG $target :O!! YOU POKED ME!");
		}
	}
	return 1;
}

sub find_target {
	my ($to, $from) = @_;

	if($to =~ /^(#|&)/){
		return 0; # from a channel do not SEND_AWAY
	}
	return $from; # from a private message
}