Skip to content

Commit cef8fd9

Browse files
committed
Enhance match notification logic for Real Madrid; add tomorrow's match reminder and update message formatting
1 parent 349d309 commit cef8fd9

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

scripts/real_madrid/matches_time.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
dateParts = dateStr.split("، ")
141141
dateMonth = dateParts[1]
142142
dateDay = int(dateMonth.split(" ")[0])
143-
if datetime.now().date().day == dateDay:
143+
if dateDay == datetime.now().date().day: # In case today:
144144
print(f"Founded match today: {date}")
145145

146146
matchDec = matchDates[date]
@@ -152,7 +152,7 @@
152152
team2 = team1
153153

154154
messageText = (
155-
f"<b>مباراة اليوم - الساعة {dateParts[2]}</b>\n\n"
155+
f"<b>تذكير بمباراة اليوم - الساعة {dateParts[2]}</b>\n\n"
156156
f"<b>{team1}</b> و <b>{team2}</b> - علي ملعب {location}"
157157
)
158158

@@ -170,7 +170,37 @@
170170
print("Faild to send telegram message - Continue")
171171
continue
172172
print("Telegram message sended successfully")
173-
print("✅ Work ended successfully - Exitting...")
173+
elif (dateDay - datetime.now().date().day) == 0: # In case tomorrow:
174+
matchDec = matchDates[date]
175+
team1 = matchDec["team1"]
176+
team2 = matchDec["team2"]
177+
location = matchDec["location"]
178+
if not team1 == "ريال مدريد":
179+
team1 = "ريال مدريد"
180+
team2 = team1
181+
182+
messageText = (
183+
f"<b>توجد مباراة غداً - الساعة {dateParts[2]}</b>\n\n"
184+
f"<b>{team1}</b> و <b>{team2}</b> - علي ملعب {location}"
185+
)
186+
187+
print(f"Founded match tomorrow: {date}")
188+
print("Send to telegram - Sending")
189+
isSuccessSend = asyncio.run(
190+
send_text_message(
191+
token=TELEGRAM_TOKEN_REAL_MADRID,
192+
chat_id=TELEGRAM_CHAT_ID,
193+
text=messageText,
194+
source_url=MATCHES_URL,
195+
buttonText="الموقع الرسمي لريال مدريد",
196+
)
197+
)
198+
if not isSuccessSend:
199+
print("Faild to send telegram message - Continue")
200+
continue
201+
print("Telegram message sended successfully")
202+
203+
print("\n✅ Work ended successfully - Exitting...")
174204
else:
175205
print("❗ No data avalibale - Existting")
176206
else:

0 commit comments

Comments
 (0)