mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Bump examples, docs and executor (nothing)
This commit is contained in:
parent
21908739e9
commit
9f13e11e6b
9 changed files with 57 additions and 21 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
**This example is outdated**
|
||||
In this example used ArgumentParser for configuring Your bot.
|
||||
|
||||
Provided to start bot with webhook:
|
||||
|
|
|
|||
|
|
@ -1,19 +1,27 @@
|
|||
import asyncio
|
||||
"""
|
||||
This is a echo bot.
|
||||
It echoes any incoming text messages.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from aiogram import Bot, types, Dispatcher, executor
|
||||
from aiogram import Bot, Dispatcher, executor, types
|
||||
|
||||
API_TOKEN = 'BOT TOKEN HERE'
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
bot = Bot(token=API_TOKEN, loop=loop)
|
||||
# Initialize bot and dispatcher
|
||||
bot = Bot(token=API_TOKEN)
|
||||
dp = Dispatcher(bot)
|
||||
|
||||
|
||||
@dp.message_handler(commands=['start', 'help'])
|
||||
async def send_welcome(message: types.Message):
|
||||
"""
|
||||
This handler will be called when client send `/start` or `/help` commands.
|
||||
"""
|
||||
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
|
||||
|
||||
|
||||
|
|
@ -30,4 +38,4 @@ async def echo(message: types.Message):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
executor.start_polling(dp, loop=loop, skip_updates=True)
|
||||
executor.start_polling(dp, skip_updates=True)
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ dp = Dispatcher(bot)
|
|||
|
||||
|
||||
@dp.message_handler(filters.RegexpCommandsFilter(regexp_commands=['item_([0-9]*)']))
|
||||
async def send_welcome(message: types.Message):
|
||||
regexp_command = message.conf['regexp_command']
|
||||
async def send_welcome(message: types.Message, regexp_command):
|
||||
await message.reply("You have requested an item with number: {}".format(regexp_command.group(1)))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
"""
|
||||
Example outdated
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import ssl
|
||||
import sys
|
||||
|
|
@ -5,7 +9,7 @@ import sys
|
|||
from aiohttp import web
|
||||
|
||||
import aiogram
|
||||
from aiogram import Bot, types, Version
|
||||
from aiogram import Bot, types
|
||||
from aiogram.contrib.fsm_storage.memory import MemoryStorage
|
||||
from aiogram.dispatcher import Dispatcher
|
||||
from aiogram.dispatcher.webhook import get_new_configured_app, SendMessage
|
||||
|
|
|
|||
|
|
@ -31,13 +31,11 @@ async def echo(message: types.Message):
|
|||
async def on_startup(dp):
|
||||
await bot.set_webhook(WEBHOOK_URL)
|
||||
# insert code here to run it after start
|
||||
#
|
||||
|
||||
|
||||
async def on_shutdown(dp):
|
||||
# insert code here to run it before shutdown
|
||||
#
|
||||
await bot.close()
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue