summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc/scripts/irc
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/nc/scripts/irc')
-rw-r--r--src/usr.bin/nc/scripts/irc81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/usr.bin/nc/scripts/irc b/src/usr.bin/nc/scripts/irc
deleted file mode 100644
index e45942c0bc..0000000000
--- a/src/usr.bin/nc/scripts/irc
+++ /dev/null
@@ -1,81 +0,0 @@
1#! /bin/sh
2# $OpenBSD: irc,v 1.2 2001/01/29 01:58:12 niklas Exp $
3
4## Shit-simple script to supply the "privmsg <recipient>" of IRC typein, and
5## keep the connection alive. Pipe this thru "nc -v -w 5 irc-server port".
6## Note that this mechanism makes the script easy to debug without being live,
7## since it just echoes everything bound for the server.
8## if you want autologin-type stuff, construct some appropriate files and
9## shovel them in using the "<" mechanism.
10
11# magic arg: if "tick", do keepalive process instead of main loop
12if test "$1" = "tick" ; then
13# ignore most signals; the parent will nuke the kid
14# doesn't stop ^Z, of course.
15 trap '' 1 2 3 13 14 15 16
16 while true ; do
17 sleep 60
18 echo "PONG !"
19 done
20fi
21
22# top level: fire ourselves off as the keepalive process, and keep track of it
23sh $0 tick &
24ircpp=$!
25echo "[Keepalive: $ircpp]" >&2
26# catch our own batch of signals: hup int quit pipe alrm term urg
27trap 'kill -9 $ircpp ; exit 0' 1 2 3 13 14 15 16
28sleep 2
29
30sender=''
31savecmd=''
32
33# the big honkin' loop...
34while read xx yy ; do
35 case "${xx}" in
36# blank line: do nothing
37 "")
38 continue
39 ;;
40# new channel or recipient; if bare ">", we're back to raw literal mode.
41 ">")
42 if test "${yy}" ; then
43 sender="privmsg ${yy} :"
44 else
45 sender=''
46 fi
47 continue
48 ;;
49# send crud from a file, one line per second. Can you say "skr1pt kidz"??
50# *Note: uses current "recipient" if set.
51 "<")
52 if test -f "${yy}" ; then
53 ( while read zz ; do
54 sleep 1
55 echo "${sender}${zz}"
56 done ) < "$yy"
57 echo "[done]" >&2
58 else
59 echo "[File $yy not found]" >&2
60 fi
61 continue
62 ;;
63# do and save a single command, for quick repeat
64 "/")
65 if test "${yy}" ; then
66 savecmd="${yy}"
67 fi
68 echo "${savecmd}"
69 ;;
70# default case goes to recipient, just like always
71 *)
72 echo "${sender}${xx} ${yy}"
73 continue
74 ;;
75 esac
76done
77
78# parting shot, if you want it
79echo "quit :Bye all!"
80kill -9 $ircpp
81exit 0