MkBot is an easy way to crate inline Telegram bots and you can get json file from the user answers
usage example
import telebot
from mkBot import mkBot
from telebot.types import InlineKeyboardButton
# bot
bot = telebot.TeleBot("Bot_token")
# functions
def all(msg):
main.save(msg, msg.text)
main.check("send", msg)
def question(msg):
all(msg)
main.gen_json("output.json")
# the questions list
questions = [
{
"id" : 1,
"text" : "Do you want to start ?",
"buttons" : [
[InlineKeyboardButton("start", callback_data="yes")]
]
},
{
"id" : 2,
"text" : "How old are you",
"json_name" : "age",
"function": question
},
{
"id" : 3,
"text" : "the answers has been send",
"buttons" : [
[InlineKeyboardButton("again ?", callback_data="new")],
]
},
]
# define the main class
main = mkBot.Main(queslist = questions, bot = bot)
@bot.message_handler(func = lambda message:True)
def message(msg):
if msg.text == "/start":
main.send_frist(msg)
# the callback handler that gets all inline buttons when has been clicked
@bot.callback_query_handler(func=lambda chosen_inline_result:True)
def inline(call):
main.save(call.message, call.data)
if main.index < len(questions) - 1:
main.check("edit", call.message)
else:
main.send_frist(call.message)
bot.polling()
for more informations see the source code
Release files for mkBot 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mkbot-1.0.1.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mkbot-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / mkbot-1.0.1.tar.gz
| Download URL | mkbot-1.0.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
335d7567b814320961aa9448ea28efc598c5aca228f7a9bf7256cf9e5bf0a4dc
|
|
BLAKE2b-256 checksum How to use checksums |
e3e47519ae7e4d87619b2fb8f9ece5e9f52f1f625177153c3cc27cc74fc583c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / mkbot-1.0.1-py3-none-any.whl
| Download URL | mkbot-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
017ac4dfe64714e37ebd1d7c23b77cea71e2306fe2c13ff09dd9b7319859c71b
|
|
BLAKE2b-256 checksum How to use checksums |
d720c5b23fc5b57f097dba08a7d0b0f3e87263ea9efca6618d661b8a3abd7b2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|