Benutzer:Heernis/Nützliche Skripte

Aus EnzyklopAtys

Wechseln zu: Navigation, Suche
Chatlogfilter.png
#!/bin/bash
ID=0 #Profile ID
CHARNAME="heernis" #allways lowercase
OUTPUT="chatlog.txt"
WATCH="tail -f --lines=-100" #watch live
#READ="cat" #read whole chat log

SHOWNOT="(SYSTEM\|MTD)" #Skipped every system log and GuildMotd Message

#Uncomment only one line, if needed.
#SHOWONLY="[0-9] {put any dynchat}"
#SHOWONLY="[0-9] ryzomforge"
#SHOWONLY="[0-9] Deutsch Uni"
#SHOWONLY="[0-9] English Uni"
#SHOWONLY="[0-9] Karavan"
#SHOWONLY="[0-9] Kami"
#SHOWONLY="[0-9] Marauder"
#SHOWONLY="[0-9] Ranger"
#SHOWONLY=(UNIVERSE)
#SHOWONLY=(TELL) #Driect Message
#SHOWONLY=(SAY) #Around-Chat
#SHOWONLY=(GUILD)
#SHOWONLY=(TEAM)

#Uncomment only one line
#RMDATE="s/[0-9][0-9][0-9][0-9]\/[0-9][0-9]\/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] //g" #remove date and time
RMDATE="s/[0-9][0-9][0-9][0-9]\/[0-9][0-9]\/[0-9][0-9] //g" #remove only date
#RMDATE="[0-9][0-9]:[0-9][0-9]:[0-9][0-9]//g" #remove only time

#Removes unecessary log rubbish
RMCOLOR="s/\@{[A-Z0-9]\+}//g; s/ \* //g" #remove * and @{EE3F}
RMGENERIC='/(CSR)/! s/([A-Z]\+)//g' #remove GENERIC CHANNEL INFO like (UNIVERSE) except (CSR)
RMDYN='s/(DYN[0-9])//g' #removes DYN CHANNEL INFO like (DYN0)
RMEMT='s/(SAY\/EMT)//g'
RMLANGUNI="s/\[[0-9] [A-Zaa-z]\+ [A-Zaa-z]\+\] //g" #removes UNI LANGUAGE INFO like (0 English UNI)
RMDYN1="s/\[[0-9] [A-Zaa-z]\+\] //g" #removes DYN INFO like [0 ryzomforge]
RMINFO="/<INFO>/d; /<USERS>/d"

TELLST="s/\/tellst//g; s/sagt dir/flüstert zurück/g" # german issue, removes "/tellst" and change answers to "flüstert zurück"

#RMSPACE="s/\(.\{1\}\)//" #Removes space at the beginning of every line, change the number if needed.

norm="$(printf '\033[0m')" #returns to "normal"
lightredbold="$(printf '\033[1;49;91m ')"
lightgreenbold="$(printf '\033[1;49;92m')"
lightyellowbold="$(printf '\033[1;49;93m')"
lightbluebold="$(printf '\033[1;49;94m')"
lightmagentabold="$(printf '\033[1;49;95m')"
lightcyanbold="$(printf '\033[1;49;96m')"
lightgraybold="$(printf '\033[1;49;39m')"
lightwhitebold="$(printf '\033[1;49;97m')"

#AROUND='s/\(.*SAY.*\)/'${lightwhitebold}'\1'${norm}'/g;'
#TELL='s/\(.*TELL.*\)/'${lightgraybold}'\1'${norm}'/g'
#GUILD='s/\(.*GUILD.*\)/'${lightgreenbold}'\1'${norm}'/g'
#UNIVERSE='s/\(.*UNIVERSE.*\)/'${lightredbold}'\1'${norm}'/g'
#TEAM='s/\(.*TEAM.*\)/'${lightmagentabold}'\1'${norm}'/g'
#ENGLISHUNI='s/.*English Uni.*/'${lightcyanbold}'\1'${norm}'/g'
#DEUTSCHUNI='s/.*Deutsch Uni.*/'${lightcyanbold}'\1'${norm}'/g'

$WATCH $READ /home/$USER/.local/share/Ryzom/$ID/save/log_$CHARNAME.txt | grep --line-buffered -v "$SHOWNOT" | \
grep --line-buffered "$SHOWONLY" | \
sed -ue "$AROUND;$TELL;$TEAM;$GUILD;$UNIVERSE;$ENGLISHUNI;$RMCOLOR;$RMGENERIC;$RMDYN;$RMEMT;$RMDYN1;$RMLANGUNI;$RMINFO;$TELLST;$RMDATE;$RMSPACE" | tee -a $OUTPUT
#!/bin/bash
#Rewrite live chatlog and show in terminal (only ryzomforge)
tail -f ~/.local/share/Ryzom/0/save/log_heernis.txt | grep --line-buffered "[123456789] ryzomforge" | sed -u -e 's/\@{[A-Z0-9]\+}//g' | sed -u -e 's/ \* //g' | sed -u -e 's/\[//g;s/\]//g;' | sed -u -e 's/[1-9] ryzomforge//g' | sed -u -e 's/(DYN[1-9])//g' | sed -u '/<INFO>/d' | sed -u '/<USERS>/d' | sed -u -e 's/[0-9]\{4,\}\/[0-9]\{2,\}\/[0-9]\{2,\} [0-9]\{2,\}:[0-9]\{2,\}:[0-9]\{2,\}//g' | sed -u -e 's/\(.\{2\}\)//'
#!/bin/bash
#Rewrite chatlog for archiving into text-file (only ryzomforge)
grep "[123456789] ryzomforge" ~/.local/share/Ryzom/0/save/log_heernis.txt | sed -e 's/\@{[A-Z0-9]\+}//g' | sed -e 's/ \* //g' | sed -e 's/\[//g;s/\]//g;'  | sed -e 's/[1-9] ryzomforge//g' | sed -e 's/(DYN[1-9])//g' | sed '/<INFO>/d' | sed '/<USERS>/d' | sed -e 's/[0-9]\{4,\}\/[0-9]\{2,\}\/[0-9]\{2,\} [0-9]\{2,\}:[0-9]\{2,\}:[0-9]\{2,\}//g' | sed -e 's/\(.\{2\}\)//' > ryzomforge_archive.txt
#!/bin/bash
#Rewrite live chatlog and show in terminal (all channels)
tail -f ~/.local/share/Ryzom/0/save/log_heernis.txt | grep --line-buffered -v "(SYSTEM" | sed -u -e 's/\@{[A-Z0-9]\+}//g' | sed -u -e 's/ \* //g' | sed -u -e 's/(DYN[0-9])//g' | sed -u -e 's/\[[0-9] [A-Zaa-z]\+\] //g' | sed -u -e 's/\[[0-9] [A-Zaa-z]\+ [A-Zaa-z]\+\] //g' | sed -u -e 's/\/tellst//g'  | sed -u '/<INFO>/d' | sed -u '/<USERS>/d' | sed -u -e 's/([A-Z]\+)//g' | sed -u -e 's/[0-9]\{4,\}\/[0-9]\{2,\}\/[0-9]\{2,\} [0-9]\{2,\}:[0-9]\{2,\}:[0-9]\{2,\}//g' | sed -u -e 's/\(.\{1\}\)//'
Example:
2019/06/10 23:00:08 (DYN3) * @{EE3F}[3 ryzomforge] Nilstilar sagt: @{AFBF}Bonne nuit / Good night
Rewrites to
Nilstilar sagt: Bonne nuit / Good night
#!/bin/bash
#watch the log | filter only channel SAY/EMT | exchange charname with <Spieler> |exchange Aeps Zessen with <Ziel> | write it into  emotes.txt
tail -f /home/$USER/.local/share/Ryzom/0/save/log_heernis.txt | grep --line-buffered '(SAY/EMT)' | sed -u -e 's/\(.\{32\}\)//' | sed -u -e 's/\Heernis\b/<Spieler>/g' | sed -u -e 's/\Aeps Zessen\b/<Ziel>/g' >> emotes.txt
#!/bin/bash
# Skip System lines and cut out a part of the log based on time
grep -v "(SYSTEM" log_heernis.txt | sed -n "/2018\/06\/12 18:39/,/2018\/06\/12 18:40/p" log_heernis.txt > log_heernis_cutout.txt
#!/bin/bash
# Remove @{EE3F}
sed -e 's/\@{[A-Z0-9]\+}//g' log_heernis.txt > log_heernis
#Remove all System lines
grep -v '(SYSTEM' log_heernis.txt > log_heernis_edit.txt

Match a whole line with regex

["’]?[A-Z][^.?!]+((?![.?!][’"]?\s["’]?[A-Z][^.?!]).)+[.?!’"]+
#!/bin/bash
##############################################
##########!!!ROCKETCHAT BROADCAST!!!##########
##############################################
##requirements: sudo apt install at curl grep sed
##create a text file and name it message.txt
##Add this to the file:
##de {My first message!}
##en {My first message!}
##es {My first message!}
##fr {My first message!}
##ru {My first message!}
##uni {My first message!}
##Put the text between the brackets {}
##execute this file with "at 18:00 -f ./filename.sh" for example

SITE="chat.ryzom.com"
USER="username" #put your charname between ""
PW="password" #put your account password between ""
boldyellow='\x1b[1;33m'
red='\033[0;31m'
green='\033[0;32m'
reset='\033[0m' 

#Retrieving account information 
if [ ! -f login.txt ];
then
curl -H "Content-type:application/json" http://${SITE}:3000/api/v1/login \
-d '{ "user": "'"${USER}"'", "password": "'"${PW}"'" }' > login.txt
else
     echo -e "${red}login.txt exists already${green}"
fi

#Set the variables from files
USERID=$(cat "login.txt" | egrep -whoi '"userID":"[A-Za-z0-9]+"' login.txt | sed -e 's/"//g;s/userId://g')
ATOKEN=$(cat "login.txt" | egrep -whoi '"authToken":"[A-Za-z0-9_-]+"' login.txt | sed -e 's/"//g;s/authToken://g')

MESSAGE1=$(cat "message.txt" | grep de | sed -e 's/de {//g;s/}//g')
MESSAGE2=$(cat "message.txt" | grep es | sed -e 's/es {//g;s/}//g')
MESSAGE3=$(cat "message.txt" | grep en | sed -e 's/en {//g;s/}//g')
MESSAGE4=$(cat "message.txt" | grep fr | sed -e 's/fr {//g;s/}//g')
MESSAGE5=$(cat "message.txt" | grep ru | sed -e 's/ru {//g;s/}//g')
MESSAGE6=$(cat "message.txt" | grep uni | sed -e 's/uni {//g;s/}//g')

CHANNEL1="#pub-uni-de"
CHANNEL2="#pub-uni-es"
CHANNEL3="#pub-uni-en"
CHANNEL4="#pub-uni-fr"
CHANNEL5="#pub-uni-ru"
CHANNEL6="#pub-uni"

SLEEP="1"
#Broadcast!
curl -H "X-Auth-Token: ${ATOKEN}" \
     -H "X-User-Id: ${USERID}" \
     -H "Content-type:application/json" \
     http://${SITE}:3000/api/v1/chat.postMessage \
     -d '{ "channel": "'"$CHANNEL1"'", "text": "'"${MESSAGE1}"'" }' > /dev/null && \

echo -e "${red}Message sended to German UNI${green}"

sleep $SLEEP && \

curl -H "X-Auth-Token: ${ATOKEN}" \
     -H "X-User-Id: ${USERID}" \
     -H "Content-type:application/json" \
     http://${SITE}:3000/api/v1/chat.postMessage \
     -d '{ "channel": "'"$CHANNEL2"'", "text": "'"${MESSAGE2}"'" }' > /dev/null && \

echo -e "${red}Message sended to Spanish UNI${green}"

sleep $SLEEP && \

curl -H "X-Auth-Token: ${ATOKEN}" \
     -H "X-User-Id: ${USERID}" \
     -H "Content-type:application/json" \
     http://${SITE}:3000/api/v1/chat.postMessage \
     -d '{ "channel": "'"$CHANNEL3"'", "text": "'"${MESSAGE3}"'" }' > /dev/null && \

echo -e "${red}Message sended to English UNI${green}"

sleep $SLEEP && \

curl -H "X-Auth-Token: ${ATOKEN}" \
     -H "X-User-Id: ${USERID}" \
     -H "Content-type:application/json" \
     http://${SITE}:3000/api/v1/chat.postMessage \
     -d '{ "channel": "'"$CHANNEL4"'", "text": "'"${MESSAGE4}"'" }' > /dev/null && \

echo -e "${red}Message sended to French UNI${green}"

sleep $SLEEP && \

curl -H "X-Auth-Token: ${ATOKEN}" \
     -H "X-User-Id: ${USERID}" \
     -H "Content-type:application/json" \
     http://${SITE}:3000/api/v1/chat.postMessage \
     -d '{ "channel": "'"$CHANNEL5"'", "text": "'"${MESSAGE5}"'" }' > /dev/null && \

echo -e "${red}Message sended to Russian UNI${green}"

sleep $SLEEP && \

curl -H "X-Auth-Token: ${ATOKEN}" \
     -H "X-User-Id: ${USERID}" \
     -H "Content-type:application/json" \
     http://${SITE}:3000/api/v1/chat.postMessage \
     -d '{ "channel": "'"$CHANNEL6"'", "text": "'"${MESSAGE6}"'" }' > /dev/null

echo -e "${red}Message sended to UNI${reset}"