An easy way to crate inline Telegram bots and you can get json file from the user answers
Project description
MkBot is an easy way to crate inline Telegram bots and you can get json file from the user answers
usage example
import telebot
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mkbot-1.0.0.tar.gz
(3.4 kB
view details)
Built Distribution
mkBot-1.0.0-py3-none-any.whl
(3.8 kB
view details)
File details
Details for the file mkbot-1.0.0.tar.gz
.
File metadata
- Download URL: mkbot-1.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2740789623192f4a573a13ab5356d135372c4244ef57413920169d60f260d7 |
|
MD5 | 72e09d2e03bc5ab2e0e4da229057ed4d |
|
BLAKE2b-256 | 9f29e8466509fae99550ffa562c5a48632060c5f603f5fab524bf11e6c110ed7 |
File details
Details for the file mkBot-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: mkBot-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39b1e3c33bba94c43dc0f0554760a81253f9314b06777012d1e408733b93de06 |
|
MD5 | e0443389571d8cfc2dcc9afa2ea5f36f |
|
BLAKE2b-256 | 43f32415c3495886569fd37b964ee36203c3ee8f2ecd6c889141808bf84f02f8 |