summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLedmitz <smoothshifter@tuta.io>2020-09-16 17:55:53 +0000
committerLedmitz <smoothshifter@tuta.io>2020-09-16 17:55:53 +0000
commit42eb5c67e2d393fd3530f5813b78cf219d0edf96 (patch)
tree6e33e17c82b6db6c82d46bd637f587f88c9dd9d5
parentbdde31e5ec25159bdbb94209c0e50f9fa3c2723f (diff)
downloadtmw-info-42eb5c67e2d393fd3530f5813b78cf219d0edf96.tar.gz
tmw-info-42eb5c67e2d393fd3530f5813b78cf219d0edf96.tar.bz2
tmw-info-42eb5c67e2d393fd3530f5813b78cf219d0edf96.tar.xz
tmw-info-42eb5c67e2d393fd3530f5813b78cf219d0edf96.zip
Added chat log searchchat_search
-rw-r--r--README.md2
-rwxr-xr-xtmw-info44
2 files changed, 44 insertions, 2 deletions
diff --git a/README.md b/README.md
index b9f2be3..e298987 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ tmw-info [command] [STRING]"
gm-asearch TERM1 TERM2 TERM3 ... (results contain all of the terms)
gm-esearch TERM1 TERM2 TERM3 ... (results contain the exact term)
gm-show (if zenity is installed, displays a GUI pop-up of the last 10 issued GM CMDs)
+ chat-search TERM1 TERM2 TERM3 ... (chat: results contain all of the terms)
item-update (downloads item DB. Must be run before searching)
item-search TERM1 TERM2 TERM3 ... (items: results contain all of the terms)
mob-update (downloads monster DB. Must be run before searching)
@@ -67,4 +68,5 @@ If you get an error while searching, it may contain special characters and needs
2020-08-15 - fixed gm-show (wasn't showing GUI) and removed trailing comma in mob drops
2020-08-16 - added ratio for dropped items to represent chances in a more human readable way
+2020-09-16 - added chat log search
diff --git a/tmw-info b/tmw-info
index a0bc49b..e66e49f 100755
--- a/tmw-info
+++ b/tmw-info
@@ -16,6 +16,17 @@ TMW_INFO="$HOME/.tmw-info"
ITEM_DIR="$TMW_INFO/item"
# Monster DB DIR
MOB_DIR="$TMW_INFO/mob"
+# Chat logs DIR
+CHAT_LOGS="$HOME/.local/share/mana/logs/server.themanaworld.org/"
+
+
+
+
+
+
+
+
+
# GM Log DIR
TMW_GM_LOGS="$TMW_INFO/logs"
GM_LOG_LIST="$TMW_INFO/gm_log_list"
@@ -43,6 +54,7 @@ help(){
echo " gm-asearch TERM1 TERM2 TERM3 ... (results contain all of the terms)"
echo " gm-esearch TERM1 TERM2 TERM3 ... (results contain the exact term)"
echo " gm-show (if zenity is installed, displays a GUI pop-up of the last 10 issued GM CMDs), otherwise in terminal"
+ echo " chat-search TERM1 TERM2 TERM3 ... (chat: results contain all of the terms)"
echo " item-update (downloads item DB. Must be run before searching)"
echo " item-search TERM1 TERM2 TERM3 ... (items: results contain all of the terms)"
echo " mob-update (downloads monster DB. Must be run before searching)"
@@ -131,7 +143,7 @@ elif [ "$1" == "gm-asearch" ]; then
#echo "SEARCH_TERMS: $SEARCH_TERMS"
#echo "WORD_COUNT: $WORD_COUNT"
#echo "COUNT: $COUNT"
- echo "========== Results (all): $SEARCH_TERMS} ==========" | sed 's/\\//g'
+ echo "========== Results (all): $SEARCH_TERMS ==========" | sed 's/\\//g'
while [ "$COUNT" -le "$WORD_COUNT" ]
do
WORD=$(echo "$SEARCH_TERMS" | awk "{print \$$COUNT}")
@@ -146,7 +158,7 @@ elif [ "$1" == "gm-asearch" ]; then
#echo "COUNT: $COUNT"
#echo "LAST_COUNT: $LAST_COUNT"
done
- cat "$TMW_INFO/gm-asearch$LAST_COUNT.tmp"
+ cat "$TMW_INFO/gm-asearch$LAST_COUNT.tmp"
elif [ "$1" == "gm-esearch" ]; then
if [ ! -d "$TMW_GM_LOGS" ] || [ -z "$(ls "$TMW_GM_LOGS")" ]; then
echo 'You must run gm-update before searching'
@@ -215,6 +227,34 @@ elif [ "$1" == 'gm-show' ]; then
else
cat < "$GM_REPORT"
fi
+elif [ "$1" == "chat-search" ]; then
+ if [ ! -d "$CHAT_LOGS" ] || [ -z "$(ls "$CHAT_LOGS")" ]; then
+ echo 'There are no chat logs to search'
+ exit 0
+ fi
+ # All terms: This must not be an array
+ SEARCH_TERMS=$(echo "$*" | sed -E 's/^chat-search\s//g' | sed 's/\[/\\\[/g' | sed 's/\]/\\\]/g')
+ WORD_COUNT=$(echo "$SEARCH_TERMS" | wc -w)
+ COUNT='1'
+ #echo "SEARCH_TERMS: $SEARCH_TERMS"
+ #echo "WORD_COUNT: $WORD_COUNT"
+ #echo "COUNT: $COUNT"
+ echo "========== Results (chat): $SEARCH_TERMS ==========" | sed 's/\\//g'
+ while [ "$COUNT" -le "$WORD_COUNT" ]
+ do
+ WORD=$(echo "$SEARCH_TERMS" | awk "{print \$$COUNT}")
+ #echo "WORD: $WORD"
+ if [ "$COUNT" = '1' ]; then
+ grep -ir "$WORD" "$CHAT_LOGS"/* | sed -E 's/^.*server.themanaworld.org\/\///g' > "$TMW_INFO/chat-search$COUNT.tmp"
+ else
+ grep -hi "$WORD" "$TMW_INFO/chat-search$LAST_COUNT.tmp" > "$TMW_INFO/chat-search$COUNT.tmp"
+ fi
+ LAST_COUNT="$COUNT"
+ COUNT=$(( COUNT + 1 ))
+ #echo "COUNT: $COUNT"
+ #echo "LAST_COUNT: $LAST_COUNT"
+ done
+ cat "$TMW_INFO/chat-search$LAST_COUNT.tmp"
elif [ "$1" == 'item-update' ]; then
mkdir -p "$ITEM_DIR"
ITEM_FILES=($(curl -s 'https://github.com/themanaworld/tmwa-server-data/tree/master/world/map/db' | sed 's/<\/*[^>]*>//g' | grep -o 'item_db.*\.txt'))