tazirc view tazirc-lb @ rev 22

revision of german messages
author Hans-G?nter Theisgen
date Mon Oct 09 17:11:41 2017 +0100 (20 months ago)
parents 3b881ac93484
children
line source
1 #!/bin/sh
2 #
3 # TazIRC-lb - SliTaz IRC Log Bot : Keep it very small!
4 #
5 # Copyright 2014 (C) SliTaz GNU/Linux - BSD License
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
8 . /lib/libtaz.sh
10 # Internationalization
11 TEXTDOMAIN='tazirc'
12 export TEXTDOMAIN
14 # Help and usage
15 if [ ! "$1" ] || [ ! "$2" ]; then
16 cat << EOT
18 $(boldify "$(gettext 'Usage:')") $(basename $0) [host] [chan] [--option]"
20 $(boldify "$(gettext 'Options:')")
21 --nick= $(gettext "Set the Bot IRC nickname")
22 --mode= $(gettext "Use specified mode. Default: +i")
23 --port= $(gettext "Use specified port. Default: 6667")
24 --dest= $(gettext "Log files destination path")
26 EOT
27 exit 0
28 fi
30 # Cmdline --options= are parsed by libtaz.sh
31 [ "$nick" ] || nick="TazIRC-lb"
32 [ "$mode" ] || mode="+i"
33 [ "$port" ] || port="6667"
34 [ "$dest" ] || dest="$(pwd)"
35 host="$1"
36 chan="$2"
37 send="$dest/$host/$chan/send.txt"
39 # Clean up on exit
40 trap "echo 'Exiting...' && rm -f $send" SIGINT INT TERM
41 mkdir -p $(dirname $send)
43 # Introduce me!
44 clear && boldify "$(gettext 'Connecting to:') $host #${chan}"
45 cat > ${send} << EOT
46 NICK $nick
47 USER $nick $mode * :$0
48 JOIN #$chan
49 EOT
51 # Connect and handle server messages
52 tail -f ${send} | busybox nc ${host} ${port} | while read MESSAGE
53 do
54 # New log file for each day
55 logs="$dest/$host/$chan/$(date -u '+%F').log"
56 case "$MESSAGE" in
57 *NICK*) ;;
58 *PRIVMSG*)
59 # Display and log channel messages
60 user=$(echo "${MESSAGE%!*}" | sed s'/://')
61 text=$(echo "${MESSAGE#* :}")
62 echo "[$(date -u '+%R')] $user: $text"
63 echo "$(date -u '+%R')|$user|$text" >> ${logs} ;;
64 PING*)
65 # Responding to ping
66 echo "PONG${MESSAGE#PING}" >> ${send} ;;
67 *MODE*)
68 echo "${MESSAGE#* }" ;;
69 *)
70 echo "${MESSAGE#* :}" ;;
71 esac
72 done
74 exit 0