Giter Site home page Giter Site logo

How to use buttons? about telebot HOT 4 CLOSED

smartnode avatar smartnode commented on July 28, 2024
How to use buttons?

from telebot.

Comments (4)

smartnode avatar smartnode commented on July 28, 2024

Reply markup

You just need to send json string as reply_markup

const char *reply_markup = "{\"keyboard\":[[\"Yes\",\"No\"],[\"Maybe\"],[\"0\",\"1\",\"3\"]],\"one_time_keyboard\":True}"
ret = telebot_send_message(handle, chat_id, "Does it work", "HTML", false, false, message_id, reply_markup);

Inline keyboard

Here is JSON example of keyboards
3-row example

[[{"text":"text 1","callback_data":"1"},{"text":"Some button text 2","url":"https://elmurod.net"},{"text":"Some button text 3","callback_data":"3"}]]

2-row, 2+1 columns

[[{"text":"Text 1","callback_data":"1"},{"text":"Link 1","url":"https://elmurod.net"}],[{"text":"Text2","callback_data":"2"}]] 

from telebot.

Arcanum7 avatar Arcanum7 commented on July 28, 2024

I have try to send by first method simple json and it's fail:
[DEBUG][telebot_core_curl_perform:142]Response: {"ok":true,"result":[{"update_id":760823970, "message":{"message_id":56,"from":{"id":115948583,"is_bot":false,"first_name":"\u0421\u0430\u043c\u0443\u0438\u043b \u0413\u0435\u0440\u043c\u0430\u043d\u043e\u0432\u0438\u0447","last_name":"\u0410\u0440\u043a\u0430\u043d\u0443\u043c","username":"Arcanum7","language_code":"ru"},"chat":{"id":115948583,"first_name":"\u0421\u0430\u043c\u0443\u0438\u043b \u0413\u0435\u0440\u043c\u0430\u043d\u043e\u0432\u0438\u0447","last_name":"\u0410\u0440\u043a\u0430\u043d\u0443\u043c","username":"Arcanum7","type":"private"},"date":1603264033,"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}]}}]} Number of updates: 1 Самуил Германович: /start [ERROR][telebot_core_curl_perform:137]Wrong HTTP response received, response: 400

i had use this code:

if (strstr(message.text, "/start"))
    {
        const char* reply_markup = "{\"keyboard\":[[\"Yes\",\"No\"],[\"Maybe\"],[\"0\",\"1\",\"3\"]],\"one_time_keyboard\":True}";
        ret_proc = telebot_send_message(handle, message.chat->id, "Does it work", "HTML", false, false, updates[index].message.message_id, reply_markup);
     }

upd: how to use telebot_reply_keyboard_markup stuct?

from telebot.

Arcanum7 avatar Arcanum7 commented on July 28, 2024

and it work:
const char* reply_markup = " { \"keyboard\": [[{\"text\": \"1\"}],[{ \"text\": \"2\"},{ \"text\": \"3\"}]] } ";

last Q? for this issue - how to use telebot_reply_keyboard_markup ?
write pure json in c - it is very interesting existential experience, yep...

from telebot.

smartnode avatar smartnode commented on July 28, 2024

I don't have time to work on this project. I believe it would be better keyboards as data structure...

from telebot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.