File: irssilog-to-raw

package info (click to toggle)
ctrlproxy 3.0.7-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 1,668 kB
  • ctags: 2,045
  • sloc: ansic: 15,358; sh: 2,805; xml: 1,078; python: 346; makefile: 302; perl: 18
file content (24 lines) | stat: -rwxr-xr-x 921 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env perl
# Simple irssi-log to raw-irc converter
# (C) 2004 Jelmer Vernooij <jelmer@samba.org>
# Published under the GPLv3 or later

$target = shift or die("No channel/nick name specified");

while(<STDIN>) {
	$l = $_;
	if($l =~ /^(.{2}):(.{2}) -!- ([^ ]+) \[([^\]]+)\] has quit \[([^\]]+)\]/) {
		print ":$3!$4 QUIT :$5\r\n";
	} elsif($l =~ /^(.{2}):(.{2}) -!- ([^ ]+) \[([^\]]+)\] has joined ([^ ]+)/) {
		print ":$3!$4 JOIN $5\r\n";
		$hostmask{$3} = $4;
	} elsif($l =~ /^(.{2}):(.{2})  \* ([^ ]+) (.*)/) {
		$hostmask{$3} = "unknown" if !$hostmask{$3};
		print ":$3!" . $hostmask{$3} . " PRIVMSG $target :$4\r\n";
	} elsif($l =~ /^(.{2}):(.{2}) -!- ([^ ]+) \[([^\]]+)\] has left ([^ ]+) \[([^\]]*)\]/) {
		print ":$3!$4 PART $5 :$6\r\n";
	} elsif($l =~ /^(.{2}):(.{2}) <(.)([^>]+)> (.*)/) {
		$hostmask{$4} = "unknown" if !$hostmask{$4};
		print ":$4!" . $hostmask{$4} . " PRIVMSG $target :$5\r\n";
	}
}