示例#1
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)
示例#2
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("Такой планеты нет в базе данных")
示例#3
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)
示例#4
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])
示例#5
0
    def __init__(self, config):
        super(self.__class__, self).__init__(config)

        self.body = ephem.Uranus()
        self.id = "uranus"
        self.name = "Uranus"
        self.category = "planet"
示例#6
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')
示例#7
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'
        )  #дополнительный ответ в случае неправильного ввода
示例#8
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='Эй, это не планета!')
示例#9
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('Не могу найти созвездие.')
示例#10
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'")
示例#11
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")
示例#12
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)
示例#13
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))
示例#14
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))
示例#15
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)
示例#16
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)
示例#17
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)
示例#18
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!")
示例#19
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!')
示例#20
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)
示例#21
0
文件: rose_topdown.py 项目: OSSOS/MOP
def plot_planets_plus_Pluto(ax, date=parameters.NEWMOONS[parameters.DISCOVERY_NEW_MOON]):
    for planet in [ephem.Saturn(), ephem.Uranus(), ephem.Neptune(), ephem.Pluto()]:
        planet.compute(ephem.date(date))
        fc = plot_fanciness.ALMOST_BLACK
        if planet.name == 'Pluto':
            alpha = 0.35
            size = 10
            fs = 5
        else:
            alpha = 0.7
            size = 20
            fs = 10
        ax.scatter(planet.ra, planet.sun_distance,
                   marker='o',
                   s=size,
                   facecolor=fc,
                   edgecolor=fc,
                   alpha=alpha)
        if planet.name == 'Saturn':
            ax.annotate(planet.name, (planet.ra + (math.radians(3)), planet.sun_distance - 2), size=fs)
        elif planet.name == 'Uranus':
            ax.annotate(planet.name, (planet.ra - (math.radians(12)), planet.sun_distance + 1), size=fs)
        else:
            ax.annotate(planet.name, (planet.ra - (math.radians(0.5)), planet.sun_distance + 2), size=fs)

        # Neptune's orbit has e = 0.01, so can get away with a circle
        if planet.name == 'Neptune':
            orb = np.arange(0, 2 * np.pi, (2 * np.pi) / 360)
            ax.plot(orb, np.repeat(planet.sun_distance, len(orb)), color='b', linestyle=':', linewidth=0.4, alpha=0.7)

    return
示例#22
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('Ошибка! Введите название планеты на английском.')
示例#23
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))
示例#24
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}')
示例#25
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))
示例#26
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]}'
    )
示例#27
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())
示例#28
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 ))
示例#29
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))
示例#30
0
文件: ephem_bot.py 项目: readiv/ls1
def planet(bot, update):
    if update == None or update.message == None:
        return  #Периоди́чески возникает такая хрень

    edata = f"{datetime.datetime.today():%Y/%m/%d}"  #посмотри “datetime tostring” #Думаю так будет лучше

    ephem_dic = {
        'mars': ephem.Mars(edata),
        'moon': ephem.Moon(edata),
        'mercury': ephem.Mercury(edata),
        'venus': ephem.Venus(edata),
        'jupiter': ephem.Jupiter(edata),
        'saturn': ephem.Saturn(edata),
        'uranus': ephem.Uranus(edata),
        'neptune': ephem.Neptune(edata),
        'pluto': ephem.Pluto(edata),
    }

    text = update.message.text.split(' ')
    try:
        text = text[1].lower()  #Получили название планеты
        ephem_one = ephem_dic[text]
        const = ephem.constellation(ephem_one)
        update.message.reply_text(
            f'Планета {text.upper()} сегодня находится в созвездии "{const[1].upper()}"'
        )
    except:  # у тебя по смыслу тут ловится только ошибка «отсутствие в словаре» давай тогда только эту операцию транс и обернём, будет правильней
        update.message.reply_text(
            'Я вас не понял. Вы должны набрать /planet планета')
        update.message.reply_text(
            'Сейчас я знаю такие планеты: ' +
            str([x.capitalize() for x in list(ephem_dic)
                 ])[1:-1])  #давай с большой буквы выведем планеты