Guest User

Untitled

a guest
Nov 24th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use POE;
  7. use POE::Component::IRC::State;
  8. use POE::Component::IRC::Plugin::AutoJoin;
  9.  
  10. POE::Session->create(
  11. package_states => [
  12. main => [ qw(_start irc_join) ]
  13. ]
  14. );
  15.  
  16. $poe_kernel->run();
  17.  
  18. sub _start {
  19. my $irc = POE::Component::IRC::State->spawn(
  20. Nick => 'basic_bot',
  21. Server => 'irc.freenode.net',
  22. );
  23.  
  24. $irc->plugin_add('AutoJoin', POE::Component::IRC::Plugin::AutoJoin->new(
  25. Channels => [ '#test_channel1', '#test_channel2' ]
  26. ));
  27.  
  28. $irc->yield(register => 'join');
  29. $irc->yield('connect');
  30. }
  31.  
  32. sub irc_join {
  33. my $nick = (split /!/, $_[ARG0])[0];
  34. my $channel = $_[ARG1];
  35. my $irc = $_[SENDER]->get_heap();
  36.  
  37. # only send the message if we were the one joining
  38. if ($nick eq $irc->nick_name()) {
  39. $irc->yield(privmsg => $channel, 'Hi everybody!');
  40. }
  41. }
Add Comment
Please, Sign In to add comment