## ## Put me in ~/.irssi/scripts, and then execute the following in irssi: ## ## /load perl ## /script load notify ## use strict; use Irssi; use vars qw($VERSION %IRSSI); use Data::Dumper; use Net::SMTP; $VERSION = "0.01"; %IRSSI = ( authors => 'Luke Macken/Michael Mayhew/vbatts', contact => 'lewk@csh.rit.edu/mmayhew@gmail.com/vbatts@hashbangbash.com', name => 'gmail_notify.pl', description => 'A notification script by Luked Macked hacked up by Michael Mayhew, and later vbatts', license => 'GNU General Public License', url => 'N/A', ); my $email_to = 'someuser@email.com'; my $email_from = 'someuser@email.com'; my $email_user = 'someuser'; my $email_hello_domain = 'email.com'; sub priv_notify { my ($address, $msg, $nick) = @_; my $chatnet = @$address{'chatnet'}; my $usermode_away = @$address{'usermode_away'}; return if ($usermode_away == 0); # Send away! #&send_mail($email_to, '[' . $chatnet . '] IRC Message: from ' . $nick, "On server: " . Dumper($address) . "\n" . $msg); &send_mail($email_to, '[' . $chatnet . '] IRC Message: from "' . $nick . '"', "Message: " . $msg); } Irssi::signal_add('message private', 'priv_notify'); sub notify { my ($dest, $text, $stripped) = @_; my $server = $dest->{server}; my $channel = $dest->{target}; my $chatnet = $server->{chatnet}; my $usermode_away = $server->{usermode_away}; return if ($usermode_away == 0); return if (!$server || !($dest->{level} & MSGLEVEL_HILIGHT)); # This regex removes items #$stripped =~ s/[^a-zA-Z0-9 .,!?\@:\>]//g; # Stashing the message, so it isn't destroyed my $msg = $stripped; # regex to get the usersname # I KNOW this regex could be better, but i'm lazy right now $stripped =~ s/^<(.*)> .*$/$1/g; my $nick = $stripped ; # Send away! &send_mail($email_to, "[$chatnet] $channel IRC Message: from \"$nick\"", $msg); } Irssi::signal_add('print text', 'notify'); sub send_mail { my $to = $_[0]; my $subject = $_[1]; my $body = $_[2]; my $from = $email_from; my $user = $email_user; #my $password = 'batchme'; my $smtp; if (not $smtp = Net::SMTP->new('localhost', Hello => $email_hello_domain, Timeout => 30, Debug => 0)) { die "Could not connect to server\n"; } #$smtp->auth($user, $password) # || die "Authentication failed!\n"; $smtp->mail($from . "\n"); my @recepients = split(/,/, $to); foreach my $recp (@recepients) { $smtp->to($recp . "\n"); } $smtp->data(); $smtp->datasend("From: " . $from . "\n"); $smtp->datasend("To: " . $to . "\n"); $smtp->datasend("Subject: " . $subject . "\n"); $smtp->datasend("\n"); $smtp->datasend($body . "\n"); $smtp->dataend(); $smtp->quit; }