SHOW:
|
|
- or go back to the newest paste.
| 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 => '[email protected]', | |
| 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 | - | $server->command("/MSG ".$target.": test");
|
| 21 | + | |
| 22 | my ($host, $port) = split(' ', $data);
| |
| 23 | ||
| 24 | $server->command("/MSG ".$target." Checking host: ".$host." and port ".$port." ");
| |
| 25 | my ($sock) = new | |
| 26 | IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,Proto=>'tcp'); | |
| 27 | if($sock) | |
| 28 | {
| |
| 29 | $server->command("/MSG ".$target." Online!");
| |
| 30 | } | |
| 31 | else {
| |
| 32 | ||
| 33 | } | |
| 34 | $server->command("/MSG ".$target." Offline!");
| |
| 35 | } | |
| 36 | } | |
| 37 | Irssi::signal_add_last('message public', 'cmd_check');
| |
| 38 | ||
| 39 | ||
| 40 | Irssi::command_bind check => sub {
| |
| 41 | my ($text) = @_; | |
| 42 | my ($args, $active_server, $witem) = @_; | |
| 43 | my ($host, $port) = split(' ', $text);
| |
| 44 | Irssi::print("Checking host: $host and port: $port");
| |
| 45 | my ($sock) = new | |
| 46 | IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,Proto=>'tcp'); | |
| 47 | if($sock) | |
| 48 | {
| |
| 49 | Irssi::print("Online");
| |
| 50 | } | |
| 51 | else | |
| 52 | {
| |
| 53 | Irssi::print("Offline");
| |
| 54 | } | |
| 55 | }; |