# HG changeset patch # User Christophe Lincoln # Date 1389731931 -3600 # Node ID 3b881ac9348441756a64dc637af027d4b5410c3a # Parent 533ffcc81327fe45c8291ef42f22b74078141544 Add tazirc-lb - SliTaz IRC Log Bot diff -r 533ffcc81327 -r 3b881ac93484 README --- a/README Tue Jan 14 19:02:33 2014 +0000 +++ b/README Tue Jan 14 21:38:51 2014 +0100 @@ -47,5 +47,18 @@ use the --dest= option to set the output logs path. +Translation +----------- +To start a new translation please use msginit from the pot file directory. +Example for French/France locale (fr_FR): + + $ msginit -l fr_FR -o fr.po -i tazbox.pot + +To update all pot files when some new strings have been added (mainly for +developers before commit) and to update all translations from the pot file: + + $ make pot && make msgmerge + + ================================================================================ diff -r 533ffcc81327 -r 3b881ac93484 tazirc-lb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazirc-lb Tue Jan 14 21:38:51 2014 +0100 @@ -0,0 +1,74 @@ +#!/bin/sh +# +# TazIRC-lb - SliTaz IRC Log Bot : Keep it very small! +# +# Copyright 2014 (C) SliTaz GNU/Linux - BSD License +# Author: Christophe Lincoln +# +. /lib/libtaz.sh + +# Internationalization +TEXTDOMAIN='tazirc' +export TEXTDOMAIN + +# Help and usage +if [ ! "$1" ] || [ ! "$2" ]; then + cat << EOT + +$(boldify "$(gettext 'Usage:')") $(basename $0) [host] [chan] [--option]" + +$(boldify "$(gettext 'Options:')") + --nick= $(gettext "Set the Bot IRC nickname") + --mode= $(gettext "Use specified mode. Default: +i") + --port= $(gettext "Use specified port. Default: 6667") + --dest= $(gettext "Logs files destination path") + +EOT + exit 0 +fi + +# Cmdline --options= are parsed by libtaz.sh +[ "$nick" ] || nick="TazIRC-lb" +[ "$mode" ] || mode="+i" +[ "$port" ] || port="6667" +[ "$dest" ] || dest="$(pwd)" +host="$1" +chan="$2" +send="$dest/$host/$chan/send.txt" + +# Clean up on exit +trap "echo 'Exiting...' && rm -f $send" SIGINT INT TERM +mkdir -p $(dirname $send) + +# Introduce me! +clear && boldify "$(gettext 'Connecting to:') $host #${chan}" +cat > ${send} << EOT +NICK $nick +USER $nick $mode * :$0 +JOIN #$chan +EOT + +# Connect and handle server messages +tail -f ${send} | busybox nc ${host} ${port} | while read MESSAGE +do + # New log file for each day + logs="$dest/$host/$chan/$(date -u '+%F').log" + case "$MESSAGE" in + *NICK*) ;; + *PRIVMSG*) + # Display and log channel messages + user=$(echo "${MESSAGE%!*}" | sed s'/://') + text=$(echo "${MESSAGE#* :}") + echo "[$(date -u '+%R')] $user: $text" + echo "$(date -u '+%R')|$user|$text" >> ${logs} ;; + PING*) + # Responding to ping + echo "PONG${MESSAGE#PING}" >> ${send} ;; + *MODE*) + echo "${MESSAGE#* }" ;; + *) + echo "${MESSAGE#* :}" ;; + esac +done + +exit 0