Skip to content

Instantly share code, notes, and snippets.

@oktober13
Created July 18, 2023 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oktober13/2279fc262bfcece14f4c66025b2fc130 to your computer and use it in GitHub Desktop.
Save oktober13/2279fc262bfcece14f4c66025b2fc130 to your computer and use it in GitHub Desktop.
A simple template for creating a Telegram bot that greets new users and responds to basic commands.
import logging
from aiogram import Bot, Dispatcher, types
API_TOKEN = 'your_token'
logging.basicConfig(level=logging.INFO)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def handle_start_command(message: types.Message):
await message.reply("Hello! I'm a bot. How can I assist you?")
@dp.message_handler(commands=['help'])
async def handle_help_command(message: types.Message):
await message.reply("This is an example template for a Telegram bot.")
if __name__ == '__main__':
from aiogram import executor
executor.start_polling(dp, skip_updates=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment