Merge branch 'multi' of https://github.com/Jxck-S/plane-notify into multi

This commit is contained in:
Jxck-S 2022-05-16 16:37:47 -04:00
commit cc7a584ac8
7 changed files with 52 additions and 10 deletions

View File

@ -104,6 +104,38 @@ docker-compose up -d
After running this command, due to the `-d` flag the container will be running in the background. To see the logs of the docker container use `docker logs CONTAINER` (add `-f` to continue streaming the containers output) After running this command, due to the `-d` flag the container will be running in the background. To see the logs of the docker container use `docker logs CONTAINER` (add `-f` to continue streaming the containers output)
### Telegram message feature - march/2022
Data obtained can be sent through Telegram to a chat (contact), channel or groups.
Creating a Telegram Bot
- Start a conversation with [BotFather](https://t.me/BotFather);
- Send it to the BotFather: /newbot
- Choose a name for your bot;
- Choose a username for your bot;
- Done! You'll get a token to access the HTTP API.
Getting channel or chat (contact) ID
- Start a conversation with [JsonDumpBot](https://t.me/JsonDumpBot);
- It will reply with a json with information from the message;
- Go to the channel or chat you want the id and forward a message from there to JsonDumpBot;
- Find the id in the reply. It'll look something like this:
```bash
{...
"forward_from_chat": {
"id": xxxxxxxxx,
...}
```
- Don't forget to add the bot as admin in channel so messages can be sent.
Getting a group ID
- Open [Telegram web](https://web.telegram.org);
- Go to group and check the url on address bar of browser;
- That's the group ID (-xxxxxxxxx), it'll look something like this:
```bash
https://web.telegram.org/z/#-xxxxxxxxx
```
### TODO ### TODO
- General Cleanup - General Cleanup

View File

@ -66,3 +66,7 @@
### OurAirports / airports.csv / regions.csv ### OurAirports / airports.csv / regions.csv
- <https://ourairports.com/data/> - <https://ourairports.com/data/>
### Telegram Bot
- <https://github.com/python-telegram-bot/python-telegram-bot>

View File

@ -2,7 +2,7 @@
#Source to pull data from #Source to pull data from
#SHOULD BE ADSBX which is ADS-B Exchange or OPENS which is OpenSky #SHOULD BE ADSBX which is ADS-B Exchange or OPENS which is OpenSky
#By default configured with OpenSky which anyone can use without a login #By default configured with OpenSky which anyone can use without a login
#ADS-B Exchange has better data but is not avalible unless you feed their network or pay. #ADS-B Exchange has better data but is not avalible unless you pay (see: https://www.adsbexchange.com/data/ )
SOURCE = OPENS SOURCE = OPENS
#Default amount of time after data loss to trigger a landing when under 10k ft #Default amount of time after data loss to trigger a landing when under 10k ft
DATA_LOSS_MINS = 5 DATA_LOSS_MINS = 5

View File

@ -1,5 +1,5 @@
[DATA] [DATA]
#Plane to track, based of ICAO or ICAO24 which is the unique transponder address of a plane. #Plane to track, based off ICAO or ICAO24 which is the unique transponder address of a plane.
ICAO = icaohere ICAO = icaohere
@ -51,7 +51,7 @@ ACCESS_TOKEN =
[TELEGRAM] [TELEGRAM]
ENABLE = False ENABLE = FALSE
TITLE = TITLE = Title Of Telegram message
ROOM_ID = ROOM_ID = -100xxxxxxxxxx
BOT_TOKEN = BOT_TOKEN = xxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

View File

@ -40,6 +40,12 @@ def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_trac
browser.execute_script("$('#infoblock-container').css('overflow', 'hidden');") browser.execute_script("$('#infoblock-container').css('overflow', 'hidden');")
except: except:
print("Couldn't disable sidebar on map") print("Couldn't disable sidebar on map")
#Remove Google Ads
try:
element = browser.find_element_by_xpath("//*[contains(@id, 'FIOnDemandWrapper_')]")
browser.execute_script("""var element = arguments[0]; element.parentNode.removeChild(element); """, element)
except:
print("Couldn't remove Google Ads")
#Remove share #Remove share
# try: # try:
# element = browser.find_element_by_xpath("//*[contains(text(), 'Copy Link')]") # element = browser.find_element_by_xpath("//*[contains(text(), 'Copy Link')]")

View File

@ -5,7 +5,7 @@ def sendTeleg(photo, message, config):
while sent == False: while sent == False:
try: try:
bot = telegram.Bot(token=config.get('TELEGRAM', 'BOT_TOKEN'), request=telegram.utils.request.Request(connect_timeout=20, read_timeout=20)) bot = telegram.Bot(token=config.get('TELEGRAM', 'BOT_TOKEN'), request=telegram.utils.request.Request(connect_timeout=20, read_timeout=20))
sent = bot.send_photo(chat_id=config.get('TELEGRAM', 'ROOM_ID'), photo=photo, caption=message, parse_mode=telegram.ParseMode.MARKDOWN, timeout=20, ) sent = bot.send_photo(chat_id=config.get('TELEGRAM', 'ROOM_ID'), photo=photo, caption=message, parse_mode=telegram.ParseMode.MARKDOWN, timeout=20)
except Exception as err: except Exception as err:
print('err.args:') print('err.args:')
print(err.args) print(err.args)

View File

@ -67,7 +67,7 @@ class Plane:
self.print_header("BEGIN") self.print_header("BEGIN")
#print (Fore.YELLOW + "OpenSky Sourced Data: ", ac_dict) #print (Fore.YELLOW + "OpenSky Sourced Data: ", ac_dict)
try: try:
self.__dict__.update({'icao' : ac_dict.icao24.upper(), 'callsign' : ac_dict.callsign, 'latitude' : ac_dict.latitude, 'longitude' : ac_dict.longitude, 'on_ground' : bool(ac_dict.on_ground), 'squawk' : ac_dict.squawk, 'track' : float(ac_dict.heading)}) self.__dict__.update({'icao' : ac_dict.icao24.upper(), 'callsign' : ac_dict.callsign, 'latitude' : ac_dict.latitude, 'longitude' : ac_dict.longitude, 'on_ground' : bool(ac_dict.on_ground), 'squawk' : ac_dict.squawk, 'track' : float(ac_dict.true_track)})
if ac_dict.baro_altitude != None: if ac_dict.baro_altitude != None:
self.alt_ft = round(float(ac_dict.baro_altitude) * 3.281) self.alt_ft = round(float(ac_dict.baro_altitude) * 3.281)
elif self.on_ground: elif self.on_ground:
@ -76,7 +76,7 @@ class Plane:
self.reg = get_aircraft_reg_by_icao(self.icao) self.reg = get_aircraft_reg_by_icao(self.icao)
self.type = get_type_code_by_icao(self.icao) self.type = get_type_code_by_icao(self.icao)
self.last_pos_datetime = datetime.fromtimestamp(ac_dict.time_position) self.last_pos_datetime = datetime.fromtimestamp(ac_dict.time_position)
except ValueError as e: except Exception as e:
print("Got data but some data is invalid!") print("Got data but some data is invalid!")
print(e) print(e)
self.print_header("END") self.print_header("END")
@ -858,4 +858,4 @@ class Plane:
print(time_since_ra) print(time_since_ra)
if time_since_ra.seconds >= 600: if time_since_ra.seconds >= 600:
print(ra_type) print(ra_type)
self.recent_ra_types.pop(ra_type) self.recent_ra_types.pop(ra_type)