Fix config being frozen
This commit is contained in:
parent
649b5367b0
commit
ea28f2cebe
1 changed files with 25 additions and 1 deletions
|
@ -1,8 +1,11 @@
|
|||
import asyncio
|
||||
import copy
|
||||
import time
|
||||
|
||||
import click
|
||||
import logging
|
||||
|
||||
import niobot
|
||||
from tortoise import run_async
|
||||
|
||||
|
||||
|
@ -48,15 +51,36 @@ def cli(log_level: str, log_file: str | None):
|
|||
def run(resume: bool):
|
||||
"""Runs the bot"""
|
||||
log.info("Starting bot.")
|
||||
log.debug("Importing instance...")
|
||||
from .main import bot
|
||||
log.debug("Import complete.")
|
||||
|
||||
if resume is False:
|
||||
bot.config.store_sync_tokens = False
|
||||
log.debug("Resume is false, hijacking config...")
|
||||
original_config = copy.copy(bot.config)
|
||||
new_config = niobot.AsyncClientConfig(
|
||||
store=original_config.store,
|
||||
encryption_enabled=original_config.encryption_enabled,
|
||||
store_name=original_config.store_name,
|
||||
pickle_key=original_config.pickle_key,
|
||||
store_sync_tokens=False,
|
||||
custom_headers=original_config.custom_headers,
|
||||
max_limit_exceeded=original_config.max_limit_exceeded,
|
||||
max_timeouts=original_config.max_timeouts,
|
||||
backoff_factor=original_config.backoff_factor,
|
||||
max_timeout_retry_wait_time=original_config.max_timeout_retry_wait_time,
|
||||
request_timeout=original_config.request_timeout,
|
||||
io_chunk_size=original_config.io_chunk_size
|
||||
)
|
||||
bot.config = new_config
|
||||
bot.load_store()
|
||||
bot.loaded_sync_token = ""
|
||||
log.debug("Bot is now prepared for a complete sync")
|
||||
log.critical("Not resuming from previous sync. This may be slow!")
|
||||
time.sleep(3)
|
||||
|
||||
# run_async(bot.start(access_token=bot.cfg["bot"]["access_token"]))
|
||||
log.debug("All pistons firing")
|
||||
asyncio.run(bot.start(access_token=bot.cfg["bot"]["access_token"]))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue