init: Initial commit

This commit is contained in:
Björn Benouarets
2026-01-07 06:20:16 +01:00
commit 7055272793
25 changed files with 1494 additions and 0 deletions

43
main.py Normal file
View File

@@ -0,0 +1,43 @@
from botbuilder.core.integration import aiohttp_error_middleware
from botbuilder.integration.aiohttp import CloudAdapter, ConfigurationBotFrameworkAuthentication
from aiohttp import web
from aiohttp.web import Application
from bot import WebhookBot
from handler import BotHandler
from config import DefaultConfig
from modules.database import DatabaseManager
from dotenv import load_dotenv
load_dotenv()
CONFIG = DefaultConfig()
DATABASE = DatabaseManager(
db_name=CONFIG.DB_NAME,
db_host=CONFIG.DB_HOST,
db_port=CONFIG.DB_PORT,
db_user=CONFIG.DB_USER,
db_password=CONFIG.DB_PASSWORD
)
ADAPTER = CloudAdapter(ConfigurationBotFrameworkAuthentication(CONFIG))
# Register error handler
async def on_error(context, error):
print(f"[Adapter] Error occurred: {error}")
import traceback
traceback.print_exc()
await context.send_activity("An error occurred processing your request.")
ADAPTER.on_turn_error = on_error
BOT = WebhookBot(CONFIG, DATABASE)
BOT_HANDLER = BotHandler(ADAPTER, BOT, CONFIG)
APP = Application()
APP.router.add_post("/api/messages", BOT_HANDLER.messages)
web.run_app(APP, host=CONFIG.HOST, port=CONFIG.PORT)