Generic views for python-telegram-bot
Project description
Jackfruit
Introduction
This library provides a simple way for creating telegram bots with deep level menu.
Components
Library give users components, like:
- Menu (MenuView) - give user ability select menu item and navigate on menus;
- Text Input (TextDataInputView) - give user ability enter text data;
- Image Input (PhotoDataInputView) - give user ability send image to bot;
- Document Input (DocumentDataInputView) - give user ability send files to bot;
- Audio Input (AudioDataInputView) - give user ability send audio files to bot;
- Video Input (VideoDataInputView) - give user ability send video files to bot;
- Voice Input (VoiceDataInputView) - give user ability send voice messages to bot;
- Sticker Input (StickerDataInputView) - give user ability send sticker to bot;
You can use class GenericDataView for show user screen, that blocking next navigation and force user to use command syntax.
All components may be easy customized, for more details please see source code (it have commented).
Usage
from os import environ
from telegram.ext import Updater
from jackfruit import *
class MainMenu(MenuView):
text = 'Hello from my bot!'
menu_items = [[('Enter my name', 'EnterName'), ('Select my age', 'SelectAge')], ]
class EnterName(TextDataInputView):
text = 'Enter my name:'
def process_data(self, state, update, context, data):
return 'MainMenu'
class SelectAge(MenuView):
text = 'Select my age:'
menu_items = [[('Below 18', 'MainMenu'), ('Above 18', 'MainMenu')]]
updater = Updater(environ['TOKEN'], use_context=True)
main_menu = MainMenu()
enter_name = EnterName()
select_age = SelectAge()
Jackfruit(updater.dispatcher, main_menu, [('start', 'MainMenu')]).register(enter_name, select_age)
updater.start_polling()
updater.idle()
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
jackfruit-0.12-py3-none-any.whl
(23.0 kB
view details)
File details
Details for the file jackfruit-0.12-py3-none-any.whl
.
File metadata
- Download URL: jackfruit-0.12-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2019b0a0c402c7b00d5c21b89c4e224bb8de78ee2ca3c38ee7dae5de9173c78b |
|
MD5 | 354819c9a565eee33b9e81056cd5c7c8 |
|
BLAKE2b-256 | 631b3e049984e154368f79dbd8486b383a7d55ae5cf4accb2ec4aa4cf0ca5be4 |