@@ -207,11 +207,11 @@ def _notif_template(cfg: dict) -> dict:
207207 }
208208
209209
210- def _send_to_channels (title : str , body : str , channels : list [str ], cfg : dict ) -> list [str ]:
210+ def _send_to_channels (title : str , body : str , channels : list [str ], cfg : dict , thumb_url : str = "" ) -> list [str ]:
211211 """Send to specified endpoint IDs (empty = all). Returns error strings."""
212212 endpoints = cfg .get ("notification_endpoints" , [])
213213 if not endpoints :
214- return _send_to_channels_legacy (title , body , channels , cfg )
214+ return _send_to_channels_legacy (title , body , channels , cfg , thumb_url = thumb_url )
215215 targets = endpoints if not channels else [ep for ep in endpoints if ep .get ("id" ) in channels ]
216216 errors = []
217217 for ep in targets :
@@ -220,22 +220,22 @@ def _send_to_channels(title: str, body: str, channels: list[str], cfg: dict) ->
220220 t = ep .get ("type" , "" )
221221 if t == "telegram" :
222222 from notifiers .telegram import TelegramNotifier
223- TelegramNotifier (ep ["bot_token" ], str (ep ["chat_id" ])).send (title , body )
223+ TelegramNotifier (ep ["bot_token" ], str (ep ["chat_id" ])).send (title , body , thumb_url = thumb_url )
224224 elif t == "pushover" :
225225 from notifiers .pushover import PushoverNotifier
226- PushoverNotifier (ep ["app_token" ], ep ["user_key" ]).send (title , body )
226+ PushoverNotifier (ep ["app_token" ], ep ["user_key" ]).send (title , body , thumb_url = thumb_url )
227227 elif t == "ntfy" :
228228 from notifiers .ntfy import NtfyNotifier
229- NtfyNotifier (ep ["url" ], ep ["topic" ], ep .get ("token" , "" )).send (title , body )
229+ NtfyNotifier (ep ["url" ], ep ["topic" ], ep .get ("token" , "" )).send (title , body , thumb_url = thumb_url )
230230 elif t == "discord" :
231231 from notifiers .discord import DiscordNotifier
232- DiscordNotifier (ep ["webhook_url" ]).send (title , body )
232+ DiscordNotifier (ep ["webhook_url" ]).send (title , body , thumb_url = thumb_url )
233233 except Exception as exc :
234234 errors .append (f"{ ep_id } : { exc } " )
235235 return errors
236236
237237
238- def _send_to_channels_legacy (title : str , body : str , channels : list [str ], cfg : dict ) -> list [str ]:
238+ def _send_to_channels_legacy (title : str , body : str , channels : list [str ], cfg : dict , thumb_url : str = "" ) -> list [str ]:
239239 _LEGACY = [("telegram" , "Telegram" ), ("pushover" , "Pushover" ), ("ntfy" , "Ntfy" ), ("discord" , "Discord" )]
240240 n = cfg .get ("notifications" , {})
241241 all_enabled = [k for k , _ in _LEGACY if n .get (k , {}).get ("enabled" )]
@@ -246,18 +246,18 @@ def _send_to_channels_legacy(title: str, body: str, channels: list[str], cfg: di
246246 if ch == "telegram" :
247247 from notifiers .telegram import TelegramNotifier
248248 t = n ["telegram" ]
249- TelegramNotifier (t ["bot_token" ], str (t ["chat_id" ])).send (title , body )
249+ TelegramNotifier (t ["bot_token" ], str (t ["chat_id" ])).send (title , body , thumb_url = thumb_url )
250250 elif ch == "pushover" :
251251 from notifiers .pushover import PushoverNotifier
252252 p = n ["pushover" ]
253- PushoverNotifier (p ["app_token" ], p ["user_key" ]).send (title , body )
253+ PushoverNotifier (p ["app_token" ], p ["user_key" ]).send (title , body , thumb_url = thumb_url )
254254 elif ch == "ntfy" :
255255 from notifiers .ntfy import NtfyNotifier
256256 nt = n ["ntfy" ]
257- NtfyNotifier (nt ["url" ], nt ["topic" ], nt .get ("token" , "" )).send (title , body )
257+ NtfyNotifier (nt ["url" ], nt ["topic" ], nt .get ("token" , "" )).send (title , body , thumb_url = thumb_url )
258258 elif ch == "discord" :
259259 from notifiers .discord import DiscordNotifier
260- DiscordNotifier (n ["discord" ]["webhook_url" ]).send (title , body )
260+ DiscordNotifier (n ["discord" ]["webhook_url" ]).send (title , body , thumb_url = thumb_url )
261261 except Exception as exc :
262262 errors .append (f"{ ch } : { exc } " )
263263 return errors
@@ -809,11 +809,27 @@ async def preview_send(
809809
810810 cfg = load_config ()
811811 sub_channels : list [str ] = []
812+ sub_game_thumbs_league : str = ""
812813 for s in cfg .get ("subscriptions" , []):
813814 if s .get ("label" ) == sub_label :
814815 sub_channels = s .get ("notify_channels" , [])
816+ sub_game_thumbs_league = s .get ("game_thumbs_league" ) or ""
815817 break
816- errors = _send_to_channels (notif_title , notif_body , sub_channels , cfg )
818+
819+ thumb_url = ""
820+ if sub_game_thumbs_league :
821+ from game_thumbs import build_thumb_url , _extract_game_teams , _to_pascal
822+ thumbs_cfg = cfg .get ("game_thumbs" , {})
823+ if thumbs_cfg .get ("enabled" ):
824+ base_url = thumbs_cfg .get ("base_url" , "" ).rstrip ("/" )
825+ if base_url :
826+ teams = _extract_game_teams (notif_title )
827+ if teams :
828+ away = _to_pascal (teams [0 ])
829+ home = _to_pascal (teams [1 ])
830+ thumb_url = f"{ base_url } /{ sub_game_thumbs_league } /{ away } /{ home } /thumb.png?style=1&logo=true&aspect=16-9"
831+
832+ errors = _send_to_channels (notif_title , notif_body , sub_channels , cfg , thumb_url = thumb_url )
817833 if errors :
818834 return Response (status_code = 400 , headers = {"X-Toast" : f"Send failed: { errors [0 ]} " })
819835 via = ", " .join (sub_channels ) if sub_channels else "all enabled channels"
0 commit comments