NAME

WWW::Omegle - Perl interface www.omegle.com

SYNOPSIS

use WWW::Omegle;
my $ombot = WWW::Omegle->new(
                           on_connect    => \&connect_cb,
                           on_chat       => \&chat_cb,
                           on_disconnect => \&disconnect_cb,
                           );

$ombot->start;
while ($ombot->get_next_event) { 1; }
exit;

sub connect_cb {
  my ($om) = @_;
  print "Connected\n";
  $om->say('Hello, sir!');
}

sub chat_cb {
  my ($om, $what) = @_;
  print ">> $what\n";
}

sub disconnect_cb {
  my ($om) = @_;
  print "Disconnected.\n";
}

DESCRIPTION

This is a perl interface to the backend API for www.omegle.com. This module lets you easily script chating with random, anonymous people around the world. Note that this uses an unofficial API and is subject to breakage if the site author chooses to change their interface.

EXPORT

None by default.

METHODS

new(%opts)

Construct a new Omeglebot. Supported options are on_chat, on_disconnect and on_connect, which must be coderefs. See synopsis for usage examples. Other %opts are passed to the WWW::Mechanize constructor

set_callback($action, $callback, @userdata)

Sets the callback for $action, where $action is 'connect, 'chat' or 'disconnect'. @userdata is user-supplied opaque data that will be bassed to the callback.

start

Begins a chat with a random stranger. Returns success/failure.

say($message)

Says something to your chat buddy. Returns success/failure

disconnect

Terminates your conversation.

get_next_event

Fetches the next event and dispatches to the appropriate callback. See synopsis. This method will block while waiting for the next event.

run_event_loop

Sit and process events forever. Only useful for simple, callback-based scripts

poke

Check for events that have been received and flush event queue. Call this method frequently in your main loop if you are not using run_event_loop()

SEE ALSO

WWW::Mechanize

AUTHOR

Mischa Spiegelmock, <revmischa@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Mischa Spiegelmock

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.