1. Evan Gates
  2. pcw

Commits

Evan Gates  committed 9c421a7

add chat.sh script

  • Participants
  • Parent commits 1aa3c38
  • Branches default

Comments (0)

Files changed (1)

File extras/chat.sh

View file
  • Ignore whitespace
+#!/bin/sh
+
+# SERVERS should be a file with a list of "server nick" pairs with a list of
+# "fifo command" pairs for each. Each server block should be separated by a new
+# line. I do not do any error checking for you, don't screw up the format.
+# For example:
+#
+# irc.oftc.net mynick
+# in /j nickserv identify mypass
+# nickserv/in /l
+# in /j #somechannel
+# in /j #anotherchannel
+# #somechannel/in hello channel
+#
+# localhost differentnick
+# &bitlbee/in identify diffpass
+# &bitlbee/in blist
+
+PREFIX="$HOME/irc"
+SERVERS="$PREFIX/servers"
+
+while read line; do
+	serv="${line%% *}"
+	nick="${line#* }"
+
+	# start ii first, so we don't hang trying to write to the fifo
+	while true; do
+		ii -n "$nick" -s "$serv" -i "$PREFIX" 
+		[ $? -eq 2] || break # only restart ii on timeout (not default for ii)
+	done &
+
+	while read line; do
+		[ -n "$line" ] || break # stop on empty line
+		fifo="${line%% *}"
+		cmd="${line#* }"
+		echo "$cmd" > "$PREFIX/$serv/$fifo"
+	done
+done