-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
45 lines (35 loc) · 1.35 KB
/
config.py
File metadata and controls
45 lines (35 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Configuration module for Facebook FAQ Bot
"""
import os
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
class Config:
"""Configuration class for bot settings"""
# Facebook credentials
FACEBOOK_PAGE_ACCESS_TOKEN = os.getenv('FACEBOOK_PAGE_ACCESS_TOKEN')
FACEBOOK_VERIFY_TOKEN = os.getenv('FACEBOOK_VERIFY_TOKEN')
APP_SECRET = os.getenv('APP_SECRET')
# Matching threshold for FAQ responses (0.0 to 1.0)
MATCH_THRESHOLD = float(os.getenv('MATCH_THRESHOLD', '0.3'))
# Flask settings
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
PORT = int(os.getenv('PORT', '5000'))
HOST = os.getenv('HOST', '0.0.0.0')
@classmethod
def validate(cls):
"""Validate that all required configuration is present"""
missing = []
if not cls.FACEBOOK_PAGE_ACCESS_TOKEN:
missing.append('FACEBOOK_PAGE_ACCESS_TOKEN')
if not cls.FACEBOOK_VERIFY_TOKEN:
missing.append('FACEBOOK_VERIFY_TOKEN')
if not cls.APP_SECRET:
missing.append('APP_SECRET')
if missing:
raise ValueError(
f"Missing required environment variables: {', '.join(missing)}\n"
"Please check your .env file or environment configuration."
)
return True