[hackers] ii: new tip (= 52)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Sat, 03 Feb 2007 13:00:02 +0100

changeset: 52:71c3217e228f
tag: tip
user: nion_AT_h4447.serverkompetenz.net
date: Sat Feb 03 12:58:13 2007 +0100
files: FAQ README query.sh
description:
documentation fixes and query.sh added

diff -r e8133981d961 -r 71c3217e228f FAQ
--- a/FAQ Fri Feb 02 13:47:08 2007 +0100
+++ b/FAQ Sat Feb 03 12:58:13 2007 +0100
@@ -15,7 +15,22 @@ like a charm.
 like a charm.
 
 Which commands are supported?
- -----------------------------
+-----------------------------
 j (join or msg), t (topic), a (away), n (nick), l (leave). The missing are
 obsolete or can be easily used by typing the IRC commands itself (i.e. /WHO
 instead of /who).
+
+How can I recognize queries?
+----------------------------
+ii itself doesn't support this but the queries.sh script is an example
+of how to get the new and changed files in your irc directory.
+To get an instant notice of a new file other mechanisms like inotify/dnotify
+could be used as well but I was too lazy to try it out since the script
+is enough for me.
+
+What other fancy stuff can I do with ii?
+----------------------------------------
+It is very easy to write irc bots in ii:
+tail -f \#/out | while read foo; do name=echo $foo | awk '{print $2}' | sed 's,<\\(.*\\)>,\\1,'; if 0 -eq expr $RANDOM % 10 then echo "$name: WHAT??" ; fi; done
+This will just spam a channel but think about using nagios2irc or you can
+use ii to generate channel stats. Your imagination should be boundless.
diff -r e8133981d961 -r 71c3217e228f README
--- a/README Fri Feb 02 13:47:08 2007 +0100
+++ b/README Sat Feb 03 12:58:13 2007 +0100
@@ -6,11 +6,11 @@ In every directory a FIFO file (in) and
 In every directory a FIFO file (in) and and normal file (out)
 is placed.
 The in file is used to communicate with the servers and the out
-files includes the server messages. For every channel and every nick
+files include the server messages. For every channel and every nick
 name there will be new in and out files.
 The basic idea of this is to be able to communicate with an IRC
-server with basic command line tools.
-For example if you will join a channel just do echo "/j #channel" > in
+server with standard command line tools.
+For example if you want to join a channel just do echo "/j #channel" > in
 and ii creates a new channel directory with in and out file.
 
 Installation
@@ -36,6 +36,8 @@ If you use the next editor line for a ne
 If you use the next editor line for a new posting you can use ctrl-p for nick
 completion if you wrote the nick in the past.
 Thanks to Matthias Kopfermann for this hint.
+You can find an example of how this nested environment could look like on:
+http://nion.modprobe.de/blog/archives/440-Using-the-ii-irc-client.html
 
 Configuration
 -------------
diff -r e8133981d961 -r 71c3217e228f query.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/query.sh Sat Feb 03 12:58:13 2007 +0100
@@ -0,0 +1,30 @@
+#!/bin/sh
+# ----------------------------------------------------
+# Nico Golde <nico_AT_ngolde.de>
+# License: do whatever you want with this code
+# Purpose: locate new queries for the ii irc client
+# ----------------------------------------------------
+
+IRCPATH=$HOME/irc
+TMPFILE=$IRCPATH/queries.tmp
+
+if [ ! -f $TMPFILE ]; then
+ touch $TMPFILE
+fi
+
+echo "searching new query data"
+for i in `find $IRCPATH -newer $TMPFILE -name 'out'`
+do
+ grep -v '\-!\-' $i > /dev/null 2>&1 # if file doesnt just contain server stuff
+ if [ $? -ne 1 ]; then
+ # strip server, nickserv and channel out files
+ echo $i | egrep -v -i "nickserv|#|$IRCPATH/(irc\.freenode\.net|irc\.oftc\.net)/out" > /dev/null 2>&1
+ if [ $? -ne 1 ]; then
+ echo -e "new data in: $i\n========================================================"
+ tail -5 $i
+ read
+ fi
+ fi
+done
+
+touch $TMPFILE
Received on Sat Feb 03 2007 - 13:00:03 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:50 UTC