2024-11-21 23:26:07 +01:00
|
|
|
"""Main module."""
|
|
|
|
|
|
|
|
import sys
|
2023-04-05 21:57:31 +02:00
|
|
|
|
2024-04-21 17:17:00 +02:00
|
|
|
from sentry_sdk.integrations.stdlib import StdlibIntegration
|
2023-04-05 21:57:31 +02:00
|
|
|
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
|
|
|
|
|
2024-04-21 17:17:00 +02:00
|
|
|
if config.sentry_enabled:
|
2024-11-24 11:05:22 +01:00
|
|
|
import sentry_sdk
|
|
|
|
|
2024-04-21 17:17:00 +02:00
|
|
|
apm = sentry_sdk.init(
|
|
|
|
dsn=config.sentry_dsn,
|
|
|
|
enable_tracing=True,
|
|
|
|
environment=config.environment,
|
2024-04-21 17:56:27 +02:00
|
|
|
release=config.version,
|
2024-04-21 17:17:00 +02:00
|
|
|
integrations=[StdlibIntegration()],
|
2024-08-30 20:38:56 +02:00
|
|
|
spotlight=True,
|
2024-04-21 17:17:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-04-05 21:57:31 +02:00
|
|
|
def create_bot() -> WebexBot:
|
2024-04-21 17:17:00 +02:00
|
|
|
"""Create and return a Webex Bot object."""
|
2023-04-05 21:57:31 +02:00
|
|
|
webex_bot: WebexBot = WebexBot(
|
|
|
|
bot_name=config.bot_name,
|
|
|
|
teams_bot_token=config.webex_token,
|
2024-08-30 20:38:56 +02:00
|
|
|
approved_domains=config.approved_domains,
|
|
|
|
approved_rooms=config.approved_rooms,
|
|
|
|
approved_users=config.approved_users,
|
2023-04-05 21:57:31 +02:00
|
|
|
)
|
|
|
|
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
|
2023-04-05 21:02:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-04-05 21:57:31 +02:00
|
|
|
try:
|
|
|
|
bot: WebexBot = create_bot()
|
|
|
|
bot.run()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("Shutting down bot...")
|
2024-11-21 23:26:07 +01:00
|
|
|
sys.exit(0)
|