2023-06-03 23:49:12 +03:00
|
|
|
#!/bin/bash
|
2022-09-30 01:09:19 +03:00
|
|
|
|
2023-09-10 01:13:40 +03:00
|
|
|
# TODO: Добавить описание
|
|
|
|
# TODO: Добавить в README.md
|
|
|
|
|
2022-09-30 01:09:19 +03:00
|
|
|
# https://linuxconcept.com/making-a-simple-irc-chat-bot-logger-using-bash-script/
|
|
|
|
|
2023-06-03 23:49:12 +03:00
|
|
|
nick="blb$$"
|
2022-09-25 04:09:19 +03:00
|
|
|
channel=admin
|
|
|
|
server=iiiypuk.me
|
2023-06-03 23:49:12 +03:00
|
|
|
config=/tmp/irclog
|
|
|
|
[ -n "$1" ] && channel=$1
|
|
|
|
[ -n "$2" ] && server=$2
|
|
|
|
config="${config}_${channel}"
|
|
|
|
echo "NICK $nick" > $config
|
|
|
|
echo "USER $nick +i * :$0" >> $config
|
|
|
|
echo "JOIN #$channel" >> $config
|
|
|
|
trap "rm -f $config;exit 0" INT TERM EXIT
|
|
|
|
tail -f $config | nc $server 6667 | while read MESSAGE
|
|
|
|
do
|
|
|
|
case "$MESSAGE" in
|
|
|
|
PING*) echo "PONG${MESSAGE#PING}" >> $config;; *QUIT*) ;;
|
|
|
|
*PART*) ;;
|
|
|
|
*JOIN*) ;;
|
|
|
|
*NICK*) ;;
|
|
|
|
*PRIVMSG*) echo "${MESSAGE}" | sed -nr "s/^:([^!]+).*PRIVMSG[^:]+:(.*)/[$(date '+%R')] \1> \2/p" >> $config;;
|
|
|
|
*) echo "${MESSAGE}";;
|
|
|
|
esac
|
2022-09-25 04:09:19 +03:00
|
|
|
done
|