Created
July 18, 2023 09:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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