Convos::Core::Connection - A Convos connection base class
Convos::Core::Connection is a base class for Convos connections.
See also Convos::Core::Connection::Irc.
$self->on(dialog => sub { my ($self, $dialog) = @_; });
Emitted when a new $dialog is created.
$self->on(me => sub { my ($self, $me) = @_; });
Emitted when information about the representation of "user" changes. $me contains:
$me
{ nick => $str, real_host => $str, version => $str, available_user_modes => $str, available_channel_modes => $str, }
Note that this hash is Convos::Core::Connection::Irc specific.
$self->on(message => sub { my ($self, $self, $msg) = @_; }); $self->on(message => sub { my ($self, $dialog, $msg) = @_; });
Emitted when a connection or dialog receives a new message. $msg will contain:
$msg
{ from => $str, message => $str, type => {action|notice|privmsg}, }
$self->on(state => sub { my ($self, $state, $reason) = @_; });
Emitted when the connection state change.
$self->on(dialog => sub { my ($self, $dialog, $info) = @_; });
Emitted when the dialog change state. $info will contain information about the change:
$info
{join => $nick} {nick => $new_new, renamed_from => $old_nick_lc} {part => $nick, message => $reason, kicker => $kicker} {part => $nick, message => $reason} {updated => true}
Convos::Core::Connection inherits all attributes from Mojo::Base and implements the following new ones.
$str = $self->id; $str = $class->id(\%attr);
Returns a unique identifier for a connection.
$obj = $self->messages;
Holds a Convos::Core::Dialog object with the conversation to the server.
$str = $self->name;
Holds the name of the connection.
$str = $self->protocol;
Holds the protocol name.
$url = $self->url;
Holds a Mojo::URL object which describes where to connect to. This attribute is read-only.
$user = $self->user;
Holds a Convos::Core::User object that owns this connection.
Convos::Core::Connection inherits all methods from Mojo::Base and implements the following new ones.
$self = $self->connect(sub { my ($self, $err) = @_ });
Used to connect to "url". Meant to be overloaded in a subclass.
$dialog = $self->dialog(\%attrs);
Returns a new Convos::Core::Dialog object or updates an existing object.
$objs = $self->dialogs;
Returns an array-ref of of Convos::Core::Dialog objects.
$self = $self->disconnect(sub { my ($self, $err) = @_ });
Used to disconnect from server. Meant to be overloaded in a subclass.
$dialog = $self->get_dialog($id); $dialog = $self->get_dialog(\%attrs);
Returns a Convos::Core::Dialog object or undef.
$self = Convos::Core::Connection->new(\%attrs);
Creates a new connection object.
$self = $self->participants("#target" => sub { my ($self, $err, $participants) = @_; });
Retrieves a list of participants in a room.
$self = $self->rooms({match => "name"}, sub { my ($self, $err, $list) = @_; });
Used to retrieve a list of Convos::Core::Dialog objects for the given connection.
$self = $self->save(sub { my ($self, $err) = @_; });
Will save "ATTRIBUTES" to persistent storage. See "save_object" in Convos::Core::Backend for details.
$self = $self->send($target => $message, sub { my ($self, $err, $any) = @_; });
Used to send a $message to $target. $message is a plain string and $target can be a user or room/channel name.
$message
$target
Meant to be overloaded in a subclass.
$self = $self->state($state, $message); $state = $self->state;
Holds the state of this object. $state can be "disconnected", "connected" or "queued" (default). "queued" means that the object is in the process of connecting or that it want to connect.
$state
$path = $self->uri;
Holds a Mojo::Path object, with the URI to where this object should be stored.
$str = $self->wanted_state; $self = $self->wanted_state("connected"); # or "disconnected"
The state that this connection should be in. "state" on the other hand reflects which state the connection is actually in.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
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.