NAME
Convos::Core::Connection - Represents a connection to an IRC server
SYNOPSIS
$c
= Convos::Core::Connection->new(
server
=>
'irc.localhost'
,
login
=>
'username'
,
redis
=> Mojo::Redis->new,
);
$c
->
connect
;
Mojo::IOLoop->start;
DESCRIPTION
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
"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", "irc_err_nosuchchannel" "irc_err_notonchannel" "irc_err_bannedfromchan", l</irc_error> and "irc_quit".
ATTRIBUTES
server
login
The username of the owner.
redis
Holds a Mojo::Redis object.
log
Holds a Mojo::Log object.
METHODS
new
Checks for mandatory attributes: "login" and "server".
connect
$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 "server" 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_from_conversations
@channels
=
$self
->channels_from_conversations(\
@conversations
);
This method returns an array ref of channels based on the conversations input. It will use "server" to filter out the right list.
add_server_message
$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.
add_message
$self
->add_message(\
%message
);
Will add a private message to the database.
disconnect
Will disconnect from the "irc" server.
EVENT HANDLERS
irc_rpl_welcome
Example message:
:Zurich.CH.EU.Undernet.Org 001 somenick :Welcome to the UnderNet IRC Network, somenick
irc_rpl_whoisuser
Reply with user info
irc_rpl_whoischannels
Reply with user channels
irc_rpl_notopic
:server 331 nick
#channel :No topic is set.
irc_rpl_topic
Reply with topic
irc_topic
:nick!~user
@hostname
TOPIC
#channel :some topic
irc_rpl_topicwhotime
Reply with who and when for topic change
irc_rpl_myinfo
Example message:
:Tampa.FL.US.Undernet.org 004 somenick Tampa.FL.US.Undernet.org u2.10.12.14 dioswkgx biklmnopstvrDR bklov
irc_join
irc_nick
:old_nick!~username@1.2.3.4 NICK :new_nick
irc_quit
{
params
=> [
'Quit: leaving'
],
raw_line
=>
':nick!~user@localhost QUIT :Quit: leaving'
,
command
=>
'QUIT'
,
prefix
=>
'nick!~user@localhost'
};
irc_part
irc_err_bannedfromchan
:electret.shadowcat.co.uk 474 nick #channel :Cannot join channel (+b)
irc_err_nosuchchannel
:astral.shadowcat.co.uk 403 nick #channel :No such channel
irc_err_notonchannel
:electret.shadowcat.co.uk 442 nick #channel :You're not on that channel
irc_rpl_namreply
Example message:
:Budapest.Hu.Eu.Undernet.org 353 somenick = #html :somenick Indig0 Wildblue @HTML @CSS @Luch1an @Steaua_ Indig0_ Pilum @fade
irc_rpl_liststart
:servername 321 fooman Channel :Users Name
irc_rpl_list
:servername 322 somenick #channel 10 :[+n] some topic
irc_rpl_listend
:servername 323 somenick :End of /LIST
irc_mode
:nick!user
@host
MODE
#channel +o othernick
irc_error
Example message:
ERROR :Closing Link: somenick by Tampa.FL.US.Undernet.org (Sorry, your connection class is full - try again later or try another server)
cmd_nick
Handle nick commands from user. Change nick and set new nick in redis.
cmd_join
Handle join commands from user. Add to channel set.
COPYRIGHT
See Convos.
AUTHOR
Jan Henning Thorsen
Marcus Ramberg