Assist an amateur.

agolangf · 2017-03-22 19:00:38 · 551 次点击    
这是一个分享于 2017-03-22 19:00:38 的资源,其中的信息可能已经有所发展或是发生改变。

Hello, I have what I hope is a quick question. I'm using a small bit of code that receives a feed from an API of a list of items and then displays specific items I'm interested in based on a few variables.

My issue I believe is pretty simple. Say you have an item type that is "Apple". Now it can be a plain "Apple", or sometimes can be a "Juice Apple" or a "Apple Mush", or even a "Juicy Apple Mush". But "Apple" will always be present.

My issue is that the only item type I am getting returned is the plain "Apple" and the possible derivatives as mentioned above do not show up. I've found using a wildcard * does not work. Note I am a complete amateur and really not clear on much of what I'm doing ! :grinning:

I'm hoping there is something simple I'm missing that I can change to allow my searches to not just return plain "Apple", but anything that contains "Apple" along with instances of "Apple" with a modifier that comes before, after or in both positions around "Apple".

This is the code, in this case I am only getting "Breach Leaguestone", but not examples that are modified with a word before or after "Breach Leaguestone", only the plain exact match.

func processStash(stash *api.Stash) {
re := regexp.MustCompile("^~b/o ([0-9\\.]+) ([^ ]+)$")
for _, item := range stash.Items {
    matches := re.FindStringSubmatch(item.Note)
    if len(matches) < 3 {
        continue
    }
    boQuantity := matches[1]
    boCurrency := matches[2]
    if item.League == "Legacy" && item.Type == "Breach Leaguestone" && item.ItemLevel >= 69 {
        log.Printf("@%v Hi I would like to buy your %v listed for %v %v in %v stash tab %v", stash.LastCharacterName, item.Type, boQuantity, boCurrency, item.League, stash.Label)
    }
}

This is the relevant API: https://github.com/ccbrown/poe-go/blob/master/api/item.go

Thanks in advance for any help! I assume this is a downright simple fix, just beyond my grasp.


评论:

the_jester:

Your regex is very likely not doing what you think it is doing. Test it over here.

donniederpo:

  if item.League == "Legacy" && item.Type == "Breach Leaguestone" && item.ItemLevel >= 69 {

item.Type == "Breach Leaguestone" is your problem here, that requires an exact match for item.Type. You will need to change that to be a lazier match type.

Yojihito:

Are you building your own poe.trade indexer to beat the 20 second delay on that plattform?

Also they patched the leaguestone trick and banned people for it (but only 00,01% I guess).

JamesTCoconuts:

Trying to lol.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

551 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传