|
1 | 1 | # Description |
2 | | -Implementation of Israel Home Front Command's (AKA "Pikud Ha Oref") public API, gets real-time alerts about rockets lunched from Gaza-strip into Israel's territory. |
| 2 | +Real-time rocket alert integration with Israel Home Front Command’s public API (Pikud HaOref). |
| 3 | +Because waiting for rocket sirens is so last century… 💥🚀 |
3 | 4 |
|
4 | 5 | ## About the library |
5 | | -RedAlert is a library that synchronizing with Israel Home Front Command's API to get the alerts in real-time, |
6 | | -the library interface is user-friendly and has lots of features which are described below. |
| 6 | +RedAlert is a C# library that continuously syncs with Israel Home Front Command’s live alert API to fetch rocket and other emergency alerts across Israel’s territory — not just Gaza-strip launches. |
| 7 | +It offers an easy-to-use event-driven interface with multi-language support and handy mapping capabilities to visualize affected zones. |
7 | 8 |
|
8 | 9 | ## Features |
9 | | -* Gets red alerts in real-time. |
10 | | - |
11 | | -* Fetches location data from alerts location (coordinates, city names, city zones, time to run for safe-zone) |
| 10 | +🚨 Real-time retrieval of Israel Home Front Command alerts |
12 | 11 |
|
13 | | -* Supports 4 languages: Hebrew, Arabic, Russian and English. |
| 12 | +🌍 Supports multiple launch zones, not limited to Gaza — because rockets love to surprise |
14 | 13 |
|
15 | | -* Gets the picture of Israel with markers over the alert's location with path lines. |
| 14 | +📍 Provides detailed location info (coordinates, city names, alert zones) |
16 | 15 |
|
17 | | -## Example code |
| 16 | +🌐 Localization for Hebrew, Arabic, Russian, and English |
| 17 | + |
| 18 | +🔄 Runs a lightweight background thread for continuous updates and event notifications |
| 19 | + |
| 20 | +## How to Use |
18 | 21 | ```cs |
19 | 22 | using RedAlert; |
| 23 | +using System; |
| 24 | +using System.Collections.Generic; |
20 | 25 |
|
21 | | -private static void Main() |
22 | | -{ |
23 | | - //Creating the event subscriber |
24 | | - Alerts alerts = new Alerts(); |
25 | | - alerts.OnAlertReceived += Alerts_OnAlertReceived; |
26 | | -} |
27 | | - |
28 | | -private static void Alerts_OnAlertReceived(List<AlertCityData> cities) |
| 26 | +class Program |
29 | 27 | { |
30 | | - //With every new alert, this function will executed. |
31 | | - |
32 | | - DateTime occurence = cities[0].Timestamp; |
33 | | - List<string> zones = new List<string>(); |
34 | | - List<string> descriptions = new List<string>(); |
35 | | - List<string> result = new List<string>(); |
36 | | - |
37 | | - //Sorting the cities zones |
38 | | - foreach (AlertCityData city in cities) |
| 28 | + static void Main() |
39 | 29 | { |
40 | | - if (!zones.Contains(city.Zone_he)) |
41 | | - zones.Add(city.Zone_he); |
| 30 | + var alerts = new Alerts(); |
| 31 | + alerts.OnAlertReceived += Alerts_OnAlertReceived; |
| 32 | + |
| 33 | + Console.WriteLine("Listening for alerts... Stay safe out there! 🚦"); |
| 34 | + Console.ReadKey(); |
42 | 35 | } |
43 | 36 |
|
44 | | - //Sorting all the alerts, every alert into his zone. |
45 | | - for (int i = 0; i < zones.Count; ++i) |
| 37 | + private static void Alerts_OnAlertReceived(List<AlertCityData> cities) |
46 | 38 | { |
47 | | - descriptions.Add(""); |
48 | | - foreach (AlertCityData city in cities) |
49 | | - { |
50 | | - if (city.Zone_he != zones[i]) |
51 | | - continue; |
| 39 | + if (cities == null || cities.Count == 0) return; |
| 40 | + |
| 41 | + DateTime alertTime = cities[0].Timestamp; |
| 42 | + var zones = new List<string>(); |
| 43 | + var descriptions = new List<string>(); |
| 44 | + var results = new List<string>(); |
| 45 | + |
| 46 | + foreach (var city in cities) |
| 47 | + if (!zones.Contains(city.Zone_he)) |
| 48 | + zones.Add(city.Zone_he); |
52 | 49 |
|
53 | | - descriptions[i] += $"{city.Name_he} - ({city.Time_he})\n"; |
| 50 | + for (int i = 0; i < zones.Count; i++) |
| 51 | + { |
| 52 | + descriptions.Add(""); |
| 53 | + foreach (var city in cities) |
| 54 | + if (city.Zone_he == zones[i]) |
| 55 | + descriptions[i] += $"{city.Name_he} - ({city.Time_he})\n"; |
54 | 56 | } |
55 | | - } |
56 | 57 |
|
57 | | - //Adding the results into a list for easier use. |
58 | | - for (int i = 0; i < zones.Count; ++i) |
59 | | - result.Add($"{zones[i]}\n\n{descriptions[i]}"); |
| 58 | + for (int i = 0; i < zones.Count; i++) |
| 59 | + results.Add($"{zones[i]}\n\n{descriptions[i]}"); |
60 | 60 |
|
61 | | - //Printing the alerts with their information |
62 | | - Console.WriteLine($"New Alert! [{occurence.ToShortDateString()}] {occurence.ToShortTimeString()}:\n" + string.Join("\n\n", result)); |
| 61 | + Console.WriteLine($"🔥 New Alert! [{alertTime.ToShortDateString()} {alertTime.ToShortTimeString()}]:\n" + |
| 62 | + string.Join("\n\n", results)); |
| 63 | + } |
63 | 64 | } |
64 | 65 | ``` |
65 | 66 | ## Information |
66 | | -1) This library will only work for people whose locations is in Israel because Israel Home Front Command (Pikud Ha Oref) accepts only the requests from Israel.<br> |
67 | | -2) The enemy cannot exploit or use this library for bad usage because it does not contain any private sensitive information, we use the public API of Israel Home Front Command (Pikud Ha Oref) <br> |
68 | | -3) This library is very simple to use and have very good performance |
| 67 | +🧠 Performance optimized: Light background polling thread keeps your CPU chill while staying alert-ready. |
| 68 | + |
| 69 | +🤖 AI-free zone: Because sometimes the best algorithms are just good ol’ C# and coffee ☕. |
69 | 70 |
|
70 | 71 | ## Dependencies |
71 | 72 | [Newtonsoft.Json 13.0.1](https://www.nuget.org/packages/Newtonsoft.Json/)<br><br>Installation:<br> |
72 | 73 | ```Install-Package Newtonsoft.Json -Version 13.0.1``` |
73 | 74 |
|
74 | 75 | ## This project is under Berkeley Software Distribution (BSD) license. |
75 | | -* The source code doesn’t need to be public when a distribution of the software is made. |
76 | | -* Modifications to the software can be released under any license. |
77 | | -* Changes made to the source code may not be documented. |
78 | | -* It offers no explicit position on patent usage. |
79 | | -* The license and copyright notice must be included in the documentation of the compiled version of the source code (as opposed to only in the source code). |
80 | | -* The BSD 3-clause states that the names of the author and contributors can’t be used to promote products derived from the software without permission. |
81 | | - |
82 | | -## Educational Purposes |
83 | | -"Copyright Disclaimer Under Section 107 of the Copyright Act 1976, allowance is made for "fair use" for purposes such as criticism, comment, news reporting, teaching scholarship, and research. Fair use is a use permitted by copyright statutes that might otherwise be infringing. Non-profit, educational, or personal use tips the balance in favor of fair use." |
| 76 | + Use, modify, and distribute freely (including commercial use) |
| 77 | + |
| 78 | + No obligation to open-source your modifications |
| 79 | + |
| 80 | + Don’t use authors’ names to promote derived products without permission |
| 81 | + |
| 82 | + Must include license and copyright notices in distributions |
| 83 | + |
| 84 | +Disclaimer |
| 85 | +"Fair use is real — this project is for education, safety, and curiosity. No rockets were harmed in making this code." |
0 commit comments