1# A simple script for all Norwegians who like to get
2# all incoming english text translated to Norwegian :D
3# Written by dpryo <hnesland@samsen.com>
4#
5# WARNING:
6# Dunno what freetranslation.com thinks about it ;D
7# ..so remember, this scripts sends ALL incoming public messages
8# as a webrequest to their server. That is, one request pr.
9# message you get. In other words, if somebody pubfloods 100 lines, you will
10# visit freetranslation.com 100 times ;)
11######
12#
13# There is at least one bug in it .. It doesn't check wether the
14# incoming text is english or not before it sends the request.
15#
16# Somebody could perhaps fix that?, since i'm a lazy asshole.
17#
18# Another thing, it doesn't handles channels or anything, so
19# I could call this a "Technology Preview" as all the big
20# guys are calling their software when it's in a buggy and
21# not-so-very-usefull stage of development :P
22#
23use Irssi;
24use LWP::Simple;
25use vars qw($VERSION %IRSSI);
26$translate =0;
27
28$VERSION = "0.2";
29%IRSSI = (
30	authors     => "Harald Nesland",
31	contact     => "hnesland\@samsen.com",
32	name        => "EngNoTranslate",
33	description => "Very simple script that sends incoming text to freetranslation.com for english->norwegian translation. May be modified to translate other languages.",
34	license     => "Public Domain",
35	url         => "http://www.satyra.net",
36	changed     => "Thu Apr 11 14:15:25 CEST 2002"
37);
38
39sub income {
40my ($server, $data, $nick, $mask, $target) = @_;
41		$eng = $data;
42	if($translate=1) {
43		$eng =~ s/ /+/ig;
44		chop($eng);
45		Irssi::command("/echo [$nick] $eng");
46		$result = get("http://ets.freetranslation.com:5081/?Sequence=core&Mode=txt&template=TextResults2.htm&Language=English/Norwegian&SrcText=$eng");
47		Irssi::command("/echo [$nick] $result");
48	}
49}
50
51sub trans {
52
53	if($translate =0) { $translate=1; } else { $translate =0; }
54}
55
56Irssi::signal_add("message public", "income");
57Irssi::command_bind("translate","trans");
58