Linting
All checks were successful
Lint / lint (pull_request) Successful in 6s

This commit is contained in:
Logan Cusano
2025-06-29 15:53:15 -04:00
parent fb9f8a680f
commit ddfa9fc2a3
4 changed files with 16 additions and 17 deletions

View File

@@ -75,10 +75,10 @@ class DiscordBotManager:
LOGGER.info("Bot is ready, start_bot returning.") LOGGER.info("Bot is ready, start_bot returning.")
return return
except asyncio.TimeoutError: except asyncio.TimeoutError:
LOGGER.error("Timeout waiting for bot to become ready. Bot might have failed to start.") LOGGER.error("Timeout waiting for bot to become ready. Bot might have failed to start.")
if self.bot_task and not self.bot_task.done(): if self.bot_task and not self.bot_task.done():
self.bot_task.cancel() self.bot_task.cancel()
raise RuntimeError("Bot failed to become ready within timeout.") raise RuntimeError("Bot failed to become ready within timeout.")
async def stop_bot(self): async def stop_bot(self):
async with self.lock: async with self.lock:
@@ -130,8 +130,8 @@ class DiscordBotManager:
LOGGER.info("Bot joined voice, returning.") LOGGER.info("Bot joined voice, returning.")
return return
except asyncio.TimeoutError: except asyncio.TimeoutError:
LOGGER.error("Timeout waiting for bot to join voice.") LOGGER.error("Timeout waiting for bot to join voice.")
raise RuntimeError("Bot failed to join voice within timeout.") raise RuntimeError("Bot failed to join voice within timeout.")
async def leave_voice_channel(self, guild_id: int): async def leave_voice_channel(self, guild_id: int):
if not self.bot: if not self.bot:

View File

@@ -1,6 +1,6 @@
import csv import csv
import json import json
from models import ConfigGenerator, DecodeMode, ChannelConfig, DeviceConfig, TrunkingConfig, TrunkingChannelConfig, AudioConfig, TerminalConfig, TalkgroupTag from models import TalkgroupTag
from typing import List from typing import List
from internal.logger import create_logger from internal.logger import create_logger
@@ -67,4 +67,4 @@ def get_current_system_from_config() -> str:
first_channel = data["channels"][0] first_channel = data["channels"][0]
if "name" in first_channel: if "name" in first_channel:
return first_channel["name"] return first_channel["name"]
return None return None

View File

@@ -5,7 +5,8 @@ from internal.logger import create_logger
LOGGER = create_logger(__name__) LOGGER = create_logger(__name__)
def create_bot_router(bot_manager: DiscordBotManager): # Function to create router # Function to create router
def create_bot_router(bot_manager: DiscordBotManager):
router = APIRouter() router = APIRouter()
# API Endpoints # API Endpoints
@@ -53,5 +54,5 @@ def create_bot_router(bot_manager: DiscordBotManager): # Function to create rout
"active_token": bot_manager.token "active_token": bot_manager.token
} }
return status return status
return router # Return the configured router return router

View File

@@ -3,10 +3,9 @@ import subprocess
import os import os
import signal import signal
import json import json
from models import ConfigGenerator, DecodeMode, ChannelConfig, DeviceConfig, TrunkingConfig, TrunkingChannelConfig, AudioConfig, TerminalConfig, TalkgroupTag from models import ConfigGenerator, DecodeMode, ChannelConfig, DeviceConfig, TrunkingConfig, TrunkingChannelConfig, AudioConfig, TerminalConfig
from internal.logger import create_logger from internal.logger import create_logger
from internal.bot_manager import DiscordBotManager from internal.bot_manager import DiscordBotManager
from typing import List
from internal.op25_config_utls import save_talkgroup_tags, save_whitelist, del_none_in_dict, get_current_system_from_config from internal.op25_config_utls import save_talkgroup_tags, save_whitelist, del_none_in_dict, get_current_system_from_config
LOGGER = create_logger(__name__) LOGGER = create_logger(__name__)
@@ -119,10 +118,9 @@ def create_op25_router(bot_manager: DiscordBotManager):
async def update_prensece(): async def update_prensece():
current_system = get_current_system_from_config() current_system = get_current_system_from_config()
if not current_system: if not current_system:
raise HTTPException(status_code=500, detail="Unable to get current system.") raise HTTPException(status_code=500, detail="Unable to get current system.")
await bot_manager.set_presence(current_system) await bot_manager.set_presence(current_system)
return current_system return current_system
return router
return router