mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 19:00:23 +00:00
misc: code consistency and bot instance creation (#1482)
* misc: code consistency and bot instance creation * Changelog for aiogram#1482 * misc: consistency of comments and dispatcher instance creation * misc: removed routers example * Update CHANGES/1482.misc.rst --------- Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
This commit is contained in:
parent
b08ba78898
commit
e3dc7d576b
13 changed files with 54 additions and 30 deletions
|
|
@ -7,7 +7,8 @@ from os import getenv
|
|||
|
||||
from aiohttp import web
|
||||
|
||||
from aiogram import Bot, Dispatcher, Router, types
|
||||
from aiogram import Bot, Dispatcher, Router
|
||||
from aiogram.client.default import DefaultBotProperties
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.filters import CommandStart
|
||||
from aiogram.types import Message
|
||||
|
|
@ -29,7 +30,7 @@ WEBHOOK_PATH = "/webhook"
|
|||
WEBHOOK_SECRET = "my-secret"
|
||||
# Base URL for webhook will be used to generate webhook URL for Telegram,
|
||||
# in this example it is used public DNS with HTTPS support
|
||||
BASE_WEBHOOK_URL = "https://aiogram.dev/"
|
||||
BASE_WEBHOOK_URL = "https://aiogram.dev"
|
||||
|
||||
# All handlers should be attached to the Router (or Dispatcher)
|
||||
router = Router()
|
||||
|
|
@ -49,7 +50,7 @@ async def command_start_handler(message: Message) -> None:
|
|||
|
||||
|
||||
@router.message()
|
||||
async def echo_handler(message: types.Message) -> None:
|
||||
async def echo_handler(message: Message) -> None:
|
||||
"""
|
||||
Handler will forward receive a message back to the sender
|
||||
|
||||
|
|
@ -78,8 +79,8 @@ def main() -> None:
|
|||
# Register startup hook to initialize webhook
|
||||
dp.startup.register(on_startup)
|
||||
|
||||
# Initialize Bot instance with a default parse mode which will be passed to all API calls
|
||||
bot = Bot(TOKEN, parse_mode=ParseMode.HTML)
|
||||
# Initialize Bot instance with default bot properties which will be passed to all API calls
|
||||
bot = Bot(token=TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
|
||||
|
||||
# Create aiohttp.web.Application instance
|
||||
app = web.Application()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue