Merge pull request #162 from setazer/dev-2.x

remove unnecessary loop definitions
This commit is contained in:
Alex Root Junior 2019-07-16 09:36:40 +03:00 committed by GitHub
commit 8fccd29594
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 34 deletions

View file

@ -9,9 +9,8 @@ API_TOKEN = 'BOT TOKEN HERE'
logging.basicConfig(level=logging.INFO)
log = logging.getLogger('broadcast')
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop, parse_mode=types.ParseMode.HTML)
dp = Dispatcher(bot, loop=loop)
bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.HTML)
dp = Dispatcher(bot)
def get_users():

View file

@ -13,8 +13,8 @@ logging.basicConfig(level=logging.INFO)
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()
dp = Dispatcher(bot, storage=storage)
dp.middleware.setup(LoggingMiddleware())

View file

@ -11,8 +11,8 @@ API_TOKEN = 'BOT TOKEN HERE'
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)

View file

@ -11,9 +11,7 @@ from aiogram.utils import executor
API_TOKEN = 'BOT TOKEN HERE'
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
bot = Bot(token=API_TOKEN)
# For example use simple MemoryStorage for Dispatcher.
storage = MemoryStorage()
@ -117,4 +115,4 @@ async def process_gender(message: types.Message, state: FSMContext):
if __name__ == '__main__':
executor.start_polling(dp, loop=loop, skip_updates=True)
executor.start_polling(dp, skip_updates=True)

View file

@ -7,8 +7,7 @@ API_TOKEN = 'BOT TOKEN HERE'
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@ -21,4 +20,4 @@ async def inline_echo(inline_query: types.InlineQuery):
if __name__ == '__main__':
executor.start_polling(dp, loop=loop, skip_updates=True)
executor.start_polling(dp, skip_updates=True)

View file

@ -4,8 +4,7 @@ from aiogram import Bot, Dispatcher, executor, filters, types
API_TOKEN = 'BOT TOKEN HERE'
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@ -40,4 +39,4 @@ async def send_welcome(message: types.Message):
if __name__ == '__main__':
executor.start_polling(dp, loop=loop, skip_updates=True)
executor.start_polling(dp, skip_updates=True)

View file

@ -9,12 +9,10 @@ from aiogram.utils.exceptions import Throttled
TOKEN = 'BOT TOKEN HERE'
loop = asyncio.get_event_loop()
# In this example Redis storage is used
storage = RedisStorage2(db=5)
bot = Bot(token=TOKEN, loop=loop)
bot = Bot(token=TOKEN)
dp = Dispatcher(bot, storage=storage)
@ -119,4 +117,4 @@ if __name__ == '__main__':
dp.middleware.setup(ThrottlingMiddleware())
# Start long-polling
executor.start_polling(dp, loop=loop)
executor.start_polling(dp)

View file

@ -9,9 +9,8 @@ from aiogram.utils import executor
BOT_TOKEN = 'BOT TOKEN HERE'
PAYMENTS_PROVIDER_TOKEN = '123456789:TEST:1234567890abcdef1234567890abcdef'
loop = asyncio.get_event_loop()
bot = Bot(BOT_TOKEN)
dp = Dispatcher(bot, loop=loop)
dp = Dispatcher(bot)
# Setup prices
prices = [
@ -96,4 +95,4 @@ async def got_payment(message: types.Message):
if __name__ == '__main__':
executor.start_polling(dp, loop=loop)
executor.start_polling(dp)

View file

@ -25,8 +25,7 @@ GET_IP_URL = 'http://bot.whatismyipaddress.com/'
logging.basicConfig(level=logging.INFO)
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop, proxy=PROXY_URL)
bot = Bot(token=API_TOKEN, proxy=PROXY_URL)
dp = Dispatcher(bot)
@ -62,4 +61,4 @@ async def cmd_start(message: types.Message):
if __name__ == '__main__':
start_polling(dp, loop=loop, skip_updates=True)
start_polling(dp, skip_updates=True)

View file

@ -17,8 +17,7 @@ API_TOKEN = 'BOT TOKEN HERE'
logging.basicConfig(level=logging.INFO)
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
bot = Bot(token=API_TOKEN)
# Throttling manager does not work without Leaky Bucket.
# 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__':
start_polling(dp, loop=loop, skip_updates=True)
start_polling(dp, skip_updates=True)

View file

@ -37,8 +37,7 @@ WEBAPP_PORT = 3001
BAD_CONTENT = ContentTypes.PHOTO & ContentTypes.DOCUMENT & ContentTypes.STICKER & ContentTypes.AUDIO
loop = asyncio.get_event_loop()
bot = Bot(TOKEN, loop=loop)
bot = Bot(TOKEN)
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)

View file

@ -18,8 +18,7 @@ WEBAPP_PORT = 3001
logging.basicConfig(level=logging.INFO)
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)