Skip to main content

A python library for Telegram Bot Api.

Project description

For examples and docs check out:

Basic Installization and 'Hello.' reply.

from BotApiTelegram import TelegramBot, filters

bot_token = '' # Your bot token from @BotFather.

bot = TelegramBot('bot_db', bot_token=bot_token)

@bot.on_update(filters.command('start'))
def on_start(message):
    message.reply('Hello.')

bot.start_polling()

Creating Buttons.

from BotApiTelegram import TelegramBot, filters
from BotApiTelegram.types import Button

bot_token = '' # Your bot token from @BotFather.

bot = TelegramBot('bot_db', bot_token=bot_token)

@bot.on_update(filters.command('start'))
def on_start(message):
    buttons = [
        [Button.inline('This is a button', 'callback_data')],
        [Button.inline('Two buttons', 'callback_data'), Button.inline('In one row.', 'callback_data')],
        [Button.url('URL Link button', 'https://github.com/SastaDev/BotApiTelegram')]
        ]
    message.reply('An Example of inline keyboard buttons.', buttons=buttons)

bot.start_polling()

Adding filters.

from BotApiTelegram import TelegramBot, filters

bot_token = '' # Your bot token from @BotFather.

bot = TelegramBot('bot_db', bot_token=bot_token)

# command '/start', you can change the prefix '/' by passing starts_with in filters.command
# Example: filters.command('start, starts_with='!')
@bot.on_update(filters.command('start'))
def on_start(message):
    message.reply('Hello by *filters.command*.')

# You can use regex for text, command and callback query data.
@bot.on_update(filters.regex('^/start'))
def on_start(message):
    message.reply('Hello by *filters.regex*.')

# Using filters for callback query.
@bot.on_update(filters.CallbackQuery('data'))
def on_callback_query_data(callback_query):
    callback_query.answer('The callback data is "data".', show_alert=True)

bot.start_polling()

Links

GitHub Repo Link: SastaDev/BotApiTelegram. Documentation Link: BotApiTelegramDocs. Updates Channel on Telegram: BotApiTelegram. Help Support Chat on Telegram: BotApiTelegramChat.

Project details


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

BotApiTelegram-0.0.8-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file BotApiTelegram-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for BotApiTelegram-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 90fe9e429cf6e3f2cd76eb4883426db716dbc45e6f38f8da1159ed829b35eb40
MD5 42858f8b35252e6614602983283ef37f
BLAKE2b-256 9d22a9a357b5ad371c5f03f9321f869850c0a3d45ac547aa4fba7a74b2a356fb

See more details on using hashes here.

Supported by

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