Benutzer:Heernis/Nützliche Skripte
Aus EnzyklopAtys
< Benutzer:Heernis
Version vom 4. November 2019, 01:50 Uhr von Heernis (Diskussion | Beiträge)
#!/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][^.?!]).)+[.?!’"]+