Net-YMSG

 view release on metacpan or  search on metacpan

YMSG.pm  view on Meta::CPAN

	if(! defined $self->identifier) {
	print STDERR "ERROR:Identifier Not Found";
	}
	my $server=$self->get_connection();
	my $num=$server->send($msg,0);
	
      
}


=head2 $yahoo->change_state($busy, $status_message)

This method sets the I<status messages> for the current user. 'Status message' is set by C<$status_message>. 'Busy icon' is set by the numerical value of C<$busy>.

The C<$busy> should be called with following arguments:

	0 - I'm Available
	1 - Busy
	2 - Sleep

=cut

sub change_state
{
	my $self = shift;
	my $busy = shift;
	my $message = join '', @_;
	my $server = $self->handle;

	my $event = $self->create('ChangeState');
	$event->status_code(99);    # 99 : Custom status
	$event->busy($busy);
	$event->body($message);

	$server->send($event->to_raw_string, 0);
}


sub change_status_by_code
{
	my $self = shift;
	my $status_code = shift || 0;
	my $server = $self->handle;

	my $event = $self->create('ChangeState');
	$event->status_code($status_code);
	$event->busy(1);

	$server->send($event->to_raw_string, 0);	
}


sub ping
{
	my $self = shift;
	my $server = $self->get_connection;
	my $command = $self->_create_message(

YMSG.pm  view on Meta::CPAN

	use Net::YMSG;
	use strict;
	use constant IN_BUSY => 1;
	
	my $yahoo = Net::YMSG->new(
		id       => 'yahoo_id',
		password => 'password',
	);
	$yahoo->login or die "Can't login Yahoo!Messenger";;
	
	$yahoo->change_state(IN_BUSY, q{I'm very busy now!});
	sleep 5;
	__END__

=head2 Become Invisible

	#!perl
	use Net::YMSG;
	use strict;
	
	my $yahoo = Net::YMSG->new(

YMSG/Buddy.pm  view on Meta::CPAN

use constant IS_ONLINE  => 1;
use constant IS_OFFLINE => 0;

sub new
{
	my $class = shift;
	bless {
		name          => 'nobody',
		status        => IM_AVAILABLE,
		custom_status => '',
		busy          => ICON_AVAILABLE,
		online        => IS_OFFLINE,
		session_id    => 0,
	}, $class;
}


sub name
{
	my $self = shift;
	$self->{name} = shift if @_;
	$self->{name};
}


sub status
{
	my $self = shift;
	if (@_) {
		$self->{status} = shift;
		$self->busy(ICON_BUSY) if $self->{status} <= STEPPED_OUT;
		$self->busy(ICON_SLEEP) if $self->{status} == SLEEP;
		$self->busy(ICON_AVAILABLE) if $self->{status} == CUSTOM_STATUS
									|| $self->{status} == IM_AVAILABLE;
	}
	$self->{status};
}


sub custom_status
{
	my $self = shift;
	if (@_) {
		$self->{custom_status} = shift;
		$self->status(CUSTOM_STATUS);
	}
	$self->{custom_status};
}


sub busy
{
	my $self = shift;
	if (@_) {
		$self->{busy} = shift;
	}
	$self->{busy};
}


sub online
{
	my $self = shift;
	if (@_) {
		$self->{online} = shift;
	}
	$self->{online};

YMSG/Buddy.pm  view on Meta::CPAN

	}
}



sub to_string
{
	my $self = shift;
	if ($self->is_online) {
		return sprintf "%s %s (%s)",
			$self->busy == ICON_AVAILABLE ? ':->'
				: $self->busy == ICON_BUSY ? ':-@'
				: $self->busy == ICON_SLEEP ? ':-Z'
				: '?',
			$self->name,
			$self->get_status_message;
	} else {
		return sprintf "%s %s (%s)",
			'   ',
			$self->name,
			'Not online';
	}
}

YMSG/ChangeState.pm  view on Meta::CPAN

	my $self = shift;
	if (@_) {
		$self->SUPER::source(@_);
		my $yahoo = $self->get_connection;
		my $buddy = $yahoo->get_buddy_by_name($self->from);
		return unless $buddy;

		$buddy->status($self->status_code);
		if ($self->status_code == 99) {
			$buddy->custom_status($self->body);
			$buddy->busy($self->busy);
		}
	}
	$self->SUPER::source();
}

sub from
{
	my $self = shift;
	$self->_set_by_name('BUDDY_ID', shift) if @_;
	$self->_get_by_name('BUDDY_ID');
}


sub body
{
	my $self = shift;
	$self->_set_by_name('STATUS_MESSAGE', shift) if @_;
	$self->_get_by_name('STATUS_MESSAGE');
}

sub busy
{
	my $self = shift;
	$self->_set_by_name('BUSY_CODE', shift) if @_;
	$self->_get_by_name('BUSY_CODE');
}

sub status_code
{
	my $self = shift;
	$self->_set_by_name('STATUS_CODE', shift) if @_;

YMSG/EventFactory.pm  view on Meta::CPAN

			if ($baddy[$i] eq BADDY_NAME) {
				$buddy = $connection->get_buddy_by_name($baddy[$i+1]);
			}
			elsif ($baddy[$i] eq STATE) {
				$buddy->status($baddy[$i+1]);
			}
			elsif ($baddy[$i] eq STATE_OF_USER_DEFINITION) {
				$buddy->custom_status($baddy[$i+1]);
			}
			elsif ($baddy[$i] eq BUSYNESS) {
				$buddy->busy($baddy[$i+1]);
			}
			elsif ($baddy[$i] eq SESSION_ID) {
				$buddy->session_id($baddy[$i+1]);
			}
			elsif ($baddy[$i] eq ONLINE_OR_OFFLINE) {
				$buddy->online($baddy[$i+1]);
			}
			else {}
		}
		return $event;

example/yahoo.pl  view on Meta::CPAN

		  exit;

	 }
}

sub ChangeState
{
	 my $self = shift;
	 my $event = shift;

	 my $busy_status = $event->busy == 1 ?
		  '(Busy) ' :
		  $event->busy == 2 ?
		  '(Sleep) ' : '';

	 my $message;
	 if ($event->status_code == 99) {
		  $message = sprintf "[%s] %sTransit to '%s'\n",
		  $event->from, $busy_status, $event->body;
	 }
	 else {
		  $message = sprintf "[%s] %sTransit to '%s'\n",
		  $event->from, $busy_status, STATUS_MESSAGE->[$event->status_code]; 
	 }
	 print $message;
}


sub NewFriendAlert
{
	 my $self = shift;
	 my $event = shift;



( run in 0.302 second using v1.01-cache-2.11-cpan-87723dcf8b7 )