Guest User

Untitled

a guest
Apr 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use feature qw/say/;
  6. use FindBin::libs;
  7.  
  8. use AnyEvent;
  9. use AnyEvent::Wassr;
  10. use Config::Pit;
  11. use Encode qw/encode_utf8/;
  12. use Net::PingFM;
  13.  
  14. my $config = pit_get("wassr2pingfm" , require => {
  15. "username" => "your username on wassr",
  16. "password" => "your password on wassr",
  17. "user_key" => "your user_key on Ping.fm",
  18. "api_key" => "your api_key on Ping.fm",
  19. });
  20. die 'pit_get failed.' if !%$config;
  21. my $username = $config->{username} or die 'username not found.';
  22. my $password = $config->{password} or die 'password not found.';
  23. my $user_key = $config->{user_key} or die 'user_key not found.';
  24. my $api_key = $config->{api_key} or die 'api_key not found.';
  25.  
  26. my $wassr = AnyEvent::Wassr->new(
  27. username => $username,
  28. password => $password,
  29. );
  30.  
  31. my $pingfm = Net::PingFM->new(
  32. user_key => $user_key,
  33. api_key => $api_key,
  34. );
  35.  
  36. $wassr->reg_cb(
  37. show => sub {
  38. my ($wassr, @statuses) = @_;
  39. for my $status (reverse @statuses) {
  40. my $user = encode_utf8($status->{user}{screen_name});
  41. my $text = encode_utf8($status->{text});
  42. say "Updating Ping.fm to '$text'";
  43. $pingfm->post($text);
  44. }
  45. },
  46. error => sub {
  47. my ($wassr, $error) = @_;
  48. warn "Error: $error\n";
  49. },
  50. );
  51.  
  52. $wassr->receive_statuses_show;
  53. $wassr->start;
  54.  
  55. my $cv = AnyEvent->condvar;
  56. $cv->recv;
Add Comment
Please, Sign In to add comment