Files
taro-bot-teams/main.py
Björn Benouarets 7055272793 init: Initial commit
2026-01-07 06:20:16 +01:00

43 lines
1.1 KiB
Python

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)