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 hashes)

Uploaded Python 3

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