Skip to content

Instantly share code, notes, and snippets.

@MohammadHosseinGhorbani
Created August 4, 2024 22:49
Show Gist options
  • Save MohammadHosseinGhorbani/9f42177c3c41dace79d2b39bc2c53349 to your computer and use it in GitHub Desktop.
Save MohammadHosseinGhorbani/9f42177c3c41dace79d2b39bc2c53349 to your computer and use it in GitHub Desktop.
One-Liner Telegram Bot

One-Liner Telegram Bot (Using python-telegram-bot)

A simple Telegram bot that responds to the /start command with a basic text message.

This is just for fun and not a proper way to develop Telegram bots.

First, install the python-telegram-bot package:

python install -U python-telegram-bot

Bot Code

type("TelegramBot", (), {'__init__': lambda self: [setattr(self, 'app', __import__('telegram.ext').ext.ApplicationBuilder().token(TOKEN).build()), self.app.add_handler(__import__('telegram.ext').ext.CommandHandler('start', lambda update, context: update.message.reply_text("ONE LINE BOT!"))), None][-1], '__call__': lambda self: self.app.run_polling(drop_pending_updates=True)})()()

Make sure to get your bot's token from @BotFather and set it as TOKEN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment