The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Convos::Core::Connection - Represents a connection to an IRC server

SYNOPSIS

  use Convos::Core::Connection;

  $c = Convos::Core::Connection->new(
         name => 'magnet',
         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:

ATTRIBUTES

name

Name of the connection. Example: "freenode", "magnet" or "efnet".

log

Holds a Mojo::Log object.

login

The username of the owner.

redis

Holds a Mojo::Redis object.

METHODS

new

Checks for mandatory attributes: "login" and "name".

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 "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_from_conversations

  @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.

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_endofwhois

Use data from "irc_rpl_whoisidle", "irc_rpl_whoisuser" and "irc_rpl_whoischannels".

irc_rpl_whoisidle

Store idle info internally. See "irc_rpl_endofwhois".

irc_rpl_whoisuser

Store user info internally. See "irc_rpl_endofwhois".

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

See "irc_join" in Mojo::IRC.

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

err_bannedfromchan

:electret.shadowcat.co.uk 474 nick #channel :Cannot join channel (+b)

err_nosuchchannel

:astral.shadowcat.co.uk 403 nick #channel :No such channel

err_nosuchnick

  :electret.shadowcat.co.uk 442 sender nick :No such nick

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
  :nick!user@host MODE yournick +i

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