Exemple #1
0
def planet(bot, update):
    date = datetime.date.today()
    text_at = update.message.text.split(' ')[1].capitalize()
    if text_at == 'Sun':
        const = ephem.constellation(ephem.Sun(date))
    elif text_at == 'Mercury':
        const = ephem.constellation(ephem.Mercury(date))
    elif text_at == 'Venus':
        const = ephem.constellation(ephem.Venus(date))
    elif text_at == 'Earth':
        const = 'Неизвестная планета'
    elif text_at == 'Moon':
        const = ephem.constellation(ephem.Mars(date))
    elif text_at == 'Mars':
        const = ephem.constellation(ephem.Mars(date))
    elif text_at == 'Jupiter':
        const = ephem.constellation(ephem.Jupiter(date))
    elif text_at == 'Saturn':
        const = ephem.constellation(ephem.Saturn(date))
    elif text_at == 'Uranus':
        const = ephem.constellation(ephem.Uranus(date))
    elif text_at == 'Neptune':
        const = ephem.constellation(ephem.Neptune(date))
    elif text_at == 'Pluto':
        const = ephem.constellation(ephem.Pluto(date))
    else:
        const = 'Данные не доступны'
    update.message.reply_text(const)
def show_constellation(update, context):
    text = update.message.text.lower().split()
    if len(text) != 2:
        update.message.reply_text('Неверно задана планета. Попробуйте ещё раз.')
        return
    
    currentDate = dt.date.today().strftime('%Y/%m/%d')
    planet = ephem.Planet
    if text[1] == 'mercury':
        planet = ephem.Mercury(currentDate)
    elif text[1] == 'venus':
        planet = ephem.Venus(currentDate)
    elif text[1] == 'mars':
        planet = ephem.Mars(currentDate)
    elif text[1] == 'jupiter':
        planet = ephem.Jupiter(currentDate)
    elif text[1] == 'saturn':
        planet = ephem.Saturn(currentDate)
    elif text[1] == 'uranus':
        planet = ephem.Uranus(currentDate)
    elif text[1] == 'neptune':
        planet = ephem.Neptune(currentDate)
    elif text[1] == 'pluto':
        planet = ephem.Pluto(currentDate)
    else:
        response = f'Планета введена неверно. Повторите ввод.\n Список планет: {pll.planets}'
        print(response)
        update.message.reply_text(response)
        return

    constellation = ephem.constellation(planet)
    print(constellation)
    response = f'{pll.planets_rus.get(planet.name, planet.name)} сегодня находится в созвездии {constellation[1]}.'
    update.message.reply_text(response)
def planet_constellation(bot, update):
    try:
        current_date = update.message.date
        planet = update.message.text.split()[1].lower().capitalize()

        if planet == "Sun":
            planet_object = ephem.Sun(current_date)
        elif planet == "Moon":
            planet_object = ephem.Moon(current_date)
        elif planet == "Mercury":
            planet_object = ephem.Mercury(current_date)
        elif planet == "Venus":
            planet_object = ephem.Venus(current_date)
        elif planet == "Mars":
            planet_object = ephem.Mars(current_date)
        elif planet == "Jupiter":
            planet_object = ephem.Jupiter(current_date)
        elif planet == "Saturn":
            planet_object = ephem.Saturn(current_date)
        elif planet == "Uranus":
            planet_object = ephem.Uranus(current_date)
        elif planet == "Neptune":
            planet_object = ephem.Neptune(current_date)
        elif planet == "Pluto":
            planet_object = ephem.Pluto(current_date)
        else:
            update.message.reply_text("Нет такой планеты!")

        const = ephem.constellation(planet_object)
        text = f'Планета "{planet}" находится сейчас в созвездии {const}.'
        update.message.reply_text(text)

    except IndexError:
        update.message.reply_text("Напиши название планеты после /planet!")
Exemple #4
0
def tell_constellation(bot, update, args):
    print('Вызван /planet')
    input = args[0].capitalize()
    if input == "Mars":
        planet = ephem.Mars()
    if input == "Neptune":
        planet = ephem.Neptune()
    if input == "Venus":
        planet = ephem.Venus()
    if input == "Mercury":
        planet = ephem.Mercury()
    if input == "Jupiter":
        planet = ephem.Jupiter()
    if input == "Saturn":
        planet = ephem.Saturn()
    if input == "Uranus":
        planet = ephem.Uranus()

    planet.compute()
    print(planet)
    try:
        string = ephem.constellation(planet)[1]
        bot.sendMessage(update.message.chat_id, text=string)
    except:
        bot.sendMessage(update.message.chat_id, text='Эй, это не планета!')
Exemple #5
0
def planet(bot, update):
    date = datetime.datetime.now()
    planet_name = update.message.text[7:]
    planet_name = planet_name.replace(' ', '')

    if planet_name == 'mars':
        planet = ephem.Mars(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    elif planet_name == 'jupiter':
        planet = ephem.Jupiter(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    elif planet_name == 'venus':
        planet = ephem.Venus(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    elif planet_name == 'mercury':
        planet = ephem.Mercury(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    elif planet_name == 'saturn':
        planet = ephem.Saturn(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    elif planet_name == 'uranus':
        planet = ephem.Uranus(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    elif planet_name == 'neptune':
        planet = ephem.Neptune(date)
        constellation = ephem.constellation(planet)
        update.message.reply_text(constellation)
    else:
        update.message.reply_text('Не могу найти созвездие.')
Exemple #6
0
def planetstransit(date):
    """returns SHA and meridian passage for the navigational planets
    """
    v = ephem.Venus()
    mars = ephem.Mars()
    j = ephem.Jupiter()
    sat = ephem.Saturn()
    obs = ephem.Observer()
    
    obs.date = date
    v.compute(date)
    vsha = nadeg(2*math.pi-ephem.degrees(v.g_ra).norm)
    vtrans = time(obs.next_transit(v))
    hpvenus = "%0.1f" %((math.tan(6371/(v.earth_distance*149597870.7)))*60*180/math.pi)
    
    obs.date = date
    mars.compute(date)
    marssha = nadeg(2*math.pi-ephem.degrees(mars.g_ra).norm)
    marstrans = time(obs.next_transit(mars))
    hpmars = "%0.1f" %((math.tan(6371/(mars.earth_distance*149597870.7)))*60*180/math.pi)

    obs.date = date
    j.compute(date)
    jsha = nadeg(2*math.pi-ephem.degrees(j.g_ra).norm)
    jtrans = time(obs.next_transit(j))
    
    obs.date = date
    sat.compute(date)
    satsha = nadeg(2*math.pi-ephem.degrees(sat.g_ra).norm)
    sattrans = time(obs.next_transit(sat))
    
    return [vsha,vtrans,marssha,marstrans,jsha,jtrans,satsha,sattrans,hpmars,hpvenus]
Exemple #7
0
def planet_status(bot, update):
    today_date = datetime.datetime.now().strftime('%Y/%m/%d')
    user_text = update.message.text
    logging.info('Пользователь @{} ({}) ввел: {} '.format(
        update.message.chat.username, update.message.chat.first_name,
        user_text))
    if 'Venus' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Venus(today_date))[1]))
    elif 'Mars' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Mars(today_date))[1]))
    elif 'Mercury' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Mercury(today_date))[1]))
    elif 'Earth' in user_text:
        update.message.reply_text("Ну ты в своем уме?)")
    elif 'Jupiter' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Jupiter(today_date))[1]))
    elif 'Saturn' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Saturn(today_date))[1]))
    elif 'Uranus' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Uranus(today_date))[1]))
    elif 'Neptune' in user_text:
        update.message.reply_text("Находится в созвездии {}".format(
            ephem.constellation(ephem.Neptune(today_date))[1]))
    else:
        update.message.reply_text(
            "Планеты на английском надо. Введите например /planet Venus")
Exemple #8
0
def planet_info (update, context):
    user_text = update.message.text.split()
    planet_dict = {
        "Mercury": ephem.Mercury('2000/01/01'), 
        "Venus": ephem.Venus('2000/01/01'), 
        "Mars": ephem.Mars('2000/01/01'), 
        "Jupiter": ephem.Jupiter('2000/01/01'), 
        "Saturn": ephem.Saturn('2000/01/01'), 
        "Uranus": ephem.Uranus('2000/01/01'), 
        "Neptune": ephem.Neptune('2000/01/01')
    }
    planet_names = list(planet_dict.keys())

    if len(user_text) == 2:
        word = user_text[1].capitalize()
        switcher = True
        for planet in planet_names:
            if word == planet:
                constellation = ephem.constellation(planet_dict[planet])
                update.message.reply_text(constellation)
                switcher = False
                break  
            elif word == "Earth":
                update.message.reply_text("Eath has no constellation")
                switcher = False
                break
        if switcher == True:
            update.message.reply_text("Wrong planet pls enter correct name of planet")
    else:
        update.message.reply_text("Wrong command. Pls type for example '/planet Mars'")
Exemple #9
0
def planet(bot, update, args):
    print('Command /planet was called')
    current_time = datetime.datetime.now()
    #input_planet = str(update.message.text.strip().split()[-1])
    input_planet = args[0].strip().title()
    all_planets = {
        'Pluto': ephem.Pluto(),
        'Mercury': ephem.Mercury(),
        'Venus': ephem.Venus(),
        'Mars': ephem.Mars(),
        'Jupiter': ephem.Jupiter(),
        'Saturn': ephem.Saturn(),
        'Uranus': ephem.Uranus(),
        'Neptune': ephem.Neptune()
    }
    answer = ''

    def constel_answer(planet):
        planet.compute(current_time)
        return ('Planet\'s info: %s %s %s' %
                (planet.ra, planet.dec, planet.mag),
                'The current constellation is: {}'.format(
                    ephem.constellation(planet)[1]))

    if input_planet in all_planets:
        answer = constel_answer(all_planets[input_planet])
    elif input_planet == 'Earth':
        answer = 'Earth is our planet!'
    else:
        answer = 'Please enter a planet of the Solar system next to the command /planet.'
    update.message.reply_text(answer)
Exemple #10
0
def compute_azel_from_planet(config):

    home = ephem.Observer()
    home.lon = str(config.rotor_lon)  # +E
    home.lat = str(config.rotor_lat) # +N
    home.elevation = config.rotor_alt # meters
    home.date = dt.datetime.utcnow() # +dt.timedelta(hours=21)

    if config.track_planet.lower() == 'sun':
        planet = ephem.Sun(home)
    if config.track_planet.lower() == 'moon':
        planet = ephem.Moon(home)
    if config.track_planet.lower() == 'mercury':
        planet = ephem.Mercury(home)
    if config.track_planet.lower() == 'venus':
        planet = ephem.Venus(home)
    if config.track_planet.lower() == 'mars':
        planet = ephem.Mars(home)
    if config.track_planet.lower() == 'jupiter':
        planet = ephem.Jupiter(home)
    if config.track_planet.lower() == 'saturn':
        planet = ephem.Saturn(home)
    if config.track_planet.lower() == 'uranus':
        planet = ephem.Uranus(home)
    if config.track_planet.lower() == 'neptune':
        planet = ephem.Neptune(home)
    planet.compute(home)

    return r2d(float(planet.az)), r2d(float(planet.alt))
Exemple #11
0
def where_planet(bot, update):
    planet_text = update.message.text
    print(planet_text)
    if planet_text == 'Mercury':
        planet = ephem.Mercury()
    elif planet_text == 'Venus':
        planet = ephem.Venus()
    elif planet_text == 'Mars':
        planet = ephem.Mars()
    elif planet_text == 'Jupiter':
        planet = ephem.Jupiter()
    elif planet_text == 'Saturn':
        planet = ephem.Saturn()
    elif planet_text == 'Uranus':
        planet = ephem.Uranus()
    elif planet_text == 'Neptune':
        planet = ephem.Neptune()
    elif planet_text == 'Pluto':
        planet = ephem.Pluto()
    elif planet_text == 'Sun':
        planet = ephem.Sun()
    elif planet_text == 'Moon':
        planet = ephem.Moon()
    else:
        update.message.reply_text('Я не знаю такой планеты')
        return

    planet.compute()
    update.message.reply_text(ephem.constellation(planet))
Exemple #12
0
def planet1(bot, update):
	text = 'Введите название планеты '
	print(text)
	update.message.reply_text(text)
	#bot.send_message(text)
	text = message.text
	planet_choose = update.message.text
	print ('Бля,...', planet_choose)
	#planet_choose = update.message.text
	dt1 = dt.today()
	#planet_choose = input('Выберите планету: ')
	if planet_choose.lower() == 'mercury':
		planet = ep.constellation(ep.Mercury(dt1))
	elif planet_choose.lower() =='venus':
		planet =ep.constellation(ep.Venus(dt1))
	elif planet_choose.lower() =='earth':
		planet = ep.constellation(ep.Earth(dt1))
	elif planet_choose.lower() =='mars':
		planet =ep.constellation(ep.Mars(dt1))
			#print(planet)
	elif planet_choose.lower() =='jupiter':
		planet =ep.constellation(ep.Jupiter(dt1))
	elif planet_choose.lower() =='saturn':
		planet =ep.constellation(ep.Saturn(dt1))
	elif planet_choose.lower() =='uranus':
		planet = ep.constellation(ep.Uranus(dt1))
	elif planet_choose.lower() =='neptune':
		planet = ep.constellation(ep.Neptune(dt1))
	elif planet_choose.lower() =='pluto':
		planet = ep.constellation(ep.Pluto(dt1))
	else:
		print (planet_choose)
		planet = 'Нет таких планет'
	print(planet)
	update.message.reply_text(planet)