Skip to main content

Flastel – Telegram Bot API.

Project description

Installation

  pip install flastel

Flastel

Flastel is a new module for creating a Telegram bot.
You will be able to create several bots on your site by setting them up on your hosting.
The "polling" mode is also supported.
With the "webhook" method, you don't need multi-mode support. You no longer need to create a background specifically for the bot.
This module supports weak hosting, which allows you to save money.

Usage/Examples

from Flastel import TelegramPollingBot
import asyncio
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

bot_token = "bot_token"
bot = TelegramPollingBot(bot_token)

@bot.command(commands=["/start"], caps_ignore=False)
async def start_command(message):
    chat_id = message.chat_id
    from_user_name = message.from_user.all_name
    await bot.send_message(chat_id, f"Привіт, {from_user_name}! Це стартова команда.", parse_mode="HTML")
    
@bot.command_with_params(commands=["/start"], params=["play", "say", "pay"])
async def start_command_with_params(message, params):
    chat_id = message.chat_id
    from_user_name = message.from_user.all_name
    await bot.send_message(chat_id, f"Привіт, {from_user_name}! Це стартова команда з параметрами {params}.")

@bot.messages_text(messages_txt=["Hello"],  caps_ignore=True)
async def message_handler(message):
    chat_id = message.chat_id
    from_user_name = message.from_user.all_name
    await bot.send_message(chat_id, f"Привіт, {from_user_name}! Дякую за таку привітність.")

@bot.command(commands=["/donate"], caps_ignore=False)
async def donate_command(message):
    user_id = message.chat_id
    title = 'На розвиток модуля'
    description = 'Ня, насправді ці кошти підуть на каву розробнику ʕ•́ᴥ•̀ʔっ'
    payload = 'new_donate'
    currency = 'XTR'
    prices = ['Donates', 10]
    await bot.send_pay(user_id, title, description, payload, currency, prices, in_support=False)

@bot.pay_pre(currency="XTR", prices=[10, 20])
async def handle_xtr_payment(query_data):
    await bot.ok_pay(query_data)

@bot.successful_payment(currency="XTR", prices=[10, 20])
async def handle_successful_xtr_payment(payment_data):
    chat_id = payment_data.chat_id
    await bot.send_message(chat_id,
                f"""Дякую за кружечку кави, тепер на у мене на одну кружку більше!
              пј€гЃЈпјѕв–їпјѕпј‰\nб•™(^в–ї^-б•™) {payment_data.total_amount}{payment_data.currency}""")

if __name__ == "__main__":
    asyncio.run(bot.run_polling())

Links

Telegram Chat
PyPI
Wiki

Support

For support, email gosdepyxa@gmail.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flastel-0.0.14.5.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flastel-0.0.14.5-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file flastel-0.0.14.5.tar.gz.

File metadata

  • Download URL: flastel-0.0.14.5.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for flastel-0.0.14.5.tar.gz
Algorithm Hash digest
SHA256 a7f1cd60ec53e29353677027af3ec7e4da5fe6094c10c736fd2f2eb509c6b0a3
MD5 dddd34f776d19741c29af3475fa9c59f
BLAKE2b-256 5317a35a13428d023e4a7fa61908a90a99f04169c9d972f010caaf6a36141ef3

See more details on using hashes here.

File details

Details for the file Flastel-0.0.14.5-py3-none-any.whl.

File metadata

  • Download URL: Flastel-0.0.14.5-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for Flastel-0.0.14.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4f7d151f978c4cb2420a34bb12bac9152433ea896e2e9f930b709d97c9b83b
MD5 7e4e28bcd3935823c858618072f9c128
BLAKE2b-256 961b17c45227b77319f11e84aa28c6e3928f5dca94d758f592033e6f3f8cabfa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page