Skip to main content

netcherTG

A simple, dependency-light Python library for building Telegram bots on top of the official Telegram Bot HTTP API.

Install

pip install netcherTG

Getting a bot token

Message @BotFather on Telegram, run /newbot, and follow the prompts to get an API token.

Quick start

from netcherTG import Bot

bot = Bot("123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")

@bot.command("start")
def start(bot, message):
    bot.send_message(message.chat_id, f"Hello, {message.username}!")

@bot.command("echo")
def echo(bot, message):
    text = " ".join(message.args()) or "(nothing to echo)"
    bot.send_message(message.chat_id, text)

@bot.message_handler()
def fallback(bot, message):
    bot.send_message(message.chat_id, "I didn't understand that.")

bot.run()

Inline keyboards

from netcherTG import Bot, keyboards

bot = Bot("YOUR_TOKEN")

@bot.command("menu")
def menu(bot, message):
    kb = keyboards.inline_keyboard([
        [("Yes", "yes"), ("No", "no")],
    ])
    bot.send_message(message.chat_id, "Choose one:", reply_markup=kb)

@bot.callback_query_handler()
def on_click(bot, query):
    bot.answer_callback_query(query.id, text="Got it!")
    bot.send_message(query.message.chat_id, f"You picked: {query.data}")

bot.run()

Reply keyboards

from netcherTG import keyboards

kb = keyboards.reply_keyboard([["Option A", "Option B"], ["Cancel"]])
bot.send_message(chat_id, "Pick one:", reply_markup=kb)

API overview

Method Description
Bot(token) Create a bot instance
bot.send_message(chat_id, text, ...) Send a text message
bot.send_photo(chat_id, photo_url, caption=None) Send a photo
bot.edit_message_text(chat_id, message_id, text) Edit an existing message
bot.delete_message(chat_id, message_id) Delete a message
bot.answer_callback_query(id, text=None) Acknowledge a button press
bot.get_me() Get info about the bot
@bot.command(name) Register a /command handler
@bot.message_handler() Register a handler for plain text messages
@bot.callback_query_handler() Register a handler for inline button presses
bot.run(poll_interval=1.0) Start long-polling

License

MIT

Download files

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

Source Distribution

netchertg-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

netchertg-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file netchertg-0.1.0.tar.gz.

File metadata

  • Download URL: netchertg-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for netchertg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96f484db0c4f9832b7758cb7ffd4136571717a64c24a96912fa23297f4386f51
MD5 0a10e1685c1a926f77d94064742516c4
BLAKE2b-256 f4e1a9b04740015620aec5129016174d5ae1a1bc2ae398c2b56d5aa4cfd95a1f

See more details on using hashes here.

File details

Details for the file netchertg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: netchertg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for netchertg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 601d1badcdc41f81f5a3b636a78c406139f78ca44cc0fdc2072a07c69281fcf6
MD5 c744b93ba5415e4b153cfb915626d8f9
BLAKE2b-256 bdb937cdc7cada2a4e2a30280bc1491ec465918cb3a623384ff052bd8884de70

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