local sankakucomplex = {} function sankakucomplex:init(config) sankakucomplex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sc', true):t('sankaku', true).table sankakucomplex.doc = [[* ]]..config.cmd_pat..[[sc* __: Sucht auf Sankaku mit diesen Tags]] end sankakucomplex.command = 'sc ' function sankakucomplex:get_post(tag) local user = cred_data.sankaku_username local password = cred_data.sankaku_pw --Your SHA1 hashed password. (echo "choujin-steiner--YOUR-PASSWORD--" | sha1sum) local BASE_URL = 'https://chan.sankakucomplex.com' local url = BASE_URL..'/post/index.json?login='..user..'&password_hash='..password..'&tags='..tag local b,c = https.request(url) if c ~= 200 then return nil end local complex = json.decode(b) if not complex[1] then return nil end local i = math.random(#complex) local link_image = 'https:'..complex[i].file_url return link_image end function sankakucomplex:action(msg, config) local input = utilities.input_from_msg(msg) if not input then utilities.send_reply(self, msg, sankakucomplex.doc, true) return end local tag = string.gsub(input, " ", '_' ) local tag = string.gsub(tag, ":", '%%3A' ) local url = sankakucomplex:get_post(tag) if not url then utilities.send_reply(self, msg, config.errors.results) return end utilities.send_typing(self, msg.chat.id, 'upload_photo') local file = download_to_file(url) if string.match(url, ".gif") or string.match(url, ".zip") or string.match(url, ".webm") or string.match(url, ".mp4") then utilities.send_document(self, msg.chat.id, file) else utilities.send_photo(self, msg.chat.id, file) end utilities.send_reply(self, msg, url) end return sankakucomplex