[wiki] [sites] iibots: no need for a subprocess awk and all that - plain sh will do || Ivan c00kiemon5ter Kanakarakis

From: <hg_AT_suckless.org>
Date: Fri, 13 Jul 2012 00:37:26 +0200 (CEST)

changeset: 949:34bab83557e9
user: Ivan c00kiemon5ter Kanakarakis <ivan.kanak_AT_gmail.com>
date: Fri Jul 13 01:30:27 2012 +0300
files: tools.suckless.org/ii/bots.md
description:
iibots: no need for a subprocess awk and all that - plain sh will do


diff -r f5ad2131281f -r 34bab83557e9 tools.suckless.org/ii/bots.md
--- a/tools.suckless.org/ii/bots.md Fri Jul 13 00:33:44 2012 +0300
+++ b/tools.suckless.org/ii/bots.md Fri Jul 13 01:30:27 2012 +0300
_AT_@ -1,12 +1,11 @@
 Its very easy to write shell script based bots with ii. As a short example look at this:
 
- tail -f \\#<CHANNEL>/out |
- while read foo ; do
- name=$(echo $foo | awk '{print $2}' | sed 's,<\\(.*\\)>,\\1,')
- if awk 'BEGIN{srand(); exit rand()<.1)}' ; then
- echo "$name: WHAT??" ;
- fi;
- done
+ tail -f \\#<CHANNEL>/out |
+ while read -r date time nick mesg; do
+ nick="${nick#<}"
+ nick="${nick%>}"
+ printf "%s: WHAT??\n" "$nick"
+ done > \\#<CHANNEL>/in
 
 Its just spamming a channel but I guess your imagination is boundless.
 I also heard about people using it together with nagios to get the notifications into IRC.
Received on Fri Jul 13 2012 - 00:37:26 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:32:28 CEST