Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support from stdin

  • Loading branch information...
commit 145ef95cd7f2354515a54097d64c0ee140ea497c 1 parent 6ab89c8
@sharl authored
Showing with 14 additions and 2 deletions.
  1. +1 −0  README
  2. +13 −2 ircrelay
View
1  README
@@ -10,3 +10,4 @@ nick = foobar
* usage
$ ircrelay "#hacktheirc" "this is test message"
+$ cat README | ircrelay "#hacktheirc" -
View
15 ircrelay
@@ -19,10 +19,14 @@ my $PASS = $ini->{_}->{pass};
my $NICK = $ini->{_}->{nick};
if ($#ARGV != 1) {
- print STDERR "usage: " . basename($0) . " <channel> <message>\n";
+ print STDERR "usage: " . basename($0) . " <channel> <message | ->\n";
exit 1;
}
my ($channel, $message) = @ARGV;
+my @messages;
+if ($message eq '-') {
+ @messages = <STDIN>;
+}
my $irc = new Net::IRC;
my $conn = $irc->newconn(
@@ -35,7 +39,14 @@ sub on_connect {
my $self = shift;
$self->join($channel);
- $self->notice($channel, $message);
+ if ($#messages >= 0) {
+ for (@messages) {
+ $self->notice($channel, $_);
+ sleep(1); # avoid flood
+ }
+ } else {
+ $self->notice($channel, $message);
+ }
exit;
}
$conn->add_handler('endofmotd', \&on_connect);
Please sign in to comment.
Something went wrong with that request. Please try again.