l radio: add c-base weather
This commit is contained in:
parent
32966b38ae
commit
4555a8858d
@ -3,12 +3,23 @@ import fileinput
|
||||
import json
|
||||
import requests
|
||||
import os
|
||||
import random
|
||||
|
||||
|
||||
geoip = geoip2.database.Reader(os.environ['MAXMIND_GEOIP_DB'])
|
||||
seen = {}
|
||||
output = []
|
||||
for ip in fileinput.input():
|
||||
if "80.147.140.51" in ip:
|
||||
output.append(
|
||||
'Weather report for c-base, space.'
|
||||
'It is empty space outside '
|
||||
'with a temperature of -270 degrees, '
|
||||
'a lightspeed of 299792 kilometers per second '
|
||||
'and a humidity of Not a Number percent. '
|
||||
f'The probability of reincarnation is {random.randrange(0, 100)} percent.'
|
||||
)
|
||||
else:
|
||||
location = geoip.city(ip.strip())
|
||||
if location.city.geoname_id not in seen:
|
||||
seen[location.city.geoname_id] = True
|
||||
|
Loading…
Reference in New Issue
Block a user