Advertisement
Aha2Y

First Release, IRSSI Port checker (Public/Private)

Feb 21st, 2012
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.74 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 ($text) = @_;
  20.     my ($server, $data, $nick, $mask, $target, $channel) =@_;
  21.     if ($data=~/^!check/){
  22.         my ($message ,$host, $port) = split(' ', $data);
  23.         if ($port == "blank") { $server->command("notice ".$nick." Fail, Its !check [host] [port] you idiot!"); }
  24.         else {
  25.             my ($sock) = new
  26.             IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,Proto=>'tcp');
  27.             if($sock)
  28.             {
  29.                 $server->command("/MSG ".$target." ".$host.":".$port." = 3Online");
  30.             }
  31.             else
  32.             {
  33.                 $server->command("/MSG ".$target." ".$host.":".$port." = 4Offline");
  34.             }
  35.         }
  36.     }
  37.     if ($data=~/^!isup/){
  38.         my ($message ,$host) = split(' ', $data);
  39.             my ($sock) = new
  40.             IO::Socket::INET(PeerAddr=>$host,PeerPort=>80,Proto=>'tcp');
  41.             if($sock)
  42.             {
  43.                 $server->command("/MSG ".$target." ".$host." = 3Online");
  44.             }
  45.             else
  46.             {
  47.                 $server->command("/MSG ".$target." ".$host." = 4Offline");
  48.             }
  49.         }
  50. }
  51. Irssi::signal_add_last('message public', 'cmd_check');
  52.  
  53.  
  54. Irssi::command_bind check => sub {
  55.   my ($text) = @_;
  56.   my ($args, $active_server, $witem) = @_;
  57.   my ($host, $port) = split(' ', $text);
  58.   Irssi::print("Checking host: $host and port: $port");
  59.   my ($sock) = new
  60.   IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,Proto=>'tcp');
  61.   if($sock)
  62.   {
  63.     Irssi::print("Online");
  64.     }
  65. else
  66. {
  67.   Irssi::print("Offline");
  68.   }
  69. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement