Skip to content

Commit 1c62833

Browse files
committed
feat: allow configuration of reporting old mods
1 parent 831a156 commit 1c62833

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

config/config.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ games:
33
bepinex: ["valheim", "valheim_server"]
44
thunderstore: "valheim"
55
nexus: "valheim"
6-
- name: "lethal_company"
7-
bepinex: ["Lethal Company"]
8-
thunderstore: "lethal-company"
6+
report_old_mods: false
7+
report_old_mods_threshold_days: 365

src/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def on_checkmods(message: Message, original_message: Message, logs: List[s
156156

157157
mods_local = parse_local(log)
158158

159-
response = compare_mods(mods_local.mods, modlist.get_online_mods(game.name))
159+
response = compare_mods(mods_local.mods, modlist.get_online_mods(game.name), game)
160160
errors = parse_errors(log)
161161

162162
time_watch = datetime.datetime.now()

src/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class GameConfig(BaseModel):
1414
thunderstore: Optional[str] = None
1515
nexus: Optional[str] = None
1616
ptb_version: Optional[str] = None
17+
report_old_mods: bool = True
18+
report_old_mods_threshold_days: int = 365
1719

1820

1921
def get_games() -> List[GameConfig]:

src/parse.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Dict, Optional
55
from packaging import version
66
from src import Mod, clean_name
7+
from src.config import GameConfig
78

89

910
class ParsedLog:
@@ -81,8 +82,8 @@ def parse_local(local_text) -> ParsedLog:
8182
return parsed_log
8283

8384

84-
def compare_mods(mods_local, mods_online: Dict[str, Mod]):
85-
time_threshold = datetime.datetime.now() - datetime.timedelta(days=30 * 12)
85+
def compare_mods(mods_local, mods_online: Dict[str, Mod], game_config: GameConfig):
86+
time_threshold = datetime.datetime.now() - datetime.timedelta(days=game_config.report_old_mods_threshold_days)
8687
result = ""
8788

8889
for mod in sorted(mods_local, key=lambda x: mods_local[x]["original_name"].lower()):
@@ -94,7 +95,7 @@ def compare_mods(mods_local, mods_online: Dict[str, Mod]):
9495
continue
9596

9697
outdated = mod_version < mods_online[mod].version
97-
old = mods_online[mod].updated < time_threshold
98+
old = game_config.report_old_mods and mods_online[mod].updated < time_threshold
9899
deprecated = mods_online[mod].deprecated
99100

100101
if outdated or old or deprecated:

0 commit comments

Comments
 (0)