Convos::Core::Connection - Represents a connection to an IRC server
use Convos::Core::Connection; $c = Convos::Core::Connection->new( name => 'magnet', login => 'username', redis => Mojo::Redis->new, ); $c->connect; Mojo::IOLoop->start;
This module use Mojo::IRC to up a connection to an IRC server. The attributes used to do so is figured out from a redis server.
There are quite a few EVENTS that this module use:
"add_message" events
"privmsg" in Mojo::IRC.
"add_server_message" events
"rpl_yourhost" in Mojo::IRC, "rpl_motdstart" in Mojo::IRC, "rpl_motd" in Mojo::IRC, "rpl_endofmotd" in Mojo::IRC, "rpl_welcome" in Mojo::IRC and "error" in Mojo::IRC.
Other events
"irc_rpl_welcome", "irc_rpl_myinfo", "irc_join", "irc_part", "irc_rpl_namreply", "err_nosuchchannel", "err_notonchannel", "err_nosuchnick" "err_bannedfromchan", l</irc_error> and "irc_quit".
Name of the connection. Example: "freenode", "magnet" or "efnet".
Holds a Mojo::Log object.
The username of the owner.
Holds a Mojo::Redis object.
Checks for mandatory attributes: "login" and "name".
$self = $self->connect;
This method will create a new Mojo::IRC object with attribute data from "redis". The values fetched from the backend is identified by "name" and "login". This method then call "connect" in Mojo::IRC after the object is set up.
Attributes fetched from backend: nick, user, host and channels. The latter is set in "channels" and used by "irc_rpl_welcome".
@channels = $self->channels_from_conversations(\@conversations);
This method returns an array ref of channels based on the conversations input. It will use "name" to filter out the right list.
$self->add_server_message(\%message);
Will look at %message and add it to the database as a server message if it looks like one. Returns true if the message was added to redis.
$self->add_message(\%message);
Will add a private message to the database.
Will disconnect from the "irc" server.
Example message:
:Zurich.CH.EU.Undernet.Org 001 somenick :Welcome to the UnderNet IRC Network, somenick
Use data from "irc_rpl_whoisidle", "irc_rpl_whoisuser" and "irc_rpl_whoischannels".
Store idle info internally. See "irc_rpl_endofwhois".
Store user info internally. See "irc_rpl_endofwhois".
Reply with user channels
:server 331 nick #channel :No topic is set.
Reply with topic
:nick!~user@hostname TOPIC #channel :some topic
Reply with who and when for topic change
:Tampa.FL.US.Undernet.org 004 somenick Tampa.FL.US.Undernet.org u2.10.12.14 dioswkgx biklmnopstvrDR bklov
See "irc_join" in Mojo::IRC.
:old_nick!~username@1.2.3.4 NICK :new_nick
{ params => [ 'Quit: leaving' ], raw_line => ':nick!~user@localhost QUIT :Quit: leaving', command => 'QUIT', prefix => 'nick!~user@localhost' };
:electret.shadowcat.co.uk 474 nick #channel :Cannot join channel (+b)
:astral.shadowcat.co.uk 403 nick #channel :No such channel
:electret.shadowcat.co.uk 442 sender nick :No such nick
:electret.shadowcat.co.uk 442 nick #channel :You're not on that channel
:Budapest.Hu.Eu.Undernet.org 353 somenick = #html :somenick Indig0 Wildblue @HTML @CSS @Luch1an @Steaua_ Indig0_ Pilum @fade
:servername 321 fooman Channel :Users Name
:servername 322 somenick #channel 10 :[+n] some topic
:servername 323 somenick :End of /LIST
:nick!user@host MODE #channel +o othernick :nick!user@host MODE yournick +i
ERROR :Closing Link: somenick by Tampa.FL.US.Undernet.org (Sorry, your connection class is full - try again later or try another server)
Handle nick commands from user. Change nick and set new nick in redis.
Handle join commands from user. Add to channel set.
See Convos.
Jan Henning Thorsen
Marcus Ramberg
To install Convos, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Convos
CPAN shell
perl -MCPAN -e shell install Convos
For more information on module installation, please visit the detailed CPAN module installation guide.