Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def bot_main(ctx, basedir, stdout_loglevel):
"""delta.chat bot management command line interface."""
basedir = os.path.abspath(os.path.expanduser(basedir))
if not os.path.exists(basedir):
os.makedirs(basedir)
db_path = os.path.join(basedir, "account.db")
account = deltachat.Account(db_path, "deltabot/{}".format(sys.platform))
loglevel = getattr(logging, stdout_loglevel.upper())
logger = make_logger(basedir, loglevel)
ctx.bot = DeltaBot(account, logger)
def get_account(basedir, remove=False):
dbpath = os.path.join(basedir, "account.db")
if remove and os.path.exists(dbpath):
os.remove(dbpath)
acc = deltachat.Account(dbpath)
acc.db_path = dbpath
return acc
def make_bot_from_args(args, plugin_manager, account=None):
basedir = os.path.abspath(os.path.expanduser(args.basedir))
if not os.path.exists(basedir):
os.makedirs(basedir)
if account is None:
db_path = os.path.join(basedir, "account.db")
account = Account(db_path, "deltabot/{}".format(sys.platform))
logger = plugin_manager.hook.deltabot_get_logger(args=args)
return DeltaBot(account, logger, plugin_manager=plugin_manager)