ignore unusual entries
This commit is contained in:
9
main.py
9
main.py
@@ -74,6 +74,10 @@ def send_message(text):
|
|||||||
print(f"❌ Failed to send message: {response.text}")
|
print(f"❌ Failed to send message: {response.text}")
|
||||||
|
|
||||||
|
|
||||||
|
def is_entries_valid(entries: list) -> bool:
|
||||||
|
return 0 < len(entries) < 10
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
previous_data = load_blackouts()
|
previous_data = load_blackouts()
|
||||||
updated_data = previous_data.copy()
|
updated_data = previous_data.copy()
|
||||||
@@ -84,6 +88,11 @@ def main() -> None:
|
|||||||
|
|
||||||
new_entries = [entry for entry in new_blackouts if entry not in old_blackouts]
|
new_entries = [entry for entry in new_blackouts if entry not in old_blackouts]
|
||||||
|
|
||||||
|
if not is_entries_valid(new_entries):
|
||||||
|
print('unusual entries was received. count:', len(new_entries))
|
||||||
|
print(json.dumps(new_entries, ensure_ascii=False, indent=2))
|
||||||
|
continue
|
||||||
|
|
||||||
for entry in new_entries:
|
for entry in new_entries:
|
||||||
message = format_message(bill_id, entry)
|
message = format_message(bill_id, entry)
|
||||||
send_message(message)
|
send_message(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user