local yandere = {} function yandere:init(config) yandere.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('yan', true):t('yandere', true).table yandere.doc = [[* ]]..config.cmd_pat..[[yan* __: Sucht auf Yandere mit diesen Tags]] end yandere.command = 'yan ' function yandere:get_post(tag) local BASE_URL = 'https://yande.re' local url = BASE_URL..'/post.json?tags='..tag local b,c = https.request(url) if c ~= 200 then return nil end local yan = json.decode(b) if not yan[1] then return nil end local i = math.random(#yan) local link_image = yan[i].file_url return link_image end function yandere:action(msg, config) local input = utilities.input_from_msg(msg) if not input then utilities.send_reply(msg, yandere.doc, true) return end local tag = string.gsub(input, " ", '_' ) local url = yandere:get_post(tag) if not url then utilities.send_reply(msg, config.errors.results) return end utilities.send_typing(msg.chat.id, 'upload_photo') local file = download_to_file(url) utilities.send_photo(msg.chat.id, file, nil, msg.message_id) utilities.send_reply(msg, url) end return yandere