diff options
author | Matthias Hecker <mail@apoc.cc> | 2020-04-13 20:55:55 +0200 |
---|---|---|
committer | Matthias Hecker <mail@apoc.cc> | 2020-04-13 20:55:55 +0200 |
commit | 2a084cf5175d62258488af0fdf45847e656ea7ad (patch) | |
tree | 02016dacdd9959d75e0b535de53d540a2ed81bde | |
parent | cc241a9709593491b6a67810ed8a5a5054e19208 (diff) |
plugin(oxford): fix empty service result see #37
-rw-r--r-- | data/rbot/plugins/oxford.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/data/rbot/plugins/oxford.rb b/data/rbot/plugins/oxford.rb index 5c9b0e4e..eba1b938 100644 --- a/data/rbot/plugins/oxford.rb +++ b/data/rbot/plugins/oxford.rb @@ -51,8 +51,10 @@ class OxfordPlugin < Plugin url = "#{@base_url}/search/dataset.js?dataset=noad&dictionary=en&query=#{CGI.escape word}" response = @bot.httputil.get(url, headers: {'X-Requested-With': 'XMLHttpRequest'}) alternative = response.gsub(/\\/, '').scan(/href="([^"]+)">([^<]+)</) - url = @base_url + alternative.first[0] - title = alternative.first[1] + unless alternative.empty? + url = @base_url + alternative.first[0] + title = alternative.first[1] + end end debug "search for alternative spelling result, returned title=#{title.inspect} url=#{url.inspect}" |