Add the option to skip loading from last sync
This commit is contained in:
parent
6c3c9c4ff8
commit
d7db6aff93
2 changed files with 14 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import time
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import logging
|
import logging
|
||||||
|
@ -39,11 +40,22 @@ def cli(log_level: str, log_file: str | None):
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def run():
|
@click.option(
|
||||||
|
"--resume/--no-resume",
|
||||||
|
default=False,
|
||||||
|
help="Whether to do a full sync, or resume from previous"
|
||||||
|
)
|
||||||
|
def run(resume: bool):
|
||||||
"""Runs the bot"""
|
"""Runs the bot"""
|
||||||
log.info("Starting bot.")
|
log.info("Starting bot.")
|
||||||
from .main import bot
|
from .main import bot
|
||||||
|
|
||||||
|
if resume is False:
|
||||||
|
bot.config.store_sync_tokens = False
|
||||||
|
bot.loaded_sync_token = ""
|
||||||
|
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"]))
|
# run_async(bot.start(access_token=bot.cfg["bot"]["access_token"]))
|
||||||
asyncio.run(bot.start(access_token=bot.cfg["bot"]["access_token"]))
|
asyncio.run(bot.start(access_token=bot.cfg["bot"]["access_token"]))
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,7 @@ bot = NonsenseBot(
|
||||||
store_path=str(store.resolve()),
|
store_path=str(store.resolve()),
|
||||||
command_prefix=config["bot"].get("prefix", "h!"),
|
command_prefix=config["bot"].get("prefix", "h!"),
|
||||||
owner_id=config["bot"].get("owner_id") or "@nex:nexy7574.co.uk",
|
owner_id=config["bot"].get("owner_id") or "@nex:nexy7574.co.uk",
|
||||||
auto_read_messages=False,
|
auto_read_messages=False
|
||||||
config=niobot.AsyncClientConfig()
|
|
||||||
)
|
)
|
||||||
bot.cfg = config
|
bot.cfg = config
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue