Net::MRIM - Perl implementation of mail.ru agent protocol
This is a Perl implementation of the mail.ru agent protocol, which specs can be found at http://agent.mail.ru/protocol.html
To construct and connect to MRIM's servers:
my $mrim=Net::MRIM->new( Debug=>0, PollFrequency=>5 ); $mrim->hello();
To log in:
if (!$mrim->login("login\@mail.ru","password")) { print "LOGIN REJECTED\n"; exit; } else { print "LOGGED IN\n"; }
To authorize a user:
my $ret=$mrim->authorize_user("friend\@mail.ru");
To add a user to contact list (sends automatically auth request):
$ret=$mrim->add_contact("friend\@mail.ru");
To remove a user from contact list:
$ret=$mrim->remove_contact("friend\@mail.ru");
To send a message:
$ret=$mrim->send_message("friend\@mail.ru","hello");
To change user status:
$ret=$mrim->change_status(status);
Where status=0 means online and status=1 means away
Get information for a contact:
$ret=$mrim->contact_info("friend\@mail.ru");
Search for users:
$ret=$mrim->search_user(email, sex, country, online);
Where sex=(1|2), country can be found at http://agent.mail.ru/region.txt or in Net::MRIM::Data.pm, and online=(0|1)
Analyze the return of the message:
if ($ret->is_message()) { print "From: ".$ret->get_from()." Message: ".$ret->get_message()." \n"; } elsif ($ret->is_server_msg()) { print $ret->get_message()." \n"; }
Looping to get messages:
while (1) { sleep(1); $ret=$mrim->ping(); if ($ret->is_message()) { print "From: ".$ret->get_from()." Message: ".$ret->get_message()." \n"; } }
Disconnecting:
$mrim->disconnect();
Alexandre Aufrere <aau@cpan.org>
Copyright (c) 2007-2008 Alexandre Aufrere. This code may be used under the terms of the GPL version 2 (see at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html). The protocol remains the property of Mail.Ru (see at http://www.mail.ru).
To install Net::MRIM::Message, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::MRIM::Message
CPAN shell
perl -MCPAN -e shell install Net::MRIM::Message
For more information on module installation, please visit the detailed CPAN module installation guide.