Skip to content

Commit

Permalink
config: set default values for some of the fields
Browse files Browse the repository at this point in the history
Resolves #59
  • Loading branch information
furkansimsekli committed Mar 18, 2024
1 parent 14fb5da commit 8e7971a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
17 changes: 8 additions & 9 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ def validate():
exit(2)

if config.ADMIN_ID == 0:
print("WARNING: You didn't configured an ADMIN_ID, so you won't be able to use admin commands!")

if config.FEEDBACK_CHAT_ID == 0:
print("ERROR: Please configure FEEDBACK_CHAT_ID")
print("ERROR: Please configure ADMIN_ID")
exit(2)

if config.LOGGER_CHAT_ID == 0:
print("ERROR: Please configure LOGGER_CHAT_ID")
exit(2)
if config.FEEDBACK_CHAT_ID == config.ADMIN_ID:
print("WARNING: FEEDBACK_CHAT_ID and ADMIN_ID are same")

if config.LOGGER_CHAT_ID == config.ADMIN_ID:
print("WARNING: LOGGER_CHAT_ID and ADMIN_ID are same")

if config.ANNOUNCEMENT_CHECK_INTERVAL == 0:
print("ERROR: Please configure ANNOUNCEMENT_CHECK_INTERVAL")
if config.ANNOUNCEMENT_CHECK_INTERVAL <= 0:
print("ERROR: Please configure ANNOUNCEMENT_CHECK_INTERVAL greater than 0")
exit(2)

if config.WEBHOOK_CONNECTED:
Expand Down
28 changes: 14 additions & 14 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@
DB_STRING: str = config["DB_STRING"]
DB_NAME: str = config["DB_NAME"]

# Feedback Chat ID
FEEDBACK_CHAT_ID: int = config["FEEDBACK_CHAT_ID"]

# Admin Chat ID
ADMIN_ID: int = config["ADMIN_ID"]

# Feedback Chat ID
FEEDBACK_CHAT_ID: int = config.get("FEEDBACK_CHAT_ID", ADMIN_ID)

# Logger Chat ID
LOGGER_CHAT_ID: int = config["LOGGER_CHAT_ID"]
LOGGER_CHAT_ID: int = config.get("LOGGER_CHAT_ID", ADMIN_ID)

# Default Department List
DEFAULT_DEPS: list[str] = config["DEFAULT_DEPS"]
DEFAULT_DEPS: list[str] = config.get("DEFAULT_DEPS", [])

# Time Configurations for the Announcement Checking Task (in seconds)
ANNOUNCEMENT_CHECK_INTERVAL: int = config["ANNOUNCEMENT_CHECK_INTERVAL"]
ANNOUNCEMENT_CHECK_FIRST: int = config["ANNOUNCEMENT_CHECK_FIRST"]
ANNOUNCEMENT_CHECK_INTERVAL: int = config.get("ANNOUNCEMENT_CHECK_INTERVAL", 1800)
ANNOUNCEMENT_CHECK_FIRST: int = config.get("ANNOUNCEMENT_CHECK_FIRST", 5)

# Polling or Webhook?
WEBHOOK_CONNECTED: bool = config["WEBHOOK_CONNECTED"]
PORT: str = config["PORT"]
WEBHOOK_URL: str = config["WEBHOOK_URL"]
WEBHOOK_CONNECTED: bool = config.get("WEBHOOK_CONNECTED", False)
PORT: str = config.get("PORT", "31415")
WEBHOOK_URL: str = config.get("WEBHOOK_URL", "")

# Conversation timeout values
FEEDBACK_TIMEOUT: int = config["FEEDBACK_TIMEOUT"]
ADMIN_ANNOUNCEMENT_TIMEOUT: int = config["ADMIN_ANNOUNCEMENT_TIMEOUT"]
ADD_TIMEOUT: int = config["ADD_TIMEOUT"]
REMOVE_TIMEOUT: int = config["REMOVE_TIMEOUT"]
FEEDBACK_TIMEOUT: int = config.get("FEEDBACK_TIMEOUT", 300)
ADMIN_ANNOUNCEMENT_TIMEOUT: int = config.get("ADMIN_ANNOUNCEMENT_TIMEOUT", 300)
ADD_TIMEOUT: int = config.get("ADD_TIMEOUT", 60)
REMOVE_TIMEOUT: int = config.get("REMOVE_TIMEOUT", 60)

0 comments on commit 8e7971a

Please sign in to comment.