feat: Refactored all cogs implementation
Some checks failed
CI / Run tests (pull_request) Has been cancelled

This commit is contained in:
2026-09-12 23:16:43 +02:00
parent 505621e0cd
commit c86ea54e86
10 changed files with 451 additions and 123 deletions

View File

@@ -7,6 +7,7 @@ from discord.ext import commands, tasks, bridge
from setup.logger import LOGGER
from setup.config import Config
from models.cs_models import *
from cogs import FeatureCog
BASE_URL = "https://www.hltv.org"
@@ -24,12 +25,20 @@ OLD_MATCH_DURATION = 3600 * 24 * 2
EMOJI_CREATE_EVENT = "✅" # Create guild event for the match
EMOJI_REMOVE_EVENT = "❌" # Remove guild event for the match
class CSCog(commands.Cog):
def __init__(self, bot:discord.Bot):
self.bot = bot
self.matches:list[Match] = []
class CSCog(FeatureCog):
def __init__(self, bot: discord.Bot):
super().__init__(bot, feature_name="cs")
self.matches: list[Match] = []
self.message_match_map = {} # Maps message IDs to Match objects
self.get_matches.start()
# Start scraping loop only if at least one guild enabled CS feature
try:
enabled_any = any(cfg.get("features", {}).get("cs") for cfg in Config.GUILD_CONFIGS.values())
except Exception:
enabled_any = False
if enabled_any:
self.get_matches.start()
def is_up_to_date(self) -> bool:
"""Check if PAGE_FILE and MATCHES_FILE are up to date."""