I tried to set up a little notification daemon in one of my projects: It should send a message to my GoogleTalk account for special events and that should be easy using one of the huge amount of Jabber/XMPP modules on CPAN.I asked Google for help and found this really good sample script made by Marco Fontani. My notifier will run on a old server running an old Perl – installation of CPAN modules isn’t fun over there because many require a newer Perl and I can’t upgrade this, but the sample requires only four modules: Net::XMPP, XML::Stream, Authen::SASL and IO::Socket::SSL.
The script expects some arguments but I changed it because passing username and password (which are quite static) isn’t that good (I think). Here is a small patch which changes the script to fixed data:
my $username = 'your.google.username'; #shift or die "$0: username needed"; my $password = 'your_google_password'; #shift or die "$0: password needed"; my $resource = 'notify v1.0'; #shift or die "$0: client handle needed";
Oh right, sending a message from myself to myself isn’t that good (I don’t know if Google supports it at all), a new GTalk account would be better. Go to Google+ and sign up for a new account for the notifier and remember to add your (recipient) account as a Google Talk partner (the script won’t send or reply a “friend” request).
I tried the script after successfully sending a chat message from the Google+ website to my Google Talk account (which is set up in my Pidgin messenger) – but it didn’t work. The login succeeded but the message didn’t pop up in Pidgin. I logged back into G+ and saw my message (as outgoing) but I had to reply from Pidgin (to mark the chat as “insecure”) and switch to @googlemail.com instead of @gmail.com for the recipient address before messages from the script hit my desktop (and mobile with running GTalk app).
Setting up the script was more easy than expected (I should have done this much earlier), thanks to Marco and his sample script, but I don’t want to write it myself from scratch after looking at the Net::XMPP documentation (which is very…