def handler(text: str, message_id: int, user: UserClass): match text: case 'افزودن ویس ⏬': user.database.menu = User.Menu.USER_ADD_VOICE_PLAYLIST user.database.back_menu = 'manage_playlist' user.send_message(user.translate('send_private_voice'), per_back) case 'حذف پلی لیست ❌': user.delete_playlist() user.send_message( user.translate('playlist_deleted'), reply_to_message_id=message_id ) user.go_back() case 'مشاهده ی ویس ها 📝': voices, prev_page, next_page = user.get_playlist_voices(1) if voices: user.send_message( make_list_string(ObjectType.PLAYLIST_VOICE, voices), make_list(ObjectType.PLAYLIST_VOICE, voices, prev_page, next_page) ) else: user.send_message( user.translate('empty_playlist'), reply_to_message_id=message_id ) case 'لینک دعوت 🔗': user.send_message(user.translate( 'playlist_link', user.database.current_playlist.name, user.database.current_playlist.get_link() )) case 'مشترکین پلی لیست 👥': user.send_message(user.translate( 'playlist_users_count', user.database.current_playlist.user_playlist.count() )) case _: user.send_message(user.translate('unknown_command'))
def handler(object_type: ObjectType, page: int, message_id: int, inliner: User): match object_type: case ObjectType.PLAYLIST: objs, prev_page, next_page = inliner.get_playlists(page) case ObjectType.PLAYLIST_VOICE: objs, prev_page, next_page = inliner.get_playlist_voices(page) case ObjectType.SUGGESTED_VOICE: objs, prev_page, next_page = inliner.get_suggestions(page, MemeType.VOICE) case ObjectType.SUGGESTED_VIDEO: objs, prev_page, next_page = inliner.get_suggestions(page, MemeType.VIDEO) case ObjectType.PRIVATE_VOICE: objs, prev_page, next_page = inliner.get_private_voices(page) inliner.edit_message_text( message_id, make_list_string(object_type, objs), make_list(object_type, objs, prev_page, next_page) )
def handler(text: str, message_id: int, user: User): match text: case 'پیشنهاد ویدئو 🔥': user.suggest_meme(MemeType.VIDEO) case 'لغو رای گیری ⏹': user.cancel_voting(MemeType.VIDEO) case 'مشاهده ی ویدئو ها 📝': videos, prev_page, next_page = user.get_suggestions(1, MemeType.VIDEO) if videos: user.send_message( make_list_string(ObjectType.SUGGESTED_VIDEO, videos), make_list( ObjectType.SUGGESTED_VIDEO, videos, prev_page, next_page ) ) else: user.send_message(user.translate( 'empty_suggested_memes', user.translate('video') ), reply_to_message_id=message_id) case _: user.send_message(user.translate('unknown_command'), reply_to_message_id=message_id)
def handler(text: str, message_id: int, user: UserClass): match text: case 'ایجاد پلی لیست 🆕': user.database.back_menu = 'manage_playlists' user.database.menu = User.Menu.USER_CREATE_PLAYLIST user.send_message(user.translate('playlist_name'), per_back) case 'مشاهده پلی لیست ها 📝': current_page, prev_page, next_page = user.get_playlists(1) if current_page: user.send_message( make_list_string(ObjectType.PLAYLIST, current_page), make_list( ObjectType.PLAYLIST, current_page, prev_page, next_page ) ) else: user.send_message( user.translate('no_playlist'), reply_to_message_id=message_id ) case _: user.send_message(user.translate('unknown_command'), reply_to_message_id=message_id)
def handler(text: str, message_id: int, user: UserClass): match text: case 'افزودن ویس ⏬': if user.private_voices_count <= 120: user.database.menu = User.Menu.USER_PRIVATE_VOICE_NAME user.database.back_menu = 'manage_private_voices' user.send_message( user.translate('meme_name', user.translate('voice')), per_back ) else: user.send_message(user.translate('voice_limit')) case 'مشاهده ی ویس ها 📝': voices, prev_page, next_page = user.get_private_voices(1) if voices: user.send_message( make_list_string(ObjectType.PRIVATE_VOICE, voices), make_list(ObjectType.PRIVATE_VOICE, voices, prev_page, next_page) ) else: user.send_message( user.translate('empty_private_voices'), reply_to_message_id=message_id ) case _: user.send_message(user.translate('unknown_command'), reply_to_message_id=message_id)