guys. Please help. I watched youtube video – how to make TG bot by Python and Aiogram in Visual Studio Code. After I entered python main.py in terminal – nothing changed, so my bot is quiete when I typing something to it.
import asyncio
from aiogram import Bot, Dispatcher, F
from aiogram.types import Message
from aiogram.filters import CommandStart, Command
bot = Bot(token='*token API code*')
dp = Dispatcher()
@dp.message(CommandStart())
async def cmd_start(message: Message):
await message.answer('Привет!')
await message.reply('Как дела?')
@dp.message(Command('help'))
async def cmd_help(message: Message):
await message.answer('Вы нажали на кнопку помощи')
@dp.message(F.text == 'У меня всё хорошо')
async def nice(message: Message):
await message.answer('Я очень рад')
async def main():
await dp.start_polling(bot)
if __name__ == '__mane__':
try:
asyncio.run(main())
except KeyboardInterrupt:
print('Бот выключен')
This is how it is looking in VS Code
New contributor
Dashwind is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.