https://link.ok.ru/OG3L1
https://link.ok.ru/O5PO1
**********************************КОД************************************************************
import asyncio
from aiogram import Bot, Dispatcher
dp = Dispatcher()
async def main(): bot = Bot(token='123token')
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())
**********************************КОД************************************************************
bot = Bot(token='123token')
dp = Dispatcher()
**********************************КОД************************************************************
async def main():
await dp.start_polling(bot)
**********************************КОД************************************************************
if __name__ == '__main__':
asyncio.run(main())
**********************************КОД************************************************************
import asyncio
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram.filters import CommandStart
dp = Dispatcher()
@dp.message(CommandStart())
async def cmd_start(message: Message):
await message.answer('Привет!')
async def main(): bot = Bot(token='123token')
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())
**********************************КОД************************************************************
python
run.py
**********************************КОД************************************************************
if __name__ == '__main__':
try:
asyncio.run(main())
except:
print('Exit')
**********************************КОД************************************************************
TOKEN='123token'
**********************************КОД************************************************************
import asyncio
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram.filters import CommandStart
from config import TOKEN
dp = Dispatcher()
@dp.message(CommandStart())
async def cmd_start(message: Message):
await message.answer('Привет!')
async def main(): bot = Bot(token=TOKEN)
await dp.start_polling(bot)
if __name__ == '__main__':
try:
asyncio.run(main())
except KeyboardInterrupt:
print('Exit')
**********************************КОД************************************************************
import os
import asyncio
from dotenv import load_dotenv
from aiogram import Bot, Dispatcher, F
from aiogram.types import Message
from aiogram.filters import CommandStart, Command
dp = Dispatcher()
@dp.message(CommandStart())
async def cmd_start(message: Message):
await message.answer(text='Привет!')
@dp.message(Command('help'))
async def cmd_help(message: Message):
await message.answer('Пока что бот не умеет ничего!')
@dp.message(F.text == 'Привет!')
async def hello(message: Message):
await message.reply('Как дела?')
@dp.message()
async def echo(message: Message):
await message.answer('Это неизвестная команда.')
async def main():
load_dotenv()
bot = Bot(token=os.getenv('TG_TOKEN'))
await dp.start_polling(bot)
if __name__ == '__main__':
try:
asyncio.run(main())
except KeyboardInterrupt:
print('Бот выключен')