#импорты
ngrok.set_auth_token(NGROK_TOKEN)
http_tunnel = ngrok.connect(5000, bind_tls=True)
# webhook settings
WEBHOOK_HOST = http_tunnel.public_url
WEBHOOK_PATH = ''
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
# webserver settings
WEBAPP_HOST = 'localhost' # or ip
WEBAPP_PORT = 5000
# Настройки логирования
now = datetime.datetime.now()
file_log = logging.FileHandler('./logs/{}-{}.log'.format(now.strftime("%Y-%m-%d"), now.strftime("%H:%M:%S")))
console_out = logging.StreamHandler()
logging.basicConfig(handlers=(file_log, console_out), format=u'%(filename)+13s [ LINE:%(lineno)-4s] %(levelname)-8s [%(asctime)s] %(message)s', level=logging.DEBUG)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot, storage=MemoryStorage())
dp.middleware.setup(LoggingMiddleware())
@dp.message_handler(commands=['buy'])
async def command(message: types.Message):
await message.delete() # удаляем сообщение, на которое поступил ответ
if not RANSOM:
############
else:
data = message.get_args().split(' ')
await message.answer('Ожидайте...')
await asyncio.sleep(20)
### Запуск бота
async def on_startup(dp):
await bot.set_webhook(WEBHOOK_URL)
# insert code here to run it after start
### Остановка бота
async def on_shutdown(dp):
logging.warning('Shutting down..')
# insert code here to run it before shutdown
# Remove webhook (not acceptable in some cases)
await bot.delete_webhook()
# Close DB connection (if used)
await dp.storage.close()
await dp.storage.wait_closed()
ngrok.disconnect(http_tunnel.public_url)
logging.warning('Bye!')
if __name__ == '__main__':
start_webhook(
dispatcher=dp,
webhook_path=WEBHOOK_PATH,
on_startup=on_startup,
on_shutdown=on_shutdown,
skip_updates=True,
host=WEBAPP_HOST,
port=WEBAPP_PORT,
)
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 21 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 20 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 21 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 19 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 20 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 21 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 20 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 200 20 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 504 0 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 504 0 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:52 +0000] "POST / HTTP/1.1" 504 0 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:55 +0000] "POST / HTTP/1.1" 200 20 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:55 +0000] "POST / HTTP/1.1" 200 19 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:55 +0000] "POST / HTTP/1.1" 200 21 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:55 +0000] "POST / HTTP/1.1" 200 21 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:55 +0000] "POST / HTTP/1.1" 200 21 "-" "Python/3.7 aiohttp/3.6.1" "-"
192.168.1.64 - - [13/Oct/2019:09:21:55 +0000] "POST / HTTP/1.1" 200 20 "-" "Python/3.7 aiohttp/3.6.1" "-"
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7face6e61d68>
Unclosed connector
connections: