def user_profile_viewer_cancel(call): try: frontend.delete_message(call.message.chat.id, call.message.message_id) except Exception: pass frontend.answer_callback_query(call.id)
def __find_buddies_button_pressed(call): alert_text = None buddies = bot.suggest_buddies(call.message.chat.id) if not send_buddies(call.message, buddies): alert_text = 'Не найдено' frontend.answer_callback_query(call.id, alert_text)
def __join_button_pressed(call): if call.message.message_id in instances: user_id, activities = instances[call.message.message_id] pointer = __parse_join_activity_data(call.data) activity_id = activities[pointer].id p = False if is_participating(user_id, activity_id): logger.info(f"Unlisting user from activity #{activity_id}") quit_activity(user_id, activity_id) p = False else: logger.info(f"Enlisting user in activity #{activity_id}") participate_in_activity(user_id, activity_id) p = True try: frontend.edit_message_reply_markup( chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=__activity_markup(activities, pointer, p)) except apihelper.ApiException as e: print(e) frontend.answer_callback_query(call.id)
def __participants_button_pressed(call): alert_text = None activity_id = call.data.split('_')[3] participants = bot.users_by_activity(activity_id) if not send_buddies(call.message, participants): alert_text = \ "В мероприятии никто не участвует. Вы можете стать первым!" frontend.answer_callback_query(call.id, alert_text)
def __activities_near_button_pressed(call): alert_text = None activities = bot.suggest_activities(call.message.chat.id) logger.info("Serving activity_viewer with activities nearby") if not send_activities(call.message, activities, alert_text): alert_text = "Не найдено ни одно достаточно близкое к Вам мероприятие" frontend.answer_callback_query(call.id, alert_text)
def __find_button_pressed(call): alert_text = None activities = bot.activities_by_user(call.message.chat.id) logger.info("Serving activity_viewer with user's activities") if not send_activities(call.message, activities, alert_text): alert_text = "Вы не подписаны ни на одно мероприятие" frontend.answer_callback_query(call.id, alert_text)
def __select_button_pressed(call): user_id = call.data.split('_')[2] logger.debug(f"User profile with id {user_id} selected " ", serving user_profile_viewer") user_a = bot.get_user_by_id(call.message.chat.id) user_b = bot.get_user_by_id(user_id) t, m, f = user_profile_viewer.create_component(user_a, user_b) frontend.send_photo(call.message.chat.id, f, t, reply_markup=m) frontend.answer_callback_query(call.id)
def delete_buddy_button_pressed(call): ba, bb = __parse_change_buddy_status_data(call.data) logger.info(f"Unbudding {bb} from {ba}") bot.unbud(ba, bb) # Создание нового markup для обновления старого markup = create_markup_add(ba, bb) # Обновление старого markup frontend.edit_message_reply_markup( chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=markup) frontend.answer_callback_query(call.id)
def __next_button_pressed(call): alert_text = None if not __try_switch(call): alert_text = "Показано последнее мероприятие" frontend.answer_callback_query(call.id, alert_text)
def __prev_button_pressed(call): alert_text = None if not __try_switch(call): alert_text = "Показано самое первое мероприятие" frontend.answer_callback_query(call.id, alert_text)
def __next_button_pressed(call): users = instances.get(call.message.message_id) user_a = bot.get_user_by_id(call.message.chat.id) if users is not None: __update_markup(user_a, users, call) frontend.answer_callback_query(call.id)
def __buddies_button_pressed(call): alert_text = None buddies = bot.buddies_by_user_id(call.message.chat.id) if not send_buddies(call.message, buddies): alert_text = 'Список Ваших товарищей пуст' frontend.answer_callback_query(call.id, alert_text)
def handle_no_call_data(call): frontend.answer_callback_query(call.id, "Спасибо, что выбрали наш продукт!")
def __go_back_button_pressed(call): logger.debug("Deleting activity_viewer") frontend.delete_message(call.message.chat.id, call.message.message_id) frontend.answer_callback_query(call.id)
def __user_viewer_back_button_pressed(call): logger.debug("Deleting stats_display") frontend.delete_message(call.message.chat.id, call.message.message_id) frontend.answer_callback_query(call.id)
def __stats_button_pressed(call): u = bot.get_user_by_id(call.message.chat.id) t, m, p = stats_display.create_message(u) frontend.send_photo(call.message.chat.id, p, t, reply_markup=m) frontend.answer_callback_query(call.id)
def __settings_button_pressed(call): activity_creation.launch(call.message.chat.id) frontend.answer_callback_query(call.id)