Closed Nakilon closed 3 years ago
By default, Infoboxer's search looks only in titles (I am not sure it is sensible behavior actually, but that's how it is now). You can hack it around by adjusting the request:
Infoboxer.wiki("https://esolangs.org/w/api.php").search(query, limit: 1) { |req| req.what(:text) }
# => [#<Page(title: "???", url: "https://esolangs.org/wiki/%3F%3F%3F"): ??? is an esoteric programming ...>]
(req
inside the block is MediaWiktory::Wikipedia::Actions::Query, and on search, this module is available for additional tweaking)
also here it's 2-3 times slower than butt, maybe making more requests
It fetches some meta-info about MediaWiki instance on wiki object instantiation, so if you'll do this:
wiki = Infoboxer.wiki("https://esolangs.org/w/api.php") # meta-info fetching
wiki.search(...) # reusing the object
...it'll probably help.
The order is weird though.
> wiki.search("nakilon", limit: 1){ |req| req.what :text }.first.title
=> "Velik"
> wiki.search("nakilon", limit: 2){ |req| req.what :text }.first.title
=> "RASEL"
> wiki.search("nakilon", limit: 3){ |req| req.what :text }.first.title
=> "RASEL"
> wiki.search("nakilon", limit: 2){ |req| req.what :text }.map &:title
=> ["RASEL", "Velik"]
P.S.: I already have the separate "meta-info fetching" line so there is probably something else that takes time.
Alright, thanks for the help. Now I fully switched to your gem: https://github.com/Nakilon/nakiircbot/commit/e35ce0783fbc27072f1c829cc2d80835a00c010f
I would love to replace
mediawiki-butt
withinfoboxer
but in this test it is unable to parse search results:(also here it's 2-3 times slower than butt, maybe making more requests, idk)