summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLedmitz <smoothshifter@tuta.io>2023-08-01 11:30:16 -0300
committerLedmitz <smoothshifter@tuta.io>2023-08-01 11:30:16 -0300
commitb957eb45d1495d2bfcb7d51e9ce07a01c7a9761b (patch)
tree624a5f7d791af9b269868d93fe8034eb26cbc0a1
parent8dfed398c54576b21c3c43b8c8bdeeed3adb9a25 (diff)
downloadtmw-info-b957eb45d1495d2bfcb7d51e9ce07a01c7a9761b.tar.gz
tmw-info-b957eb45d1495d2bfcb7d51e9ce07a01c7a9761b.tar.bz2
tmw-info-b957eb45d1495d2bfcb7d51e9ce07a01c7a9761b.tar.xz
tmw-info-b957eb45d1495d2bfcb7d51e9ce07a01c7a9761b.zip
Finally in working order againHEADonline_ordering_2master
-rw-r--r--README.md4
-rwxr-xr-xtmw-info147
2 files changed, 94 insertions, 57 deletions
diff --git a/README.md b/README.md
index 1bb5c06..b9f22c1 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,9 @@ Use gm-show to quickly display the last 10 gm commands run. Updates automaticall
```
## Changelog
-* 2023-07-29 - Updated many server URLs to current.
+* 2023-08-01 - Added account age by number to the online list, whilst leaving it in alphabetical order
+ - Corrected server URLs to be more exact, instead of looking for patterns and added rm lines, since wget was not overwriting/updating files
+* 2023-07-29 - Updated many server URLs to current
* 2023-01-22 - mob-search was showing other incorrect info, since CRIT DEF was added to mob DB. Info shows correctly now and more info is shown
* 2023-01-06 - Fixed the ordering of the online list to ignore case, so it shows players in a more organized fashion
* 2023-01-04 - Fixed mob-search do display proper drops. This was due to a server DB update which added new columns
diff --git a/tmw-info b/tmw-info
index 76b933f..d4faa9e 100755
--- a/tmw-info
+++ b/tmw-info
@@ -13,6 +13,8 @@ thisMonth=$(date -u +'%m')
MAP_URL='https://git.themanaworld.org/legacy/serverdata/-/tree/master/world/map'
#Main DIR
TMW_INFO="$HOME/.tmw-info"
+#News
+ONLINE_FILE="$TMW_INFO/online.txt"
#Items DB DIR
ITEM_DIR="$TMW_INFO/item"
#Monster DB DIR
@@ -37,24 +39,20 @@ trap FINISH EXIT
help(){
echo "tmw-info [command] [STRING]"
echo " help / --help / -h (this help screen)"
- echo " cmds-update (downloads command source files. Should be run before using \"cmds\")"
+ echo " update (downloads and updates all required commands, database and log files)"
echo " cmds (ManaPlus and GM command reference)"
echo " news (reads game news)"
- echo " online (shows online players)"
- echo " gm-update (downloads all GM logs. Should be run before searching)"
+ echo " online (shows online players in alphabetical order and numbered by account age)"
echo " gm-search TERM1 TERM2 TERM3 ... (results contain any of the terms)"
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)"
echo " mob-search TERM1 TERM2 TERM3 ... (monsters: results contain all of the terms)"
echo 'If you get and error while searching, it may contain special characters and needs to be quoted'
- echo 'gm searches, item-search, mob-search and cmds require periodic updating with their respective update commands'
- echo 'To avoid hammering servers, there will be no update-all option. Use gm-update before performing gm searches.
-Use gm-show to quickly display the last 10 gm commands run. Updates automatically. Uses zenity to display GUI, if installed)'
+ echo 'gm searches, item-search, mob-search and cmds require periodic updating with the update option'
+ echo 'Use gm-show to quickly display the last 10 gm commands run. Updates automatically. Uses zenity to display GUI, if installed)'
}
if [ -z "$1" ]; then
@@ -81,11 +79,24 @@ if [ "$1" == "help" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
elif [ "$1" == "news" ]; then
curl -s 'https://updates.tmw2.org/legacy/news.txt' | sed 's/<\/*[^>]*>//g' | less
elif [ "$1" == "online" ]; then
- curl -s 'https://server.themanaworld.org/' | sed 's/<\/*[^>]*>//g' | sed -r '/^\s*$/d' | sed -r '/^\s*Name\s*$/d' | grep --line-buffered -v 'Online Players' | sed 1d | sort -n
-elif [ "$1" == "gm-update" ]; then
+ curl -s 'https://server.themanaworld.org' | sed 's/<\/*[^>]*>//g' | sed -r '/^\s*$/d' | sed -r '/^\s*Name\s*$/d' | grep --line-buffered -v 'Online Players' > "$ONLINE_FILE"
+ COUNT='0'
+ while read NAME; do
+ COUNT=$(($COUNT + 1))
+ echo "$NAME - $COUNT" >> "$ONLINE_FILE"'_tmp'
+ done < "$ONLINE_FILE"
+ LAST_LINE=$(tail -n 1 "$ONLINE_FILE"'_tmp')
+ LAST_LINE2=$(echo "$LAST_LINE" | sed -E 's/\..*$//')
+ cat "$ONLINE_FILE"'_tmp' | sort -n | sed "s/$LAST_LINE/$LAST_LINE2/" | sed 's/&amp;/\&/g' | sed 's/&lt;/</g' | sed 's/&gt;/>/g' > "$ONLINE_FILE"
+ rm "$ONLINE_FILE"'_tmp'
+ cat "$ONLINE_FILE"
+elif [ "$1" == "update" ]; then
+##GM log updates
mkdir -p "$TMW_GM_LOGS"
#Get list of files from server to read the byte counts from
- wget -c -q -O "$GM_LOG_LIST.tmp" 'https://server.themanaworld.org/gm'
+ rm -f "$GM_LOG_LIST.tmp"
+ rm -f "$GM_LOG_LIST"
+ wget -q -O "$GM_LOG_LIST.tmp" 'https://server.themanaworld.org/gm'
sed 's/<\/*[^>]*>//g' "$GM_LOG_LIST.tmp" > "$GM_LOG_LIST"
#Download the very first one without updating it if already exists
#This is the only gmlog without a byte count check (none listed online). If it becomes corrupted, it must be deleted manually
@@ -112,13 +123,71 @@ elif [ "$1" == "gm-update" ]; then
fi
fi
done
- done
-#All searches cancel special grep characters [ and ], which are read by grep, even in single quoted text
-#When echoing back, the \ are again removed to show what was originally typed by the user correctly
-#Only [ and ] regex characters seemed to pose a problem
+ done
+ #All searches cancel special grep characters [ and ], which are read by grep, even in single quoted text
+ #When echoing back, the \ are again removed to show what was originally typed by the user correctly
+ #Only [ and ] regex characters seemed to pose a problem
+##Item updates
+ mkdir -p "$ITEM_DIR"
+ echo 'Downloading item_db_chest.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_chest.txt' > "$ITEM_DIR/item_db_chest.txt"
+ echo 'Downloading item_db_foot.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_foot.txt' > "$ITEM_DIR/item_db_foot.txt"
+ echo 'Downloading item_db_generic.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_generic.txt' > "$ITEM_DIR/item_db_generic.txt"
+ echo 'Downloading item_db_hand.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_hand.txt' > "$ITEM_DIR/item_db_hand.txt"
+ echo 'Downloading item_db_head.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_head.txt' > "$ITEM_DIR/item_db_head.txt"
+ echo 'Downloading item_db_leg.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_leg.txt' > "$ITEM_DIR/item_db_leg.txt"
+ echo 'Downloading item_db_offhand.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_offhand.txt' > "$ITEM_DIR/item_db_offhand.txt"
+ echo 'Downloading item_db_trinket.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_trinket.txt' > "$ITEM_DIR/item_db_trinket.txt"
+ echo 'Downloading item_db_use.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_use.txt' > "$ITEM_DIR/item_db_use.txt"
+ echo 'Downloading item_db_weapon.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/item_db_weapon.txt' > "$ITEM_DIR/item_db_weapon.txt"
+##Monster updates
+ mkdir -p "$MOB_DIR"
+ echo 'Downloading mob_db_0_19.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_0_19.txt' > "$MOB_DIR/mob_db_0_19.txt"
+ echo 'Downloading mob_db_20_39.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_20_39.txt' > "$MOB_DIR/mob_db_20_39.txt"
+ echo 'Downloading mob_db_40_59.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_40_59.txt' > "$MOB_DIR/mob_db_40_59.txt"
+ echo 'Downloading mob_db_60_79.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_60_79.txt' > "$MOB_DIR/mob_db_60_79.txt"
+ echo 'Downloading mob_db_80_99.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_80_99.txt' > "$MOB_DIR/mob_db_80_99.txt"
+ echo 'Downloading mob_db_over_100.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_over_100.txt' > "$MOB_DIR/mob_db_over_100.txt"
+ echo 'Downloading mob_db_over_150.txt'
+ curl -s 'https://git.themanaworld.org/legacy/serverdata/-/raw/stable/world/map/db/mob_db_over_150.txt' > "$MOB_DIR/mob_db_over_150.txt"
+##Commands updates
+ mkdir -p "$TMW_CMDS"
+ echo "Downloading and creating client command list..."
+ rm -f "$TMW_CMDS/client_commands"
+ wget -q -P "$TMW_CMDS" "https://wiki.themanaworld.org/index.php/User:Jak1/sandbox/client_commands"
+ grep -Eo '>/[a-z]+' "$TMW_CMDS/client_commands" | sed 's/^>//g' > "$TMW_CMDS/client"
+ grep -Eo '>/[a-z\,/]+' "$TMW_CMDS/client_commands" | sed 's/^>//g' >> "$TMW_CMDS/client"
+ grep -Eao '/[a-z]+ ' '/usr/games/manaplus' >> "$TMW_CMDS/client"
+ echo -e '/ipctoggle\n/lastseen\n/targetmonster\n/movetotarget\n/attack\n/targetattack\n/untarget\n/where\n/navigate X Y\n/sethome\n/movetohome\n/present\n/all\n/pickup\n/useitem ID\n/disablehighlight\n/enablehighlight\n/sit\n/direct\n/turn[up,down,left,right]' >> "$TMW_CMDS/client"
+ cat < "$TMW_CMDS/client" | sed -E 's/\s*$//g' | sort -u > "$TMW_CMDS/client.tmp"
+ mv -f "$TMW_CMDS/client.tmp" "$TMW_CMDS/client"
+ echo "Downloading and creating default at command list..."
+ rm -f "$TMW_CMDS/atcommand_athena.conf"
+ wget -q -P "$TMW_CMDS" 'https://git.themanaworld.org/legacy/serverdata/-/raw/master/world/map/conf/atcommand_athena.conf'
+ grep -Eo '[A-Za-z0-9]+: [0-9]+' "$TMW_CMDS/atcommand_athena.conf" | sort -u > "$TMW_CMDS/default_at"
+ echo "Downloading and creating custom at command list..."
+ #github because we can't see the DIRs on git.themanaworld.org in the code
+ rm -f "$TMW_CMDS/commands"
+ wget -q -P "$TMW_CMDS" 'https://github.com/themanaworld/tmwa-server-data/tree/master/world/map/npc/commands'
+ sed 's/<\/*[^>]*>//g' "$TMW_CMDS/commands" | grep -Eo '[A-Za-z0-9]+.txt' | sed 's/.txt$//g' | grep -v '^import$\|^procedures$' | sort -u > "$TMW_CMDS/custom_at"
elif [ "$1" == "gm-search" ]; then
if [ ! -d "$TMW_GM_LOGS" ] || [ -z "$(ls "$TMW_GM_LOGS")" ]; then
- echo 'You must run gm-update before searching'
+ echo 'You must run update before searching'
exit 0
fi
#Any terms: This must be an array because each term is searched separately in the for loop.
@@ -129,7 +198,7 @@ elif [ "$1" == "gm-search" ]; then
done
elif [ "$1" == "gm-asearch" ]; then
if [ ! -d "$TMW_GM_LOGS" ] || [ -z "$(ls "$TMW_GM_LOGS")" ]; then
- echo 'You must run gm-update before searching'
+ echo 'You must run update before searching'
exit 0
fi
#All terms: This must not be an array
@@ -150,7 +219,7 @@ elif [ "$1" == "gm-asearch" ]; then
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'
+ echo 'You must run update before searching'
exit 0
fi
#Exact search: Must not be an array. Used once.
@@ -243,18 +312,9 @@ elif [ "$1" == "chat-search" ]; then
else
cat "$CHAT_LOGS$CHAT.log" | less
fi
-elif [ "$1" == 'item-update' ]; then
- mkdir -p "$ITEM_DIR"
- ITEM_FILES=($(curl -s "$MAP_URL/db" | sed 's/<\/*[^>]*>//g' | grep -o 'item_db.*\.txt'))
- for ITEM_FILE in "${ITEM_FILES[@]}"; do
- echo "Downloading $ITEM_FILE"
- curl -s "$MAP_URL/db/$ITEM_FILE"\
- | grep -Eo '[0-9]+,\s*[a-zA-Z0-9]+,\s*[0-9]+,\s*[0-9]+,.*$|//ID,\s*Name.*$' | sed -E 's/<\/td>//g' | sed 's/&quot;//g'\
- | sort -nu > "$ITEM_DIR/$ITEM_FILE"
- done
elif [ "$1" == "item-search" ]; then
if [ ! -d "$ITEM_DIR" ] || [ -z "$(ls "$ITEM_DIR")" ]; then
- echo 'You must run item-update before searching'
+ echo 'You must run update before searching'
exit 0
fi
#All terms: This must not be an array
@@ -283,18 +343,9 @@ View: $(echo "$LINE" | awk '{print $16}') Script: $(echo "$LINE" | awk '{print $
Other attributes:\n\
$(echo "$LINE" | grep -o '{.*}' | sed 's/[,{}]//g' | sed 's/^\s*//g')\n"
done < "$TMW_INFO/item-search$LAST_COUNT.tmp"
-elif [ "$1" == 'mob-update' ]; then
- mkdir -p "$MOB_DIR"
- MOB_FILES="$(curl -s "$MAP_URL/db" | sed 's/<\/*[^>]*>//g' | grep -o 'mob_db.*\.txt')"
- for MOB_FILE in $MOB_FILES; do
- echo "Downloading $MOB_FILE"
- curl -s "$MAP_URL/db/$MOB_FILE" \
- | grep -Eo '[0-9]+,\s*[a-zA-Z0-9]+,\s*[a-zA-Z0-9]+,\s*[0-9]+,.*$|//ID,\s*Name.*$' | sed -E 's/<\/td>//g' | sed 's/&quot;//g' \
- | sort -nu > "$MOB_DIR/$MOB_FILE"
- done
elif [ "$1" == "mob-search" ]; then
if [ ! -d "$MOB_DIR" ] || [ -z "$(ls "$MOB_DIR")" ]; then
- echo 'You must run mob-update before searching'
+ echo 'You must run update before searching'
exit 0
fi
#All terms: This must not be an array
@@ -325,7 +376,7 @@ elif [ "$1" == "mob-search" ]; then
mv "$TMW_INFO/mob-drop-names-$MOB_ID.tmp.tmp" "$TMW_INFO/mob-drop-names-$MOB_ID.tmp"
DROP_NAMES=$(sed 's/^$//g' "$TMW_INFO/mob-drop-names-$MOB_ID.tmp")
else
- echo 'Warning: To get the names of item drops, rather than just their IDs, you must run item-update first'
+ echo 'Warning: To get the names of item drops, rather than just their IDs, you must run update first'
DROP_NAMES="${DROP_IDS[@]}"
fi
DROP_COUNT='1'
@@ -355,25 +406,9 @@ MUTATIONS: $(echo "$LINE" | awk '{print $61}') MUTATION STR: $(echo "$LINE" | aw
DROPS: $DROPS\n\
"
done < "$TMW_INFO/mob-search$LAST_COUNT.tmp"
-elif [ "$1" == 'cmds-update' ];then
- mkdir -p "$TMW_CMDS"
- echo "Downloading and creating client command list..."
- wget -q -c -P "$TMW_CMDS" "https://wiki.themanaworld.org/index.php/User:Jak1/sandbox/client_commands"
- grep -Eo '>/[a-z]+' "$TMW_CMDS/client_commands" | sed 's/^>//g' > "$TMW_CMDS/client"
- grep -Eo '>/[a-z\,/]+' "$TMW_CMDS/client_commands" | sed 's/^>//g' >> "$TMW_CMDS/client"
- grep -Eao '/[a-z]+ ' '/usr/games/manaplus' >> "$TMW_CMDS/client"
- echo -e '/ipctoggle\n/lastseen\n/targetmonster\n/movetotarget\n/attack\n/targetattack\n/untarget\n/where\n/navigate X Y\n/sethome\n/movetohome\n/present\n/all\n/pickup\n/useitem ID\n/disablehighlight\n/enablehighlight\n/sit\n/direct\n/turn[up,down,left,right]' >> "$TMW_CMDS/client"
- cat < "$TMW_CMDS/client" | sed -E 's/\s*$//g' | sort -u > "$TMW_CMDS/client.tmp"
- mv -f "$TMW_CMDS/client.tmp" "$TMW_CMDS/client"
- echo "Downloading and creating default at command list..."
- wget -q -c -P "$TMW_CMDS" "$MAP_URL/conf/atcommand_athena.conf"
- sed 's/<\/*[^>]*>//g' "$TMW_CMDS/atcommand_athena.conf" | grep -Eo '[A-Za-z0-9]+: [0-9]+' "$TMW_CMDS/atcommand_athena.conf" | sort -u > "$TMW_CMDS/default_at"
- echo "Downloading and creating custom at command list..."
- wget -q -c -P "$TMW_CMDS" "$MAP_URL/npc/commands"
- sed 's/<\/*[^>]*>//g' "$TMW_CMDS/commands" | grep -Eo '[A-Za-z0-9]+.txt' | sed 's/.txt$//g' | grep -v '^import$\|^procedures$' | sort -u > "$TMW_CMDS/custom_at"
elif [ "$1" == 'cmds' ];then
if [ ! -f "$TMW_CMDS/client" ] || [ ! -f "$TMW_CMDS/default_at" ] || [ ! -f "$TMW_CMDS/custom_at" ]; then
- echo 'You must run "cmds-update" first'
+ echo 'You must run "update" first'
else
(echo -e "\nClient Commands:"
cat < "$TMW_CMDS/client"