init: Initial commit
This commit is contained in:
43
main.py
Normal file
43
main.py
Normal 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)
|
||||
Reference in New Issue
Block a user