Chat-iFly
view release on metacpan or search on metacpan
lib/Chat/iFly.pm view on Meta::CPAN
=item avatar_uri
A URI string that references a picture used to identify the user.
=item profile_uri
A URI string that will link other users to this user's profile on the web site.
=item relationships_set
This allows you to set up buddy lists within the chat. It is a hash reference taking the form of:
{
1 => {
name => 'friend',
plural => 'friends',
valid_uids => ['user_id_1', 'user_id_5', 'user_id_3']
},
2 => {
name => 'co-worker',
plural => 'co-workers',
valid_uids => ['user_id_3', 'user_id_4', 'user_id_2']
},
}
=back
=back
=cut
sub get_key {
my ($self, $user) = @_;
my $result = from_json($self->post('/p/', {
api_key => $self->api_key,
uname => $user->{name},
uid => $user->{id} || 0,
image_path => $self->static_asset_base_uri.'/themes/'.$self->theme.'/images',
isLog => JSON::true,
whichTheme => 'blue',
enableStatus => JSON::true,
role => $user->{is_admin} ? 'admin' : ((exists $user->{custom_roles}) ? $user->{custom_roles} : 'normal'),
validState => ['available','offline','busy','idle'],
up => (exists $user->{avatar_uri}) ? $user->{avatar_uri} : $self->static_asset_base_uri.'/themes/'.$self->theme.'/images/default_avatar.png',
upl => (exists $user->{profile_uri}) ? $user->{profile_uri} : '#',
rel => (exists $user->{relationships_set}) ? 1 : undef,
valid_uids => $user->{relationships_set},
}));
$result->{uid} = $user->{id} || 0;
$result->{name} = $user->{name};
return $result;
}
=head2 update_settings( )
Updates the iFly servers with all the configured settings you passed into the constructor of this object. This must be called when you first start using this module, and also each time that you make changes to your settings.
=cut
sub update_settings {
my ($self) = @_;
return $self->post('/z/', {
api_key => $self->api_key,
enable_chatroom => $self->enable_chatroom,
theme => $self->theme,
notify_sound => $self->notification_sound,
smileys => $self->enable_smiley,
log_chat => $self->log_messages,
chat_topbar_color => $self->chat_topbar_color,
chat_topbar_text_color => $self->chat_topbar_text_color,
font_color => $self->font_color,
chat_list_header => $self->chat_list_header,
public_chatroom_header => $self->public_chatroom_header,
version => 'perl',
show_admin_list => $self->show_admin_list,
delmessage => $self->allow_clear_room_history,
clear => $self->allow_single_message_delete,
ufc => $self->allow_user_font_color,
guest_prefix => $self->anon_prefix,
use_stop_word_list => $self->use_stop_word_list,
stop_word_list => $self->stop_word_list,
});
}
=head2 get_message_thread(uid1, uid2)
Returns a hash reference of a message thread between two users.
=over
=item uid1
Required. The unique user id of the first user in the discussion.
=item uid2
Required. The unique user id of the second user in the discussion.
=back
=cut
sub get_message_thread {
my ($self, $uid1, $uid2) = @_;
ouch(441, 'uid1 required', 'uid1') unless $uid1;
ouch(441, 'uid2 required', 'uid2') unless $uid2;
return from_json($self->post('/q/', { api_key => $self->api_key, uid1 => $uid1, uid2 => $uid2} ));
}
=head2 get_message_inbox(uid)
Returns a hash reference containing the messages in the user's inbox.
=over
=item uid
The unique user id of the user who's inbox you want to retrieve.
=back
( run in 1.030 second using v1.01-cache-2.11-cpan-d7f47b0818f )