flush
[m6w6/btr] / bin / btr-irc-send
diff --git a/bin/btr-irc-send b/bin/btr-irc-send
new file mode 100755 (executable)
index 0000000..4b2259a
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env php
+<?php
+
+require __DIR__."/../lib/btr/irc.php";
+
+if ($argc != 3) {
+       fatal("Usage: %s <url|fifo> <message>\n", basename($argv[0]));
+}
+
+if (isfifo($argv[1])) {
+       file_put_contents($argv[1], $argv[2]);
+} else {
+       $bot = new Client($argv[1], function($bot) {
+               $bot->send($_SERVER["argv"][2]);
+       });
+       $bot->getSession()->onNumeric = function($origin, $event) use ($bot) {
+               if ($event == \irc\client\RPL_ENDOFNAMES) {
+                       $bot->getSession()->disconnect();
+               }
+       };
+       $bot->getSession()->run();
+}
+
+# vim: noet