local nintendo_search = {} nintendo_search.triggers = { '^/nin (.+)', '^/nintendo (.+)' } function nintendo_search:get_info(gametitle) local url = 'https://search.nintendo-europe.com/de/select?q='..gametitle..'&fq=type%3AGAME%20AND%20*%3A*&rows=1&wt=json' local res, code = https.request(url) if code ~= 200 then return nil end local data = json.decode(res).response.docs[1] if not data then return 'Nichts gefunden!' end local title = ''..data.title..'' if data.publisher then publish = ' von '..data.publisher..'' else publish = '' end if data.system_names_txt then system = ' für '..data.system_names_txt[1]..'' else system = '' end if data.pretty_agerating_s == 'n. n. b.' then fsk = '' else fsk = '\n'..data.pretty_agerating_s..'' end if data.players_to == 1 then player = '\n1 Spieler' else player = '\n1 bis '..data.players_to..' Spieler' end local link = '\nWebseite besuchen' local description = '\n\n'..string.sub(unescape(data.excerpt:gsub("%b<>", "")), 1, 300)..'' local release = '\nRelease: '..data.pretty_date_s if data.image_url_h2x1_s then image_url = ' ' else image_url = ' ' end local text = title..publish..system..image_url..fsk..player..release..link..description return text end function nintendo_search:action(msg, config, matches) local gametitle = matches[1] local text = nintendo_search:get_info(gametitle) if not text then utilities.send_reply(msg, config.errors.results) return end utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html') end return nintendo_search