tazirc rev 3

Add tazirc-lb - SliTaz IRC Log Bot
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jan 14 21:38:51 2014 +0100 (2014-01-14)
parents 533ffcc81327
children cc47a2b744c4
files README tazirc-lb
line diff
     1.1 --- a/README	Tue Jan 14 19:02:33 2014 +0000
     1.2 +++ b/README	Tue Jan 14 21:38:51 2014 +0100
     1.3 @@ -47,5 +47,18 @@
     1.4  use the --dest= option to set the output logs path.
     1.5  
     1.6  
     1.7 +Translation
     1.8 +-----------
     1.9 +To start a new translation please use msginit from the pot file directory.
    1.10 +Example for French/France locale (fr_FR):
    1.11 +
    1.12 +	$ msginit -l fr_FR -o fr.po -i tazbox.pot
    1.13 +	
    1.14 +To update all pot files when some new strings have been added (mainly for
    1.15 +developers before commit) and to update all translations from the pot file:
    1.16 +
    1.17 +	$ make pot && make msgmerge
    1.18 +
    1.19 +
    1.20  ================================================================================
    1.21  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tazirc-lb	Tue Jan 14 21:38:51 2014 +0100
     2.3 @@ -0,0 +1,74 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# TazIRC-lb - SliTaz IRC Log Bot : Keep it very small!
     2.7 +#
     2.8 +# Copyright 2014 (C) SliTaz GNU/Linux - BSD License
     2.9 +# Author: Christophe Lincoln <pankso@slitaz.org>
    2.10 +#
    2.11 +. /lib/libtaz.sh
    2.12 +
    2.13 +# Internationalization
    2.14 +TEXTDOMAIN='tazirc'
    2.15 +export TEXTDOMAIN
    2.16 +
    2.17 +# Help and usage
    2.18 +if [ ! "$1" ] || [ ! "$2" ]; then
    2.19 +	cat << EOT
    2.20 +
    2.21 +$(boldify "$(gettext 'Usage:')") $(basename $0) [host] [chan] [--option]"
    2.22 +
    2.23 +$(boldify "$(gettext 'Options:')")
    2.24 +  --nick=    $(gettext "Set the Bot IRC nickname")
    2.25 +  --mode=    $(gettext "Use specified mode. Default: +i")
    2.26 +  --port=    $(gettext "Use specified port. Default: 6667")
    2.27 +  --dest=    $(gettext "Logs files destination path")
    2.28 +
    2.29 +EOT
    2.30 +	exit 0
    2.31 +fi
    2.32 +
    2.33 +# Cmdline --options= are parsed by libtaz.sh
    2.34 +[ "$nick" ] || nick="TazIRC-lb"
    2.35 +[ "$mode" ] || mode="+i"
    2.36 +[ "$port" ] || port="6667"
    2.37 +[ "$dest" ] || dest="$(pwd)"
    2.38 +host="$1"
    2.39 +chan="$2"
    2.40 +send="$dest/$host/$chan/send.txt"
    2.41 +
    2.42 +# Clean up on exit
    2.43 +trap "echo 'Exiting...' && rm -f $send" SIGINT INT TERM
    2.44 +mkdir -p $(dirname $send)
    2.45 +
    2.46 +# Introduce me!
    2.47 +clear && boldify "$(gettext 'Connecting to:') $host #${chan}"
    2.48 +cat > ${send} << EOT
    2.49 +NICK $nick
    2.50 +USER $nick $mode * :$0
    2.51 +JOIN #$chan
    2.52 +EOT
    2.53 +
    2.54 +# Connect and handle server messages
    2.55 +tail -f ${send} | busybox nc ${host} ${port} | while read MESSAGE
    2.56 +do
    2.57 +	# New log file for each day
    2.58 +	logs="$dest/$host/$chan/$(date -u '+%F').log"
    2.59 +	case "$MESSAGE" in
    2.60 +		*NICK*) ;;
    2.61 +		*PRIVMSG*)
    2.62 +			# Display and log channel messages
    2.63 +			user=$(echo "${MESSAGE%!*}" | sed s'/://')
    2.64 +			text=$(echo "${MESSAGE#* :}")
    2.65 +			echo "[$(date -u '+%R')] $user: $text"
    2.66 +			echo "$(date -u '+%R')|$user|$text" >> ${logs} ;;
    2.67 +		PING*)
    2.68 +			# Responding to ping
    2.69 +			echo "PONG${MESSAGE#PING}" >> ${send} ;;
    2.70 +		*MODE*)
    2.71 +			echo "${MESSAGE#* }" ;;
    2.72 +		*)
    2.73 +			echo "${MESSAGE#* :}" ;;
    2.74 +	esac
    2.75 +done
    2.76 +
    2.77 +exit 0