roboluke-tasks/app/main.py
Luke Tainton f611b685b3
fix(config): return None if env var is empty or non-existent (#315)
* fix(config): return None if env var is empty or non-existent
* chore: fix pylint issues
* fix: add unit test for non-existent env vars
2024-11-21 22:26:07 +00:00

49 lines
1.3 KiB
Python

"""Main module."""
import sys
import sentry_sdk
from sentry_sdk.integrations.stdlib import StdlibIntegration
from webex_bot.webex_bot import WebexBot
from app.commands.exit import ExitCommand
from app.commands.submit_task import SubmitTaskCommand
from app.utils.config import config
if config.sentry_enabled:
apm = sentry_sdk.init(
dsn=config.sentry_dsn,
enable_tracing=True,
environment=config.environment,
release=config.version,
integrations=[StdlibIntegration()],
spotlight=True,
)
def create_bot() -> WebexBot:
"""Create and return a Webex Bot object."""
webex_bot: WebexBot = WebexBot(
bot_name=config.bot_name,
teams_bot_token=config.webex_token,
approved_domains=config.approved_domains,
approved_rooms=config.approved_rooms,
approved_users=config.approved_users,
)
webex_bot.commands.clear()
webex_bot.add_command(SubmitTaskCommand())
webex_bot.add_command(ExitCommand())
webex_bot.help_command = SubmitTaskCommand()
webex_bot.help_command.delete_previous_message = True
return webex_bot
if __name__ == "__main__":
try:
bot: WebexBot = create_bot()
bot.run()
except KeyboardInterrupt:
print("Shutting down bot...")
sys.exit(0)