mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 18:01:04 +00:00
remove unnecessary loop definitions
This commit is contained in:
parent
66849ec770
commit
1ea76cd902
12 changed files with 22 additions and 34 deletions
|
|
@ -9,9 +9,8 @@ API_TOKEN = 'BOT TOKEN HERE'
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
log = logging.getLogger('broadcast')
|
log = logging.getLogger('broadcast')
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.HTML)
|
||||||
bot = Bot(token=API_TOKEN, loop=loop, parse_mode=types.ParseMode.HTML)
|
dp = Dispatcher(bot)
|
||||||
dp = Dispatcher(bot, loop=loop)
|
|
||||||
|
|
||||||
|
|
||||||
def get_users():
|
def get_users():
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
API_TOKEN = 'BOT TOKEN HERE'
|
API_TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
bot = Bot(token=API_TOKEN, loop=loop, parse_mode=types.ParseMode.HTML)
|
bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.HTML)
|
||||||
storage = MemoryStorage()
|
storage = MemoryStorage()
|
||||||
dp = Dispatcher(bot, storage=storage)
|
dp = Dispatcher(bot, storage=storage)
|
||||||
dp.middleware.setup(LoggingMiddleware())
|
dp.middleware.setup(LoggingMiddleware())
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ API_TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
bot = Bot(token=API_TOKEN, loop=loop, parse_mode=types.ParseMode.MARKDOWN)
|
bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.MARKDOWN)
|
||||||
dp = Dispatcher(bot)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,7 @@ from aiogram.utils import executor
|
||||||
|
|
||||||
API_TOKEN = 'BOT TOKEN HERE'
|
API_TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN)
|
||||||
|
|
||||||
bot = Bot(token=API_TOKEN, loop=loop)
|
|
||||||
|
|
||||||
# For example use simple MemoryStorage for Dispatcher.
|
# For example use simple MemoryStorage for Dispatcher.
|
||||||
storage = MemoryStorage()
|
storage = MemoryStorage()
|
||||||
|
|
@ -117,4 +115,4 @@ async def process_gender(message: types.Message, state: FSMContext):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
executor.start_polling(dp, loop=loop, skip_updates=True)
|
executor.start_polling(dp, skip_updates=True)
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ API_TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN)
|
||||||
bot = Bot(token=API_TOKEN, loop=loop)
|
|
||||||
dp = Dispatcher(bot)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,4 +20,4 @@ async def inline_echo(inline_query: types.InlineQuery):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
executor.start_polling(dp, loop=loop, skip_updates=True)
|
executor.start_polling(dp, skip_updates=True)
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ from aiogram import Bot, Dispatcher, executor, filters, types
|
||||||
|
|
||||||
API_TOKEN = 'BOT TOKEN HERE'
|
API_TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN)
|
||||||
bot = Bot(token=API_TOKEN, loop=loop)
|
|
||||||
dp = Dispatcher(bot)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,4 +39,4 @@ async def send_welcome(message: types.Message):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
executor.start_polling(dp, loop=loop, skip_updates=True)
|
executor.start_polling(dp, skip_updates=True)
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,10 @@ from aiogram.utils.exceptions import Throttled
|
||||||
|
|
||||||
TOKEN = 'BOT TOKEN HERE'
|
TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
|
|
||||||
# In this example Redis storage is used
|
# In this example Redis storage is used
|
||||||
storage = RedisStorage2(db=5)
|
storage = RedisStorage2(db=5)
|
||||||
|
|
||||||
bot = Bot(token=TOKEN, loop=loop)
|
bot = Bot(token=TOKEN)
|
||||||
dp = Dispatcher(bot, storage=storage)
|
dp = Dispatcher(bot, storage=storage)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -119,4 +117,4 @@ if __name__ == '__main__':
|
||||||
dp.middleware.setup(ThrottlingMiddleware())
|
dp.middleware.setup(ThrottlingMiddleware())
|
||||||
|
|
||||||
# Start long-polling
|
# Start long-polling
|
||||||
executor.start_polling(dp, loop=loop)
|
executor.start_polling(dp)
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,8 @@ from aiogram.utils import executor
|
||||||
BOT_TOKEN = 'BOT TOKEN HERE'
|
BOT_TOKEN = 'BOT TOKEN HERE'
|
||||||
PAYMENTS_PROVIDER_TOKEN = '123456789:TEST:1234567890abcdef1234567890abcdef'
|
PAYMENTS_PROVIDER_TOKEN = '123456789:TEST:1234567890abcdef1234567890abcdef'
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
bot = Bot(BOT_TOKEN)
|
bot = Bot(BOT_TOKEN)
|
||||||
dp = Dispatcher(bot, loop=loop)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
# Setup prices
|
# Setup prices
|
||||||
prices = [
|
prices = [
|
||||||
|
|
@ -96,4 +95,4 @@ async def got_payment(message: types.Message):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
executor.start_polling(dp, loop=loop)
|
executor.start_polling(dp)
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@ GET_IP_URL = 'http://bot.whatismyipaddress.com/'
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN, proxy=PROXY_URL)
|
||||||
bot = Bot(token=API_TOKEN, loop=loop, proxy=PROXY_URL)
|
|
||||||
dp = Dispatcher(bot)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -62,4 +61,4 @@ async def cmd_start(message: types.Message):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
start_polling(dp, loop=loop, skip_updates=True)
|
start_polling(dp, skip_updates=True)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@ API_TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN)
|
||||||
bot = Bot(token=API_TOKEN, loop=loop)
|
|
||||||
|
|
||||||
# Throttling manager does not work without Leaky Bucket.
|
# Throttling manager does not work without Leaky Bucket.
|
||||||
# Then need to use storages. For example use simple in-memory storage.
|
# Then need to use storages. For example use simple in-memory storage.
|
||||||
|
|
@ -40,4 +39,4 @@ async def send_welcome(message: types.Message):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
start_polling(dp, loop=loop, skip_updates=True)
|
start_polling(dp, skip_updates=True)
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,7 @@ WEBAPP_PORT = 3001
|
||||||
|
|
||||||
BAD_CONTENT = ContentTypes.PHOTO & ContentTypes.DOCUMENT & ContentTypes.STICKER & ContentTypes.AUDIO
|
BAD_CONTENT = ContentTypes.PHOTO & ContentTypes.DOCUMENT & ContentTypes.STICKER & ContentTypes.AUDIO
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(TOKEN)
|
||||||
bot = Bot(TOKEN, loop=loop)
|
|
||||||
storage = MemoryStorage()
|
storage = MemoryStorage()
|
||||||
dp = Dispatcher(bot, storage=storage)
|
dp = Dispatcher(bot, storage=storage)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ WEBAPP_PORT = 3001
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
bot = Bot(token=API_TOKEN)
|
||||||
bot = Bot(token=API_TOKEN, loop=loop)
|
|
||||||
dp = Dispatcher(bot)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue