async def get_generic_fast(fast_name: str): user = await bot_repository.get_or_create_user() data = await zmanim_api_client.get_generic_fast( name=_get_festival_name(fast_name), location=user.location.coordinates, havdala_opinion=user.havdala_opinion) kb = inline.get_location_variants_menu(user.location_list, user.location, CallbackPrefixes.update_fast) await user.get_processor().send_fast(data, kb)
async def get_shabbat(): user = await bot_repository.get_or_create_user() data = await zmanim_api_client.get_shabbat( location=user.location.coordinates, cl_offset=user.cl_offset, havdala_opinion=user.havdala_opinion ) kb = inline.get_location_variants_menu(user.location_list, user.location, CallbackPrefixes.update_shabbat) await user.get_processor().send_shabbat(data, kb)
async def update_zmanim(lat: float, lng: float): user = await bot_repository.get_or_create_user() location = user.get_location_by_coords(lat, lng) data = await zmanim_api_client.get_zmanim( location.coordinates, user.zmanim_settings.dict() ) kb = inline.get_location_variants_menu(user.location_list, location, CallbackPrefixes.update_zmanim) await user.get_processor(location).update_zmanim(data, kb)
async def update_generic_yom_tov(yom_tov_name: str, lat: float, lng: float): user = await bot_repository.get_or_create_user() location = user.get_location_by_coords(lat, lng) data = await zmanim_api_client.get_generic_yomtov( name=_get_festival_name(yom_tov_name), location=location.coordinates, cl_offset=user.cl_offset, havdala_opinion=user.havdala_opinion) kb = inline.get_location_variants_menu(user.location_list, location, CallbackPrefixes.update_yom_tov) await user.get_processor(location).update_yom_tov(data, kb)
async def update_shabbat(lat: float, lng: float, state: FSMContext): user = await bot_repository.get_or_create_user() location = user.get_location_by_coords(lat, lng) await state.update_data({'current_location': [lat, lng]}) data = await zmanim_api_client.get_shabbat( location=location.coordinates, cl_offset=user.cl_offset, havdala_opinion=user.havdala_opinion ) kb = inline.get_location_variants_menu(user.location_list, location, CallbackPrefixes.update_shabbat) await user.get_processor(location).update_shabbat(data, kb)
async def send_zmanim(*, state: FSMContext, date: str = None, call: CallbackQuery = None): if call: date = call.data.split(CallbackPrefixes.zmanim_by_date)[1] user = await bot_repository.get_or_create_user() state_data = await state.get_data() if state_data.get('current_location'): location = user.get_location_by_coords(*state_data['current_location']) else: location = user.location data = await zmanim_api_client.get_zmanim( location.coordinates, user.zmanim_settings.dict(), date_=date ) kb = inline.get_location_variants_menu(user.location_list, location, CallbackPrefixes.update_zmanim) await user.get_processor(location=location).send_zmanim(data, kb) if call: await bot.edit_message_reply_markup(call.from_user.id, call.message.message_id, reply_markup=kb)