Skip to content

Commit 0798c6a

Browse files
committed
Enhance match notification messages with updated time formatting and title inclusion
1 parent 3060bab commit 0798c6a

1 file changed

Lines changed: 17 additions & 23 deletions

File tree

scripts/real_madrid/matches_time.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -132,30 +132,32 @@
132132
matchDates[date] = {**matchDates[date], "location": location}
133133
else:
134134
print("❗ No data avalibale - Existting")
135-
136135
# If match dates:
137136
if matchDates:
138137
for date in matchDates:
139138
dateStr = str(date)
140139
dateParts = dateStr.split("، ")
141140
dateMonth = dateParts[1]
141+
matchTime = dateParts[2]
142+
matchTime = matchTime.replace(
143+
dateParts[2].split(":")[0], str((int(dateParts[2].split(":")[0]) + 1))
144+
)
142145
dateDay = int(dateMonth.split(" ")[0])
146+
147+
matchDec = matchDates[date]
148+
team1 = matchDec["team1"]
149+
team2 = matchDec["team2"]
150+
team2 = team2 if team1 == "ريال مدريد" else team1
151+
team1 = "ريال مدريد"
152+
location = matchDec["location"]
153+
title = matchDec["title"]
143154
if dateDay == datetime.now().date().day: # In case today:
144155
print(f"Founded match today: {date}")
145-
146-
matchDec = matchDates[date]
147-
team1 = matchDec["team1"]
148-
team2 = matchDec["team2"]
149-
location = matchDec["location"]
150-
if not team1 == "ريال مدريد":
151-
team1 = "ريال مدريد"
152-
team2 = team1
153-
154156
messageText = (
155-
f"<b>تذكير بمباراة اليوم - الساعة {dateParts[2]}</b>\n\n"
156-
f"<b>{team1}</b> و <b>{team2}</b> - علي ملعب {location}"
157+
f"<b>تذكير بمباراة اليوم - الساعة {matchTime}</b>\n\n"
158+
f"- <b>{team1}</b> و <b>{team2}</b> - <b>{title}</b>\n\n"
159+
f"- علي ملعب {location}"
157160
)
158-
159161
print("Send to telegram - Sending")
160162
isSuccessSend = asyncio.run(
161163
send_text_message(
@@ -171,19 +173,11 @@
171173
continue
172174
print("Telegram message sended successfully")
173175
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-
182176
messageText = (
183177
f"<b>توجد مباراة غداً - الساعة {dateParts[2]}</b>\n\n"
184-
f"<b>{team1}</b> و <b>{team2}</b> - علي ملعب {location}"
178+
f"- <b>{team1}</b> و <b>{team2}</b> - <b>{title}</b>\n\n"
179+
f"- علي ملعب {location}"
185180
)
186-
187181
print(f"Founded match tomorrow: {date}")
188182
print("Send to telegram - Sending")
189183
isSuccessSend = asyncio.run(

0 commit comments

Comments
 (0)