mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update docs
This commit is contained in:
parent
36163690a5
commit
2870a4ca99
20 changed files with 42 additions and 79 deletions
27
examples/local_server.py
Normal file
27
examples/local_server.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import logging
|
||||
|
||||
from aiogram import Bot, Dispatcher, executor, types
|
||||
from aiogram.bot.api import TelegramAPIServer
|
||||
from aiogram.types import ContentType
|
||||
|
||||
API_TOKEN = 'BOT TOKEN HERE'
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
# Create private Bot API server endpoints wrapper
|
||||
local_server = TelegramAPIServer.from_base('http://localhost')
|
||||
|
||||
# Initialize bot with using local server
|
||||
bot = Bot(token=API_TOKEN, server=local_server)
|
||||
# ... and dispatcher
|
||||
dp = Dispatcher(bot)
|
||||
|
||||
|
||||
@dp.message_handler(content_types=ContentType.ANY)
|
||||
async def echo(message: types.Message):
|
||||
await message.copy_to(message.chat.id)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
executor.start_polling(dp, skip_updates=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue