chiark / gitweb /
Set socketargs to {}.
[ircbot] / summon-write.pl
... / ...
CommitLineData
1#!/usr/bin/perl
2
3sub fault ($) { print STDERR "$_[0]\n"; exit 8; }
4
5@ARGV==5 or fault("invalid arguments to $0");
6($line,$idlesince,$nick,$path,$chan) = @ARGV;
7
8open X, ">&0" or fault("reopen stdin for output: $!");
9
10$timestring= localtime time;
11
12pline("\a");
13pline("You are cordially invited onto the system's IRC server by \`$nick'");
14pline("($path) at $timestring");
15pline("If you don't know how to use IRC, run \`irc <your-nickname> chiark'");
16pline("When you are on-line, please ".
17 (length $chan ? "join $chan." : "send a private note to $nick."));
18pline("");
19
20close X or outfail();
21
22print "ok $line $idlesince\n";
23exit 0;
24
25sub pline ($) {
26 my ($s) = @_;
27 print X "\r", " "x78, "\r $s\r\n" or outfail();
28}
29
30sub outfail () {
31 if ($! == &EAGAIN || $! == &EWOULDBLOCK) {
32 print "failed has a congested terminal\n";
33 exit 0;
34 } else {
35 print "failed has a broken terminal ($!)\n";
36 exit 0;
37 }
38}