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

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

BotApiTelegram-0.0.7-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: BotApiTelegram-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.6

File hashes

Hashes for BotApiTelegram-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 85e661d0d6e330b5e2decc2bd2ac655783812f9a4c4437a85b5c168a2d2e00b3
MD5 7814cac7e8bb995c5bb63db2e47185ba
BLAKE2b-256 35ed80de8f934542a41ca48400c7cebc875508022630c7392a4689826c10db8b

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