jamesjamail / TunnelQuestBot

Everquest auction watcher for P99 Servers
9 stars 6 forks source link

Replace the parser implementation (based on the classic one) #58

Closed rm-you closed 1 year ago

jamesjamail commented 1 year ago

Okay I relent, this is a much better approach. There are some indexing bugs in the parser I wrote using the trie search, but even if I resolved those it would never match items that are joined together without a space, which makes your approach so much more robust. I wish I had reached out to you when I was struggling to get the aho corasick modules to work before I went down the rabbit hole of a trie search by word.

2 Questions:

1) I think we can just replace your regex for WTS/WTB to include "buying" and "selling" too? As in...

const wtb_match = preprocessedMessage.match(/\b(WTB|BUYING)\b/i);
const wts_match = preprocessedMessage.match(/\b(WTS|SELLING)\b/i);

2) Is there a way to keep track of the auction string that did not match any items/spells/aliases and return that separately from known items in the buying and selling arrays? As in...

{
  buying: {
      knownItems: [{ item: cloak of flames, price: undefined }],
      unknownItems: [{item: port to gfay, price: 50 }]
     },
   selling: {
      knownItems: [{ item: fungus covered scale tunic, price: 40000 }],
      unknownItems: [{item: blacksmithing services for hire, price: undefined }]
   }
}

If a user enters a watch for "jboots mq", it won't be a match from aho corasick. Ideally we could parse the unknown auction contents within the parser so that it gets cached along with the rest of the auction data, which would save an additional regex match on the auction content if the watch is not a "known" item.