Advertisement
Aha2Y

Irssi::Perl

Feb 21st, 2012
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.98 KB | None | 0 0
  1. use Irssi;
  2. use Irssi::Irc;
  3. use strict;
  4. use vars qw($VERSION %IRSSI);
  5. use IO::Socket;
  6.  
  7. $VERSION = '1.5';
  8. %IRSSI = (
  9.     authors     => 'Aha2Y alias Shiny',
  10.     contact     => 'Aha2Y@Hush.com',
  11.     name        => 'Port checker',
  12.     description => 'Check if a port is open' .
  13.                    'or closed' .
  14.                    'Actualy my first script.',
  15.     license     => 'Aha2Y',
  16. );
  17.  
  18. sub cmd_check {
  19.         my ($server, $data, $nick, $mask, $target, $channel) =@_;
  20.     if ($data=~/^!check/){
  21. $server->command("/MSG ".$target.": test");
  22.  }
  23. }
  24. Irssi::signal_add_last('message public', 'cmd_check');
  25.  
  26.  
  27. Irssi::command_bind check => sub {
  28.   my ($text) = @_;
  29.   my ($args, $active_server, $witem) = @_;
  30.   my ($host, $port) = split(' ', $text);
  31.   Irssi::print("Checking host: $host and port: $port");
  32.   my ($sock) = new
  33.   IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,Proto=>'tcp');
  34.   if($sock)
  35.   {
  36.     Irssi::print("Online");
  37.     }
  38. else
  39. {
  40.   Irssi::print("Offline");
  41.   }
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement