trans

Unnamed repository; edit this file 'description' to name the repository.
git clone git://fqcor.com/trans.git
torsocks git clone git://fqcoretoclxwqpy3dwktkskmwywrcktgnpviesveq6vrjhqhdc6y4fid.onion/trans.git
Log | Files | Refs | README | LICENSE

commit e292a4a85cbd5e16d5de77c7135d97b04049d31d
Author: mys <>
Date:   Wed, 22 Jul 2020 21:22:23 +0200

Init

Diffstat:
ALICENSE | 24++++++++++++++++++++++++
AREADME.md | 20++++++++++++++++++++
Abot | 13+++++++++++++
Abotenv | 14++++++++++++++
Abotreply | 30++++++++++++++++++++++++++++++
5 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/README.md b/README.md @@ -0,0 +1,20 @@ +trans - simple translation IRC bot in bash +========================================== + +Installation +------------ + +Get translation shell: + +``` +$ git clone https://github.com/soimort/translate-shell.git +``` + +Usage +----- + +Edit botenv for configuration. Edit botreply to change its interaction. To start: + +``` +$ nohup ./bot & +``` diff --git a/bot b/bot @@ -0,0 +1,13 @@ +#!/bin/bash + +source botenv + +echo "NICK $nick" > $input +echo "USER $nick * * :$nick" >> $input + +echo $connect_command +tail -f $input | $connect_command | while read res +do + echo "$(date "+[%y:%m:%d %T]")$res" >> $log + ./botreply "$res" >> $input +done diff --git a/botenv b/botenv @@ -0,0 +1,14 @@ +#!/bin/bash +nick="trans" +# password for vhost +pass="password" +# TODO multiple servers and channels +server="irc.example.com" +channel="#channel" +port="6697" +input="input" +log="bot.log" +# basic plaintext connection +connect_command="telnet $server 6667" +# example for tor with ssl +#connect_command="torsocks openssl s_client -connect $server:$port" diff --git a/botreply b/botreply @@ -0,0 +1,30 @@ +#!/bin/bash + +source botenv + +case "$1" in + *"PING "*) + sed 's/.*\(:.*\)/PONG \1/' <<< $1 + ;; + *"End of /MOTD command."*) + # wait for notices to come + sleep 10 + # uncomment for vhost + #echo "VHOST $nick $pass" + echo "JOIN $channel" + echo "MODE $nick +B" + ;; + *"PRIVMSG "*":$nick:"*|*"PRIVMSG "*":$nick,"*) + direction=$(echo "$1" | sed "/.*:$nick[,:] \([a-z]*\)-*[:>]\([a-z]*\) .*/!d;s//\1:\2/") + if [ -n "$direction" ]; + then + string=$(echo "$1" | sed "s/.*:$nick[,:] [a-z]*-*[:>][a-z]* //") + else + string=$(echo "$1" | sed "s/.*:$nick[,:]//") + fi + trans=$(translate-shell/translate -b $direction "$string" | tr '\n' ':' | sed s'/.$//') + name=${1%%!*} + name=${name#:} + echo "$1" | awk -v "name=$name" -v "trans=$trans" '{print "PRIVMSG "$3" :"name": "trans}' + ;; +esac