|
@@ -13,7 +13,6 @@ import toml
|
|
|
from rollbot import RollbotConfig, Rollbot, RollbotMessage, RollbotPlugin
|
|
|
|
|
|
import plugins
|
|
|
-import db
|
|
|
|
|
|
# Configure loggers
|
|
|
dictConfig({
|
|
@@ -39,7 +38,6 @@ with open(os.path.join(config_dir, "config.toml")) as infile:
|
|
|
with open(os.path.join(config_dir, "secrets.toml")) as infile:
|
|
|
raw_secrets = toml.load(infile)
|
|
|
|
|
|
-db_file = os.path.abspath(raw_config["database"])
|
|
|
auths = raw_secrets["auths"]
|
|
|
global_admins = auths["global"]
|
|
|
group_admins = auths["group"]
|
|
@@ -79,15 +77,10 @@ def post_groupme_message(msg, group_id):
|
|
|
app.log_exception(h)
|
|
|
|
|
|
|
|
|
-# Init db
|
|
|
-app.logger.info("Initializing database tables")
|
|
|
-session_factory = db.init_db(db_file)
|
|
|
-app.logger.info("Finished initializing database")
|
|
|
-
|
|
|
# Create bot
|
|
|
config = RollbotConfig(
|
|
|
plugins=RollbotPlugin.find_all_plugins(),
|
|
|
- session_factory=session_factory,
|
|
|
+ db_url="sqlite:///" + os.path.abspath(raw_config["database"]),
|
|
|
reply_callback=post_groupme_message,
|
|
|
aliases=raw_config.get("aliases", []),
|
|
|
responses=raw_config.get("responses", []),
|
|
@@ -99,6 +92,11 @@ config = RollbotConfig(
|
|
|
)
|
|
|
rollbot = Rollbot(config, logger=app.logger)
|
|
|
|
|
|
+# Init db
|
|
|
+app.logger.info("Initializing database tables")
|
|
|
+rollbot.init_db()
|
|
|
+app.logger.info("Finished initializing database")
|
|
|
+
|
|
|
# Setup plugins
|
|
|
rollbot.start_plugins()
|
|
|
atexit.register(rollbot.shutdown_plugins)
|