• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

💾Software Discord Bot for building ADVLoot INI File Item Syntax - (Thread also now includes standalone python scripts)

Joined
Dec 22, 2019
RedCents
1,263¢
This is a discord bot that I put together that will look up an in game item and generate the proper syntax for adding the item to your advloot filter files located in your game client userdata folder.

ie.

In discord type: !advlookup Blue Diamond
it returns: 22503^9644^Blue Diamond

[CODE lang="python" title="ADVLootBot"]
#!/usr/bin/python3.6

# Program Name: ADVLoot-Discord.py
# 'ADVLoot Discord Bot for EverQuest'
# Original Author: TheDank
# Python Version: 3.6
# Original Date: 5/7/2020
# Last Revision: 5/7/2020

# Purpose: This program will parse item input from discord and return the proper ADVLoot loot ini file item syntax.

# Dependencies: Python 3 && discord module
# python3 -m pip install --user -U discord.py[voice] # discord module

# Note: This program requires the items.txt file from "http://items.sodeq.org/download.php"

# This file is part of ADVLoot-Discord.py.

# ADVLoot-Discord is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# ADVLoot-Discord is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# see <http://www.gnu.org/licenses/>.

import subprocess
import time
import sys
import os
import discord
import asyncio
import csv

from discord.ext import commands

#### MAIN PROGRAM ####

### USER DEFINED SETTINGS ###

## Discord specific settings ##
## Obtain via 'developer mode' in Discord and by right clicking on the channel, then choose copy id ##
# general chat channel ID on discord server
CHAT_ID = <insert your channel ID here>

# Discord Bot TOKEN - DO NOT SHARE!
# Obtained from your Discord applications page under your registered Bot for this application
TOKEN = '<insert your bot token ID here>'


### END USER DEFINED SETTINGS ###

# program banner
print("\n\nStarting The EverQuest ADVLoot Item Discord Bot\n")
print("Press Ctrl+C to exit\n")

# start up the bot and log in to discord
client = discord.Client()

# start up the bot
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('----------')

# some bot commands for testing and information
@client.event
async def on_message(message):
if message.content.startswith('!test'):
counter = 0
channel = message.channel
tmp = await channel.send('Calculating messages...')
async for message in channel.history(limit=100):
if message.author == client.user:
counter += 1
await channel.send(counter)

# Lookup DKP
elif message.content.startswith('!advhelp'):
channel = message.channel
await channel.send('Hello, my name is ADVLootBot and my creator is TheDank. I am here to help you populate your LF_AN_<CHARNAME>_server.ini file with the proper item syntax. Use the following format to request the item line to insert into the file: !advlookup <itemname>', tts=False)

elif message.content.startswith('!advlookup'):
channel = message.channel
msg = message.content.split(" ")
msglist = msg[1:]
itemSearch = ' '.join(map(str, msglist))
print(itemSearch)
# open and parse items.txt file
with open('items.txt', 'r', newline='') as csvfile:
readCSV = csv.reader(csvfile, delimiter='|')
for row in readCSV:
itemName = row[1]
itemID = row[5]
itemIconID = row[13]
if itemName.lower() == itemSearch.lower():
advline = itemID+'^'+itemIconID+'^'+itemName
await channel.send(advline)

# run the bot using the TOKEN
client.run(TOKEN)
[/CODE]

Enjoy!
 
holy crap, nice work! Does this mean we need to start hosting discord bots?
 
holy crap, nice work! Does this mean we need to start hosting discord bots?
I mean there are probably a few that wouldn't be a bad idea to host with a channel that people can mute for bot spam commands and replies.
 
Thanks!

Add it to a discord server of your choosing. Remember you will need the items.txt file for the bot to parse from here. On my server I setup a cron job to download it every night at 00:10 and extract it into the bot's directory, so I have a fresh copy each day.

the cron script:

Bash:
#!/bin/bash

# download latest itemlist from sodeq.org

cd /home/thedank/scripts
wget http://items.sodeq.org/downloads/items.txt.gz
gunzip items.txt.gz


The cron job entry:

Bash:
10 0 * * * bash /home/thedank/scripts/eqitems_refresh.sh
 
I mean there are probably a few that wouldn't be a bad idea to host with a channel that people can mute for bot spam commands and replies.

On the server I deployed it to I did setup a separate advloot_lookup channel for this to avoid spam in other channels. Just use that channel ID in the bot.
 
One last tidbit to help out when running the bot

A. I usually run it in a screen session on my linux server
B. I then use the following bash script to launch it, which automatically restarts the bot if it happens to crash at any point.

[CODE lang="bash" title="start_advloot_bot.sh"]
#!/bin/bash

while true
do
echo Starting ADVLootBot
./ADVLoot-Discord.py
echo Restarting Bot in 5 Seconds ...
sleep 5
done
[/CODE]
 
Last edited:
Here is a standalone python version that does not require Discord.

[CODE lang="python" title="eqadvloot.py"]
#!/usr/bin/python

import csv

itemSearch = input("What item would you like me to look up?\n")
print("Generating advloot syntax for: ", itemSearch)

with open('items.txt', 'r', newline='') as csvfile:
readCSV = csv.reader(csvfile, delimiter='|')
for row in readCSV:
itemName = row[1]
itemID = row[5]
itemIconID = row[13]
if itemName.lower() == itemSearch.lower():
advline = itemID+'^'+itemIconID+'^'+itemName
print(advline)
[/CODE]

You will need the items.txt file in the same directory as the script. That script is posted above but here it is again to make things easy.

[CODE lang="bash" title="eqitems_refresh.sh"]
#!/bin/bash

# download latest itemlist from sodeq.org
wget http://items.sodeq.org/downloads/items.txt.gz
gunzip items.txt.gz
[/CODE]


I don't do windows, so feel free to port as you see fit!
 
One more update then I am done for today. I just evolved the standalone script to take in a list of items and produce the converted advloot list to stdout. Again this will need the items.txt file as stated above. You will also need to create a text file with each item on a separate line that you want to get advloot syntax for to feed this script. For example:

[CODE lang="ini" title="list_of_items.txt"]
Blue Diamond
Skybarrage
Cloth Cape
Skymaul
Diamond
Black Ornate Silken Bridle
Crimson Runed Mask
[/CODE]

Here is the new script:

[CODE lang="python" title="eqadvloot_multi.py"]
#!/usr/bin/python

import csv
import sys

def convertAdv(item):
with open('items.txt', 'r', newline='') as csvfile:
readCSV = csv.reader(csvfile, delimiter='|')
for row in readCSV:
itemName = row[1]
itemID = row[5]
itemIconID = row[13]
if itemName.lower() == item.lower():
advline = itemID+'^'+itemIconID+'^'+itemName
print(advline)
csvfile.close()

def main():

itemFile = sys.argv[1]
print("Generating advloot syntax for: ", itemFile)
with open(itemFile) as f:
itemList = f.read().splitlines()
f.close()

for i in itemList:
convertAdv(i)

main()
[/CODE]

Example run:

You have an item list formatted as indicated above called [list_of_items.txt]

python3 eqadvloot_multi.py list_of_items.txt

which will return to stdout the following:

[CODE lang="ini" title="stdout"]22503^9644^Blue Diamond
148964^8570^Skybarrage
1006^656^Cloth Cape
148962^8573^Skymaul
10037^966^Diamond
127635^596^Black Ornate Silken Bridle
26773^1063^Crimson Runed Mask
[/CODE]

This can then be direclty copied and pasted into your advloot ini files. Note this process will take a bit of time, depending on how long your input list is. The items.txt file is quite large and it needs to compare each item you input to each line in the items.txt file to see if there is a match.
 
Last edited:
💾Software Discord Bot for building ADVLoot INI File Item Syntax - (Thread also now includes standalone python scripts)

Users who are viewing this thread

Back
Top
Cart