Last active
November 27, 2023 14:12
-
-
Save topkecleon/8486cb63ff05fd755d6bae9d76ac4782 to your computer and use it in GitHub Desktop.
t.me/qtbot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local token = os.getenv('qtbot_token') | |
| local cat_api_key = os.getenv('cat_api_key') -- https://thecatapi.com/ | |
| local https = require('ssl.https') | |
| local json = require('dkjson') | |
| local bindings = require('bindings').set_token(token) -- https://github.com/topkecleon/bindings | |
| local cat_api_url = 'https://api.thecatapi.com/api/images/get?format=json&type=jpg&api_key=' | |
| local offset = 0 | |
| while true do | |
| local success, result = bindings.getUpdates{ | |
| timeout = 60, | |
| offset = offset, | |
| allowed_updates = '["message"]' | |
| } | |
| if success then | |
| for _, update in ipairs(result.result) do | |
| bindings.sendPhoto{ | |
| chat_id = update.message.chat.id, | |
| photo = json.decode((https.request(cat_api_url .. cat_api_key)))[1].url, | |
| reply_markup = '{"keyboard": [["CAT"]], "one_time_keyboard": true}' | |
| } | |
| offset = update.update_id + 1 | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment