Flask-inspired Telegram bot micro framework for Python.
Project description
Telegrask
Flask-inspired Telegram bot micro framework for Python. Main idea is to use callback function decorators and make bot creating more intuitive for developer.
Installing
$ python3 -m pip install Telegrask
Simple "Hello World" bot example
from telegrask import Telegrask
bot = Telegrask("BOT_TOKEN")
@bot.command("hello", help='display "Hello, World!"')
def hello_command(update, context):
update.message.reply_text("Hello, World!")
if __name__ == "__main__":
bot.run(debug=True)
More examples in examples folder.
Equivalent in pure python-telegram-bot
Click to show
from telegram.ext import Updater, CommandHandler
from telegram import ParseMode
import logging
logging.basicConfig(format="%(levelname)s - %(message)s", level=logging.DEBUG)
logger = logging.getLogger(__name__)
def hello_command(update, context):
update.message.reply_text("Hello, World!")
def help_command(update, context):
help_content = """*Available commands*
/hello
display "Hello, World!"
/help
display this message
"""
update.message.reply_text(help_content, parse_mode=ParseMode.MARKDOWN)
def main():
global updater
updater = Updater("BOT_TOKEN")
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("hello", hello_command))
dispatcher.add_handler(CommandHandler(["help", "start"], help_command))
updater.start_polling()
updater.idle()
if __name__ == "__main__":
main()
Useful links
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
Telegrask-0.3.9.tar.gz
(9.2 kB
view hashes)
Built Distribution
Telegrask-0.3.9-py3-none-any.whl
(12.6 kB
view hashes)
Close
Hashes for Telegrask-0.3.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14b21deb7ffe728c0e82d1f2af3cb51b4a721104d261464b4967dcda159c82b6 |
|
MD5 | 6e9869663c2dd9da3244c287d02d4e10 |
|
BLAKE2b-256 | ffd3ad194ae254f0b3a02c443bab2443afd214d8149f430786a739dc4d1c63c2 |