OSX compatibility
[m6w6/btr] / bin / btr-irc-send
1 #!/usr/bin/env php
2 <?php
3
4 require __DIR__."/../share/btr/irc.php";
5
6 if ($argc != 3) {
7 fatal("Usage: %s <url|fifo> <message>\n", basename($argv[0]));
8 }
9
10 if (isfifo($argv[1])) {
11 file_put_contents($argv[1], $argv[2]);
12 } else {
13 $bot = new Client($argv[1], function($bot) {
14 $bot->send($_SERVER["argv"][2]);
15 });
16 $bot->getSession()->onNumeric = function($origin, $event) use ($bot) {
17 if ($event == \irc\client\RPL_ENDOFNAMES) {
18 $bot->getSession()->disconnect();
19 }
20 };
21 $bot->getSession()->run();
22 }
23
24 # vim: noet