示例#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 planet_coor(update, context):

    if update.message.text == "/Mercury":
        date = datetime.date.today()
        coordinates_planet = ephem.Mars(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Venus":
        date = datetime.date.today()
        coordinates_planet = ephem.Venus(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Earth":
        date = datetime.date.today()
        coordinates_planet = ephem.Earth(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Mars":
        date = datetime.date.today()
        coordinates_planet = ephem.Mars(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Jupiter":
        date = datetime.date.today()
        coordinates_planet = ephem.Jupiter(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Saturn":
        date = datetime.date.today()
        coordinates_planet = ephem.Saturn(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Uranus":
        date = datetime.date.today()
        coordinates_planet = ephem.Uranus(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    elif update.message.text == "/Neptune":
        date = datetime.date.today()
        coordinates_planet = ephem.Neptune(f'{date}')
        constellation = ephem.constellation(coordinates_planet)
        update.message.reply_text(constellation)
        update.message.reply_text(coordinates_planet)
    else:
        update.message.reply_text("Я не знаю такой планеты")
示例#3
0
def space(bot, update):
    date = datetime.datetime.now()
    #logging.info(user_text)
    #update.message.reply_text('Введите планету  ')
    planeta = update.message.text
    print(planeta)
    print(len(planeta))
    print(planeta[9:])
    planeta = planeta[9:]
    print('Итог ', planeta)
    #update.message.reply_text('Введите дату согласно формату ГГГГ/ММ/ДД ')
    #date=update.message.text

    #planeta=input('Введите планету  ')
    #date=input('Введите дату согласно формату ГГГГ/ММ/ДД ')
    #reply_to_user= update.message.text
    if planeta == 'Mars':
        mars = ephem.Mars(date)
        reply_to_user = ephem.constellation(mars)

    elif planeta == 'Mercury':
        mercury = ephem.Mercury(date)
        reply_to_user = ephem.constellation(mercury)

    elif planeta == 'Venus':
        venus = ephem.Venus(date)
        reply_to_user = ephem.constellation(venus)

    elif planeta == 'Jupiter':
        jupiter = ephem.Jupiter(date)
        reply_to_user = ephem.constellation(jupiter)

    elif planeta == 'Saturn':
        saturn = ephem.Saturn(date)
        reply_to_user = ephem.constellation(saturn)

    elif planeta == 'Uranus':
        uranus = ephem.Mars(date)
        reply_to_user = ephem.constellation(uranus)

    elif planeta == 'Neptune':
        neptune = ephem.Neptune(date)
        reply_to_user = ephem.constellation(neptune)

    elif planeta == 'Pluto':
        pluto = ephem.Pluto(date)
        reply_to_user = ephem.constellation(pluto)

    #update.message.reply_text(user_text)

    update.message.reply_text(reply_to_user)
示例#4
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('Не могу найти созвездие.')
示例#5
0
def print_table():
    """Super quickie hack to print out a table for the current opposition.
       Unrelated to any of the other code in this script.
       Ought to be generalized to take start and stop times, etc.
    """
    start_date = ephem.Date(datetime.now()) - ephem.hour * 24 * 10
    end_date = start_date + ephem.hour * 24 * 40
    opp_date, closest_date = find_next_opposition(start_date)
    print("Opposition:", opp_date)
    print("Closest approach:", closest_date)

    # Define "opposition season"
    d = opp_date - ephem.hour * 24 * 15
    end_date = opp_date + ephem.hour * 24 * 20

    mars = ephem.Mars()
    print(table_header)
    while d < start_date + 60:
        mars.compute(d)
        d += ephem.hour * 24
        if abs(d - opp_date) <= .5:
            print(
                table_format % (ephem.Date(d), mars.earth_distance, mars.size),
                "** OPPOSITION")
        elif abs(d - closest_date) <= .5:
            print(
                table_format % (ephem.Date(d), mars.earth_distance, mars.size),
                "** CLOSEST APPROACH")
        else:
            print(table_format %
                  (ephem.Date(d), mars.earth_distance, mars.size))
示例#6
0
def search_planet(bot, update):

    planet = update.message.text.split()[-1]
    now_date = time.strftime('%Y/%m/%d')
    print(planet, now_date)
    if planet == 'Mercury':
        ep_planet = ephem.Mercury(now_date)
    elif planet == 'Venus':
        ep_planet = ephem.Venus(now_date)
    elif planet == 'Mars':
        ep_planet = ephem.Mars(now_date)
    elif planet == 'Jupiter':
        ep_planet = ephem.Jupiter(now_date)
    elif planet == 'Saturn':
        ep_planet = ephem.Saturn(now_date)
    elif planet == 'Uranus':
        ep_planet = ephem.Uranus(now_date)
    elif planet == 'Neptune':
        ep_planet = ephem.Neptune(now_date)
    else:
        print('Ввод неверный')
    const = ephem.constellation(ep_planet)
    print(const)
    user_text_const = f'Планета {planet} сегодня находится в созвездии {const}'
    print(user_text_const)
    update.message.reply_text(user_text_const)
示例#7
0
def constellation_planet (bot,update):
  platent_u = "/planet Mars"
  planet = platent_u.split()[1].capitalize()

  if planet=="Mars":
    search_planet = ephem.Mars('2020/05/26')
    ephem.constellation(search_planet)
示例#8
0
def planet(bot, update):
    print('planet')
    user_text = update.message.text.split()
    print(user_text)
    update.message.reply_text(user_text[1])
    user_text[1] = user_text[1].lower()

    if user_text[1] == 'mercury':
        m = ephem.Mercury(datetime.datetime.now())

    elif user_text[1] == 'venus':
        m = ephem.Venus(datetime.datetime.now())

    elif user_text[1] == 'mars':
        m = ephem.Mars(datetime.datetime.now())

    elif user_text[1] == 'jupiter':
        m = ephem.Jupiter(datetime.datetime.now())

    elif user_text[1] == 'saturn':
        m = ephem.Saturn(datetime.datetime.now())

    elif user_text[1] == 'uranus':
        m = ephem.Uranus(datetime.datetime.now())

    elif user_text[1] == 'neptune':
        m = ephem.Neptune(datetime.datetime.now())

    print(ephem.constellation(m))
    update.message.reply_text(ephem.constellation(m))
示例#9
0
def talk_to_me(update, context):

    text = update.message.text
    planet_name = text.split()[-1]

    if planet_name == 'Mars':
        mars = ephem.Mars()
        mars.compute(ephem.Date(datetime.date.today()))
        result = ephem.constellation(mars)
        update.message.reply_text(result)

    if planet_name == 'Jupiter':
        jupiter = ephem.Jupiter()
        jupiter.compute(ephem.Date(datetime.date.today()))
        result = ephem.constellation(jupiter)
        update.message.reply_text(result)

    if planet_name == 'Mercury':
        mercury = ephem.Mercury()
        mercury.compute(ephem.Date(datetime.date.today()))
        result = ephem.constellation(mercury)
        update.message.reply_text(result)

    else:
        print(text)
        update.message.reply_text(text)
示例#10
0
def ask_planet(
    update, context
):  # функция которая должна отвечать пользователю если он ввел название планеты
    user_text = update.message.text  # получаем от пользователя сообщение
    user_text = user_text.split(' ')  # делаем список из сообщения пользователя

    if user_text[0] == "\planet":  #Перебираем планеты
        date = datetime.datetime(now)  # обозначили что нужна сегодняшняя дата
        if user_text == 'Mars':  # если тест от пользователя приравнен к слову Mars
            mars = ephem.Mars(
                date
            )  # то в переменную mars кладется расположение планеты сегодня
            update.message.reply_text(ephem.constellation(
                mars))  # выводится сообщение пользователю о созвездии
        if user_text == 'Venus':
            venus = ephem.Venus(date)
            update.message.reply_text(ephem.constellation(venus))
        if user_text == 'Mercury':
            mercury = ephem.Mercury(date)
            update.message.reply_text(ephem.constellation(mercury))
        if user_text == 'Jupiter':
            jupiter = ephem.Jupiter(date)
            update.message.reply_text(ephem.constellation(jupiter))
        if user_text == 'Saturn':
            saturn = ephem.Saturn(date)
            update.message.reply_text(ephem.constellation(saturn))
        if user_text == 'Uranus':
            uranus = ephem.Uranus(date)
            update.message.reply_text(ephem.constellation(uranus))
        if user_text == 'Neptune':
            neptune = ephem.Neptune(date)
            update.message.reply_text(ephem.constellation(neptune))
        if user_text == 'Pluto':
            pluto = ephem.Pluto(date)
            update.message.reply_text(ephem.constellation(pluto))
示例#11
0
def get_planet(
        update, context
):  #функция показывает в каком созвездии планета с командой /planet
    date_user = '******'  #input('Введите дату в формате год/месяц/день: ')

    if context.args[0] == 'mars':
        planetname = ephem.Mars(date_user)
    elif context.args[0] == 'venus':
        planetname = ephem.Venus(date_user)
    elif context.args[0] == 'jupiter':
        planetname = ephem.Jupiter(date_user)
    elif context.args[0] == 'earth':
        planetname = ephem.Earth(date_user)
    elif context.args[0] == 'moon':
        planetname = ephem.Moon(date_user)
    elif context.args[0] == 'sun':
        planetname = ephem.Sun(date_user)
    elif context.args[0] == 'uranus':
        planetname = ephem.Uranus(date_user)
    elif context.args[0] == 'pluto':
        planetname = ephem.Pluto(date_user)
    else:
        update.message.reply_text('ошибочка вышла')
        return

    constel_planet = ephem.constellation(planetname)
    update.message.reply_text(
        f'{date_user} Планета {context.args[0].upper()} в созвездии {constel_planet[-1]}'
    )
示例#12
0
def planet_dialogue(update, context):
    date_now = datetime.date.today().strftime("%y/%m/%d")
    planet_for_search = ephem.Planet
    planet_name = update.message.text.split('/planet')[1].lower().strip()
    # Search planet in planet list
    if planet_name == 'mercury':
        planet_for_search = ephem.Mercury()
    elif planet_name == 'venus':
        planet_for_search = ephem.Venus()
    elif planet_name == 'earth':
        update.message.reply_text(
            'We are on Earth, from our point of view, we are not in a constellation'
        )
        return
    elif planet_name == 'mars':
        planet_for_search = ephem.Mars()
    elif planet_name == 'jupiter':
        planet_for_search = ephem.Jupiter()
    elif planet_name == 'saturn':
        planet_for_search = ephem.Saturn()
    elif planet_name == 'uranus':
        planet_for_search = ephem.Uranus()
    elif planet_name == 'neptune':
        planet_for_search = ephem.Neptune()
    else:
        update.message.reply_text('Planet not found')
        return
    # calculate actual constellation fot planet
    planet_for_search.compute(date_now)
    constellation_text = ', '.join(ephem.constellation(planet_for_search))
    update.message.reply_text(
        f'This planet is now in constellations {constellation_text}')
示例#13
0
def constellation_of_planet (bot,update):
    user_text = update.message.text.replace('/planet ','').capitalize()
    today_date = datetime.datetime.today().strftime('%Y/%m/%d')
    if user_text=='Mars':
        today_location_of_planet=ephem.Mars(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))
    elif user_text=='Mercury':
        today_location_of_planet=ephem.Mercury(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))
    elif user_text=='Venus':
        today_location_of_planet=ephem.Venus(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))
    elif user_text=='Jupiter':    
        today_location_of_planet=ephem.Jupiter(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))
    elif user_text=='Saturn':    
        today_location_of_planet=ephem.Saturn(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))
    elif user_text=='Uranus':    
        today_location_of_planet=ephem.Uranus(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))
    elif user_text=='Neptune':    
        today_location_of_planet=ephem.Neptune(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet)) 
    elif user_text=='Pluto':    
        today_location_of_planet=ephem.Pluto(datetime.date.today())
        update.message.reply_text(ephem.constellation(today_location_of_planet))              
    else:
        update.message.reply_text('Ошибка! Введите название планеты на английском.')
示例#14
0
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!")
示例#15
0
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)
示例#16
0
def get_constellation(update, context):
    print('Вызвана планета/start')
    planet_name = update.message.text.split(
    )[-1]  #сплит разделит текст от user по пробелу на отдельный словарь и добавили последний элемент из списка
    planets = {
        'Mercury': ephem.Mercury('2020/12/05'),
        'Venus': ephem.Venus('2020/12/05'),
        'Mars': ephem.Mars('2020/12/05'),
        'Jupiter': ephem.Jupiter('2020/12/05'),
        'Saturn': ephem.Saturn('2020/12/05'),
        'Uranus': ephem.Uranus('2020/12/05'),
        'Neptune': ephem.Neptune('2020/12/05'),
        'Pluto': ephem.Pluto('2020/12/05')
    }
    # Создан словарь планет с указанной датой - ключем
    if planet_name in planets:
        planet = planets[planet_name]
        constellation = ephem.constellation(planet)
        update.message.reply_text(
            constellation
        )  # мы скопировали из функции talk to me ответ полученный в консоли и перенаправляем в ответ на телеграмм
    else:
        update.message.reply_text(
            'Wrong: This planet not definde'
        )  #дополнительный ответ в случае неправильного ввода
示例#17
0
def get_planet(bot, update):
    planet_obj = None
    planet_cmd = update.message.text
    planet = planet_cmd.split()[1]
    if planet == "Mercury":
        planet_obj = ephem.Mercury(datetime.date.today())
    elif planet == "Venus":
        planet_obj = ephem.Venus(datetime.date.today())
    elif planet == "Earth":
        update.message.reply_text("Ты же на Земле!")
        return
    elif planet == "Mars":
        planet_obj = ephem.Mars(datetime.date.today())
    elif planet == "Jupiter":
        planet_obj = ephem.Jupiter(datetime.date.today())
    elif planet == "Saturn":
        planet_obj = ephem.Saturn(datetime.date.today())
    elif planet == "Uranus":
        planet_obj = ephem.Uranus(datetime.date.today())
    elif planet == "Neptune":
        planet_obj = ephem.Neptune(datetime.date.today())
    elif planet == "Pluto":
        planet_obj = ephem.Pluto(datetime.date.today())
    else:
        update.message.reply_text("Введена неверная планета")
        return
    update.message.reply_text(ephem.constellation(planet_obj)[1])
示例#18
0
  def __init__(self, screen, obs, sun):
    self.screen = screen
    self.obs = obs
    self.sun = sun
    self.pline = 235
    self.pFont = pygame.font.SysFont('Arial', 16, bold=True)

    # plot the naked eye planets
    self.plotPlanet(ephem.Saturn(), (245,128,245), 3)
    self.plotPlanet(ephem.Jupiter(),(245,245,128), 3)
    self.plotPlanet(ephem.Mars(),  (245,0,0), 3)
    self.plotPlanet(ephem.Venus(), (245,245,245), 3)
    self.plotPlanet(ephem.Mercury(), (128,245,245), 3)

    moon = ephem.Moon()
    moon.compute(obs)
    if (moon.alt>0):
      pygame.draw.circle(self.screen, (255,255,255), getxy(moon.alt, moon.az), 7, 0)
      txt = self.pFont.render('Moon', 1, (255,255,255))
      self.pline -= 15
      self.screen.blit(txt, (1,self.pline))

    if (sun.alt>0):
      pygame.draw.circle(self.screen, (255,255,0), getxy(sun.alt, sun.az), 7, 0)
      txt = self.pFont.render('Sun', 1, (255,255,0))
      self.pline -= 15
      self.screen.blit(txt, (1, self.pline))
示例#19
0
def set_source(name):
    """
    Returns an ephem object from the 
    source catalog.
    """

    name = name.lower()

    if name == 'sun':
        source = ephem.Sun()
    if name == 'mars':
        source = ephem.Mars()
    if name == 'jupiter':
        source = ephem.Jupiter()
    if name == 'lmc':
        source = ephem.readdb("LMC,f|G,5:23:34,-69:45:24,0.9,2000,3.87e4|3.3e4")
    if name == '3c273':
        source = ephem.readdb("3C273,f|G,12:29:06.6997,+02:03:08.598,12.8,2000,34.02|25.17")
    if name == 'sgra':
        source = ephem.readdb("sgrA,f|J,17:45:40.036,-29:00:28.17,0,2000")
    if name == 'g90':
        source = ephem.readdb("G90,f|J,21:13:44,48:12:27.17,0,2000")
    if name == 'g180':
        source = ephem.readdb("G180,f|J,05:43:11,29:1:20,0,2000")
    if name == 'orion':
        source = ephem.readdb("Orion,f|J,05:35:17.3,-05:23:28,0,2000")
    if name == 'rosett':
        source = ephem.readdb("Rosett,f|J,06:31:51,04:54:47,0,2000")
    #else:
        #print "Source not found in catalogue."
        #source = None
    
    return source
示例#20
0
def planet_ephem(bot, update, args):
    date = datetime.datetime.now().strftime('%Y/%m/%d')

    if args[0] == 'Jupiter':
        planet_constellation = ephem.constellation(ephem.Jupiter(date))   #/planet Jupiter
    elif args[0] == 'Mars':
        planet_constellation = ephem.constellation(ephem.Mars(date))      #/planet Mars
    elif args[0] == 'Mercury':
        planet_constellation = ephem.constellation(ephem.Mercury(date))   #/planet Mercury
    elif args[0] == 'Moon':
        planet_constellation = ephem.constellation(ephem.Moon(date))      #/planet Moon
    elif args[0] == 'Neptune':
        planet_constellation = ephem.constellation(ephem.Neptune(date))   #/planet Neptune
    elif args[0] == 'Pluto':
        planet_constellation = ephem.constellation(ephem.Pluto(date))     #/planet Pluto
    elif args[0] == 'Saturn':
        planet_constellation = ephem.constellation(ephem.Saturn(date))    #/planet Saturn
    elif args[0] == 'Sun':
        planet_constellation = ephem.constellation(ephem.Sun(date))       #/planet Sun
    elif args[0] == 'Uranus':
        planet_constellation = ephem.constellation(ephem.Uranus(date))    #/planet Uranus
    elif args[0] == 'Venus':
        planet_constellation = ephem.constellation(ephem.Venus(date))     #/planet Venus
    
    text = planet_constellation

    update.message.reply_text(" Планета {0} находится в созвездии {1} на дату {2}".format(args[0], text[1], date ))
示例#21
0
    def __init__(self, config):
        super(self.__class__, self).__init__(config)

        self.body = ephem.Mars()
        self.id = "mars"
        self.name = "Mars"
        self.category = "planet"
示例#22
0
def talk_about_planet(bot, update):
    user_text = update.message.text

    planet = user_text.capitalize()
    print('Вопрос о планете ' + planet)

    if planet == 'Sun':
        place = ephem.constellation(ephem.Sun(datetime.datetime.now()))
    elif planet == 'Moon':
        place = ephem.constellation(ephem.Moon(datetime.datetime.now()))
    elif planet == 'Earth':
        place = ephem.constellation(ephem.Earth(datetime.datetime.now()))
    elif planet == 'Mercury':
        place = ephem.constellation(ephem.Mercury(datetime.datetime.now()))
    elif planet == 'Mars':
        place = ephem.constellation(ephem.Mars(datetime.datetime.now()))
    elif planet == 'Venus':
        place = ephem.constellation(ephem.Venus(datetime.datetime.now()))
    elif planet == 'Jupiter':
        place = ephem.constellation(ephem.Jupiter(datetime.datetime.now()))
    elif planet == 'Uranus':
        place = ephem.constellation(ephem.Uranus(datetime.datetime.now()))
    elif planet == 'Neptune':
        place = ephem.constellation(ephem.Neptune(datetime.datetime.now()))
    else:
        place = 'NO'

    print(place)
    if place == 'NO':
        answer_text = 'Не могу дать ответ'
    else:
        answer_text = planet + ' находится в ' + place[1]

    print(answer_text)
    update.message.reply_text(answer_text)
示例#23
0
def show_planet(update, context):
    now = datetime.datetime.now()
    print('Вызван /planet')
    active_planet = 0
    planet = update.message.text.split(' ')
    date = '{}/{}/{}'.format(now.year, now.month, now.day)
    #print(date)
    if planet[1].lower() == 'mars':

        active_planet = ephem.Mars(date)
        constellation = ephem.constellation(active_planet)
        update.message.reply_text(constellation)

    elif planet[1].lower() == 'jupiter':
        active_planet = ephem.Jupiter(date)
        constellation = ephem.constellation(active_planet)
        update.message.reply_text(constellation)
    elif planet[1].lower() == 'mercury':
        active_planet = ephem.Mercury(date)
        constellation = ephem.constellation(active_planet)
        update.message.reply_text(constellation)
    elif planet[1].lower() == 'venus':
        active_planet = ephem.Venus(date)
        constellation = ephem.constellation(active_planet)
        update.message.reply_text(constellation)
    elif planet[1].lower() == 'saturn':
        active_planet = ephem.Saturn(date)
        constellation = ephem.constellation(active_planet)
        update.message.reply_text(constellation)
    elif planet[1].lower() == 'uranus':
        active_planet = ephem.Uranus(date)
        constellation = ephem.constellation(active_planet)
        update.message.reply_text(constellation)
    else:
        update.message.reply_text("Такой планеты нет в базе данных")
示例#24
0
    def test_equatorial_to_horizontal_dunedin(self):

        # http://www.ccdimages.com/Planets.aspx
        # get RA,dec for planets
        # verify RA and dec with ephem                                                [OK]
        # get el and az with ephem for dunedin today
        # calc el and az from RA and dec with OUR function

        import ephem

        dnd = ephem.Observer()
        dnd.lon = str(Dunedin.lon.to_degrees())
        dnd.lat = str(Dunedin.lat.to_degrees())
        dnd.elevation = Dunedin.alt
        dnd.pressure = 0.0
        datee = datetime.datetime.utcnow()
        dnd.date = datee

        objectlist = [
            ephem.Sun(),
            ephem.Mercury(),
            ephem.Venus(),
            ephem.Mars(),
            ephem.Jupiter(),
            ephem.Saturn(),
            ephem.Uranus(),
            ephem.Neptune(),
        ]
        for j in objectlist:
            j.compute(dnd)
            ra = angle.from_rad(j.ra.real)
            dec = angle.from_rad(j.dec.real)
            el, az = Dunedin.equatorial_to_horizontal(datee, ra, dec)
            self.assertAlmostEqual(el.to_rad(), j.alt.real, 3)
            self.assertAlmostEqual(az.to_rad(), j.az.real, 3)
示例#25
0
def planet_talk(bot, update, user_data):
    planet_name = "зельдобаран"
    user_text = update.message.text.split(' ')
    user_planet = user_text[1]
    if user_planet == 'Меркурий':
        planet_name = 'Меркурий'
        planet = ephem.Mercury(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Венера':
        planet_name = 'Венера'
        planet = ephem.Venus(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Марс':
        planet_name = 'Марс'
        planet = ephem.Mars(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Юпитер':
        planet_name = 'Юпитер'
        planet = ephem.Jupiter(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Сатурн':
        planet_name = 'Сатурн'
        planet = ephem.Saturn(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Уран':
        planet_name = 'Уран'
        planet = ephem.Uranus(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Нептун':
        planet_name = 'Нептун'
        planet = ephem.Neptune(datetime.now())
        update.message.reply_text(planet_answer(planet, planet_name), reply_markup=get_keyboard())
    if user_planet == 'Плутон':
        update.message.reply_text("Плутон не Планета!!!!", reply_markup=get_keyboard())
示例#26
0
def planet(bot, update, args):
    date_today = d.datetime.today()
    planet_name = ' '.join(args)
    planet_name = planet_name.lower()
    try:
        if planet_name == 'mars':
            planet_name = ephem.Mars(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        elif planet_name == 'neptune':
            planet_name = ephem.Neptune(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        elif planet_name == 'pluto':
            planet_name = ephem.Pluto(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        elif planet_name == 'saturn':
            planet_name = ephem.Saturn(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        elif planet_name == 'uranus':
            planet_name = ephem.Uranus(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        elif planet_name == 'venus':
            planet_name = ephem.Venus(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        elif planet_name == 'jupiter':
            planet_name = ephem.Jupiter(date_today)
            update.message.reply_text(ephem.constellation(planet_name)[1])
        else:
            update.message.reply_text('No data')
    except IndexError:
        update.message.reply_text(
            'Enter planet name please! For example, /planet Mars',
            reply_markup=get_keyboard())
        logging.info('User did not enter a planet')
示例#27
0
文件: bot.py 项目: sashakom/First-bot
def planets_chat(bot, update):
    name_planet = update.message.text
    logging.info(name_planet)
    if name_planet == 'Mars':
        sky = ephem.Mars()
    elif name_planet == 'Mercury':
        sky = ephem.Mercury()
    elif name_planet == 'Venus':
        sky = ephem.Venus()
    elif name_planet == 'Earth':
        sky = ephem.Earth()
    elif name_planet == 'Jupiter':
        sky = ephem.Jupiter()
    elif name_planet == 'Saturn':
        sky = ephem.Saturn()
    elif name_planet == 'Uranus':
        sky = ephem.Uranus()
    elif name_planet == 'Neptune':
        sky = ephem.Neptune()
    elif name_planet == 'Pluto':
        sky = ephem.Pluto()
    else:
        update.message.reply_text('Wrong name planet')
    sky.compute(datetime.date.today())
    update.message.reply_text(ephem.constellation(sky))
示例#28
0
def print_new_planet(bot, update):
    user_text = update.message.text
    planet_name = user_text.split(' ')[1]
    print(planet_name)
    year = "2019"
    list_planets = give_me_planets()
    if planet_name in list_planets:
        if planet_name == "Mars":
            m = ephem.Mars(year)
        elif planet_name == "Mercury":
            m = ephem.Mercury(year)
        elif planet_name == "Venus":
            m = ephem.Venus(year)
        elif planet_name == "Jupiter":
            m = ephem.Jupiter(year)
        elif planet_name == "Saturn":
            m = ephem.Saturn(year)
        elif planet_name == "Uranus":
            m = ephem.Uranus(year)
        elif planet_name == "Neptune":
            m = ephem.Neptune(year)
        elif planet_name == "Pluto":
            m = ephem.Pluto(year)
        elif planet_name == "Sun":
            m = ephem.Sun(year)
        elif planet_name == "Moon":
            m = ephem.Moon(year)
        constell_name = ephem.constellation(m)
        print(constell_name)
        update.message.reply_text(constell_name)
    else:
        update.message.reply_text('Not a planet!')
示例#29
0
def find_next_opposition(start_time):
    """Find oppsition and time of closest approach for the given time range.
       Input is the start time, either in ephem.Date or float julian.
       Output is two ephem.Dates: opposition, closest approach
    """
    t = start_time
    timedelta = ephem.hour * 6
    mars = ephem.Mars()
    sun = ephem.Sun()
    min_dist = 20
    oppy_date = None
    closest_date = None
    last_dlon = None

    # Loop til we've found opposition, plus 15 days.
    # Opposition is when dlon changes sign and is very small.
    while not oppy_date or t - oppy_date < 15:
        mars.compute(t)
        sun.compute(t)
        dlon = mars.hlon - sun.hlon

        # Does dlon have the opposite sign from last_dlon?
        if last_dlon and abs(dlon) < .1 and \
           (dlon == 0 or (dlon < 0) != (last_dlon < 0)):
            oppy_date = t
        if mars.earth_distance < min_dist:
            closest_date = t
            min_dist = mars.earth_distance

        if oppy_date and closest_date:
            return ephem.Date(oppy_date), ephem.Date(closest_date)

        last_dlon = dlon
        t += timedelta
示例#30
0
文件: bot.py 项目: Askanio234/lesson1
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='Эй, это не планета!')