| Revision 376,
1.0 KB
checked in by pynchon, 3 years ago
(diff) |
|
another irc bot
|
-
Property svn:executable set to
*
|
| Rev | Line | |
|---|
| [376] | 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | # bot to stalk people on irc and tweet everything they say |
|---|
| 4 | |
|---|
| 5 | use warnings; |
|---|
| 6 | use strict; |
|---|
| 7 | |
|---|
| 8 | use Net::Twitter; |
|---|
| 9 | use POE; |
|---|
| 10 | use POE::Component::IRC::State; |
|---|
| 11 | use POE::Component::IRC::Plugin::AutoJoin; |
|---|
| 12 | |
|---|
| 13 | my $irc = POE::Component::IRC::State->spawn( |
|---|
| 14 | Nick => 'jmacm', |
|---|
| 15 | Username => 'jmacm', |
|---|
| 16 | Ircname => 'jmacm', |
|---|
| 17 | Server => 'irc.freenode.org', |
|---|
| 18 | Port => '6667',); |
|---|
| 19 | |
|---|
| 20 | POE::Session->create(package_states => [main => [qw(_start irc_public)]]); |
|---|
| 21 | |
|---|
| 22 | $poe_kernel->run(); |
|---|
| 23 | |
|---|
| 24 | sub _start { |
|---|
| 25 | $irc->plugin_add('Autojoin', |
|---|
| 26 | POE::Component::IRC::Plugin::AutoJoin->new( |
|---|
| 27 | Channels => ['#noisebridge'])); |
|---|
| 28 | |
|---|
| 29 | $irc->yield(register => qw(join public)); |
|---|
| 30 | $irc->yield('connect'); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | sub irc_public { |
|---|
| 34 | my $nick = (split /!/, $_[ARG0])[0]; |
|---|
| 35 | if ($nick eq 'ioerror') { |
|---|
| 36 | my $nt = Net::Twitter->new( |
|---|
| 37 | traits => [qw/API::REST OAuth/], |
|---|
| 38 | consumer_key => 'xxxxx', |
|---|
| 39 | consumer_secret => 'xxxxx', |
|---|
| 40 | access_token => 'xxxxx', |
|---|
| 41 | access_token_secret => 'xxxxx', |
|---|
| 42 | ); |
|---|
| 43 | $nt->update("<$nick> $_[ARG2]"); |
|---|
| 44 | } |
|---|
| 45 | return; |
|---|
| 46 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.