Commit Diff


commit - 040156866f511f8b5b0f0ab5e6a5376f5fb72741
commit + 81b247118e0b04003b1233319a5eef2045abc56e
blob - /dev/null
blob + e3b5af9f1ea409d0ffc018ffb132eb4457dc3b26 (mode 644)
--- /dev/null
+++ lib/IRCNOW/IO/IRC.pm
@@ -0,0 +1,89 @@
+package IRCNOW::IO::IRC;
+use Exporter 'import';
+
+our @EXPORT_OK = qw(
+	putserv putservlocalnet whois ctcp cbind isstaff
+);
+
+
+#our %EXPORT_TAGS = (
+#);
+#Exporter::export_ok_tags('debug', '$verbosity', 'DateTime', 'eMail');
+
+sub putserv {
+	my( $bot, $text )=@_;
+	my $socket = $bot->{sock};
+	if ($text =~ /^([^:]+):([[:ascii:]]*)$/m) {
+		my ($cmd, $line) = ($1, $2);
+		my @lines = split /\r?\n/m, $line;
+		foreach my $l (@lines) {
+			print $socket "$cmd:$l\r\n";
+		}
+	} else {
+		print $socket "$text\r\n";
+	}
+}
+
+sub putservlocalnet {
+	my( $bot, $text )=@_;
+	my $botlocalnet;
+	foreach my $b (@bots) {
+		if($b->{name} =~ /^$localnet$/i) {
+			$botlocalnet = $b;
+			last;
+		}
+	}	
+	putserv($botlocalnet, $text);
+}
+
+sub whois {
+	my( $socket, $target )=@_;
+	print $socket "WHOIS $target $target\r\n";
+}
+
+sub ctcp {
+	my( $socket, $target )=@_;
+#	print $socket "PRIVMSG $target :".chr(01)."CLIENTINFO".chr(01)."\r\n";
+#	print $socket "PRIVMSG $target :".chr(01)."FINGER".chr(01)."\r\n";
+#	print $socket "PRIVMSG $target :".chr(01)."SOURCE".chr(01)."\r\n";
+	print $socket "PRIVMSG $target :".chr(01)."TIME".chr(01)."\r\n";
+#	print $socket "PRIVMSG $target :".chr(01)."USERINFO".chr(01)."\r\n";
+	print $socket "PRIVMSG $target :".chr(01)."VERSION".chr(01)."\r\n";
+#	print $socket "PRIVMSG $target :".chr(01)."PING".chr(01)."\r\n";
+}
+
+sub cbind {
+	my ($type, $flags, $cmd, $proc) = @_;
+	if ($type eq "pub") {
+		push(@{$call->{pub}}, {cmd => $cmd, proc => $proc});
+	} elsif ($type eq "msg") {
+		push(@{$call->{msg}}, {cmd => $cmd, proc => $proc});
+	} elsif ($type eq "notc") {
+		push(@{$call->{notc}}, {mask => $cmd, proc => $proc});
+	} elsif ($type eq "mode") {
+		push(@{$call->{mode}}, {mask => $cmd, proc => $proc});
+	} elsif ($type eq "join") {
+		push(@{$call->{join}}, {mask => $cmd, proc => $proc});
+	} elsif ($type eq "partcall") {
+		push(@{$call->{part}}, {mask => $cmd, proc => $proc});
+	} elsif ($type eq "pubm") {
+		push(@{$call->{pubm}}, {mask => $cmd, proc => $proc});
+	} elsif ($type eq "msgm") {
+		push(@{$call->{msgm}}, {mask => $cmd, proc => $proc});
+	}
+}
+
+sub isstaff {
+	my( $bot, $nick ) = @_;
+	if( !( $bot->{name} =~ /^$localnet$/i ) ) {
+		return 0;
+	}
+	foreach( @stafflist ) {
+		if( $nick eq $_ ) {
+			return 1;
+		}
+	}
+	return 0;
+}
+
+1;