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 a06810bdb89acc06b5acfbaefbe6e8a3efca30f3
parent bea40da12a0cf24a84196af51fdb03d33f00adf2
Author: mys <>
Date:   Fri,  4 Jun 2021 18:44:02 +0200

Ascii rot and negative rot numbers

Diffstat:
Mbotreply | 49+++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/botreply b/botreply @@ -15,15 +15,41 @@ rot(){ # Arguments: # $1 - rot number # $2 - rotated expression - [ "$1" -lt 27 ] || return 1 vals=( $(echo -n $2 | od -An -tuC) ) + if (($1<0)) + then + rnum=$(($1+(1-$1/26)*26)) + else + rnum=$1 + fi for i in "${!vals[@]}"; do if ((${vals[i]}>64 && ${vals[i]}<91)) then - printf "\x$(printf %x $(( (vals[i]-65+$1)%26 +65 )))" + printf "\x$(printf %x $(( (vals[i]-65+$rnum)%26 +65 )))" elif ((${vals[i]}>96 && ${vals[i]}<123)) then - printf "\x$(printf %x $(( (vals[i]-97+$1)%26 +97 )))" + printf "\x$(printf %x $(( (vals[i]-97+$rnum)%26 +97 )))" + else + printf "\x$(printf %x ${vals[i]})" + fi + done +} + +arot(){ + # Arguments: + # $1 - arot number + # $2 - rotated expression + vals=( $(echo -n $2 | od -An -tuC) ) + if (($1<0)) + then + rnum=$(($1+(1-$1/94)*94)) + else + rnum=$1 + fi + for i in "${!vals[@]}"; do + if ((${vals[i]}>32 && ${vals[i]}<127)) + then + printf "\x$(printf %x $(( (vals[i]-33+$rnum)%94 +33 )))" else printf "\x$(printf %x ${vals[i]})" fi @@ -66,6 +92,7 @@ case "$1" in echo "PRIVMSG $channel :$nick: [input-lang]:ipa <text>" echo "PRIVMSG $channel :$nick: :morse <encoded-text|unencoded-text>" echo "PRIVMSG $channel :$nick: :rot<n> <text>" + echo "PRIVMSG $channel :$nick: :arot<n> <text>" echo "PRIVMSG $channel :$nick: :1337 <text>" ;; @@ -91,9 +118,19 @@ case "$1" in # Encode rot *"PRIVMSG "*":$nick: :rot"*|*"PRIVMSG "*":$nick, :rot"*) - num=$(echo "$1" | sed "s/.*:$nick[,:] :rot\([0-9]*\).*/\1/") - exp=$(echo "$1" | sed "s/.*:$nick[,:] :rot[0-9]* //") - ret=$(rot $num "$exp") + num=$(echo "$1" | sed "s/.*:$nick[,:] :rot\([-+]\{0,1\}[0-9]\{1,\}\).*/\1/") + exp=$(echo "$1" | sed "s/.*:$nick[,:] :rot[-+]\{0,1\}[0-9]\{1,\} //") + echo $num + echo $exp + ret=$(rot "$num" "$exp") + form_reply "$1" "$ret" + ;; + + # Encode arot + *"PRIVMSG "*":$nick: :arot"*|*"PRIVMSG "*":$nick, :arot"*) + num=$(echo "$1" | sed "s/.*:$nick[,:] :arot\([-+]\{0,1\}[0-9]\{1,\}\).*/\1/") + exp=$(echo "$1" | sed "s/.*:$nick[,:] :arot[-+]\{0,1\}[0-9]\{1,\} //") + ret=$(arot "$num" "$exp") form_reply "$1" "$ret" ;;