irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit d69c451180e932f9b21575e33e8953262b938041
parent ed21d0fee0294eeb386c030f7cd22b762791b1ad
Author: Antoine Amarilli <ant.amarilli@free.fr>
Date:   Sat, 22 Jan 2011 18:08:03 +0100

added README

Diffstat:
README | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,84 @@ +irctk is a general-purpose IRC wrapper. It connects to an IRC server +specified as [NICK@]SERVER[:PORT] as a CLI argument, posts what it +receives from stdin and displays what is said to stdout. + +To compile, you need libircclient. + +TODO this code isn't tested, complete, secure, optimal or whatever + +TODO these examples aren't secure!! + +Examples: (we assume that fifo is a fifo, ie. run mkfifo fifo) + + $ irctk logger@example.com #chan1 #chan2 > irc.log + +Log what is said on #chan1 and #chan2 on example.com. Lines will be of +the form "[#chan1] <nick> message". + + $ irctk logger@example.com #chan1 #chan2 | while read line; do + CHAN=$(echo "$line" | cut -d ']' -f 1 | cut -d '[' -f 2) + MSG=$(echo "$line" | cut -d ' ' -f 2-) + echo "`date +%s` $MSG" >> $CHAN.log + done + +Same, but write in one file per chan, and add timestamps. + + $ cat suicide_note.txt | irctk you@example.com #chat + +Prepare your suicide note in a text file, and post it all at once before +killing yourself. + + $ while read line; do cowsay $line; done | irctk cow@example.com #flood + +Talk like a cow. + + $ cat suicide_note.txt | while read line; do cowsay $line; done \ + | irctk you@example.com #chat + +See above. + + $ rsstail -u 'http://feeds2.feedburner.com/fmylife' -NdzH -n 1 -i 300 \ + | grep --line-buffered '^ Today' \ + | ./irctk2 fmlbot@example.com '#fml' + +Post FMLs on irc. + + $ cat fifo | ./irctk pongbot@example.com '#chat' \ + | cut -d '>' -f 2- + | grep --line-buffered 'ping' \ + | while read line; do echo "pong"; done \ + | tee fifo + +TOTEST answer "pong" whenever someone says something containing "ping". + + $ cat fifo | ./irctk -r pongbot@example.com '#chat' \ + | cut -d '>' -f 2- + | grep --line-buffered 'ping' \ + | while read line; do + echo "nite"; echo; + done | tee fifo + +TOTEST same, but address the message specifically to the person. TOTEST +Explain the "echo". + + $ cat fifo | ./irctk -Ffr wikibot@example.com '#chat' \ + | while read line; do + Q=$(echo "$line" | tr -dc 'a-zA-Z_()'); + echo -n "$Q: "; + dig +short txt $Q.wp.dg.cx; echo; + done | tee fifo + +TOTEST A bot which queries on wikipedia whatever is said to him + + $ cat fifo | ./irctk -Ff DM@example.com '#adventure' \ + | while true; do + socat EXEC:adventure,pty,ctty,echo=0 STDIO; + done | tee fifo + +TOTEST Multiplayer adventure! (Beware, people can overwrite files when +saving their game.) The "while true" loop is to restart the game +whenever someone exits. The socat invocation is used to disable +buffering. + +netcat +