telebot (KyleJamesWalker) Telegram Bot Library

0.0.5 · abandoned · verified Thu Apr 16

This `telebot` library (version 0.0.5) by KyleJamesWalker is a minimalist Telegram bot library featuring simple route decorators for message handling. It was last updated in 2018 and appears to be abandoned, meaning it might not be compatible with the latest Telegram API changes and could have unaddressed issues. Crucially, it shares a package name with the significantly more popular and actively maintained `pyTelegramBotAPI` library, leading to frequent user confusion.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the bot, define command handlers using decorators, and start the polling loop for the `KyleJamesWalker/telebot` library. Ensure you have a valid Telegram Bot Token from BotFather, ideally passed via an environment variable.

import os
from telebot import bot, handle_message

# This token should be obtained from BotFather on Telegram.
# For local testing, you can hardcode it, but for deployment use environment variables.
BOT_TOKEN = os.environ.get('TELEBOT_TOKEN', 'YOUR_BOT_TOKEN_HERE')

# Initialize the bot
my_bot = bot(BOT_TOKEN)

@handle_message("/start")
def start_command(message):
    my_bot.post_message(message["chat"]["id"], "Hello! I am your simple bot.")

@handle_message("/hello")
def hello_command(message):
    my_bot.post_message(message["chat"]["id"], "Hi there!")

@handle_message("default") # This acts as a fallback for any other message
def default_message(message):
    my_bot.post_message(message["chat"]["id"], "I received: " + message["text"])

if __name__ == "__main__":
    if BOT_TOKEN == 'YOUR_BOT_TOKEN_HERE':
        print("WARNING: Please replace 'YOUR_BOT_TOKEN_HERE' with your actual bot token or set the TELEBOT_TOKEN environment variable.")
    print("Starting KyleJamesWalker/telebot (version 0.0.5). Press Ctrl+C to stop.")
    print("Using token ending in:", BOT_TOKEN[-4:])
    # The run() method starts an infinite loop for polling
    my_bot.run()

view raw JSON →