def subscribe(update, context): user = get_or_create_subscriber(update.effective_user, update.message) if not user.active: toogle_subscription(user.user_id) update.message.reply_text("You have subscribed") else: update.message.reply_text("You have already subscribed")
def unsubscribe(update, context): user = get_or_create_subscriber(update.effective_user, update.message) if user.active: toogle_subscription(user.user_id) update.message.reply_text("You have unsubscribed") else: update.message.reply_text("You haven't subscribed, press /subscribe for subscribing")
def mintmanga_track(update, context): user = get_or_create_subscriber(update.effective_user, update.message) try: manga_id = int(update.message.text.replace('/track_', '')) manga_title = get_manga_title('mintmanga', manga_id) text = "If you want to add once more manga press /add_more or /cancel for quit" if is_subscribed_to_manga('mintmanga', user.user_id, manga_id): update.message.reply_text(f"{manga_title} is already in your tracikng list") update.message.reply_text(text) return "add_more" else: update.message.reply_text("adding...") update = update_manga('mintmanga', manga_id) if not update: update.message.reply_text("no chapters in manga") delete_manga('mintmanga', manga_id) update.message.reply_text(text) return "add_more" subscribe_to_manga('mintmanga', user.user_id, manga_id) update.message.reply_text(f"{manga_title} added in your tracking list") update.message.reply_text(text) return "add_more" except ValueError: update.message.reply_text("don't do this again") return ConversationHandler.END
def get_last_readmanga_chapter(update, context): user = get_or_create_subscriber(update.effective_user, update.message) manga_id = int(update.message.text.replace('/last_chapter_', '')) if is_subscribed_to_manga('readmanga', user.user_id, manga_id): chapters = get_manga_chapters(manga_id) text = f'title: {chapters[0]["chapter_name"]}\nurl: {chapters[0]["chapter_url"]}' update.message.reply_text(text) else: update.message.reply_text("don't do this again")
def talk_to_me(update, context): user = get_or_create_subscriber(update.effective_user, update.message) text = "Hello {}, you said {}".format( user.user_id, update.message.text) logging.info("User: %s, Chat id: %s, Message: %s", user.user_id, user.chat_id, update.message.text ) update.message.reply_text(text, reply_markup=get_keyboard())
def manga_choose(update, context): user = get_or_create_subscriber(update.effective_user, update.message) if user.active: inlinekeyboard = [[ InlineKeyboardButton("Mintmanga", callback_data='mintmanga'), InlineKeyboardButton("Readmanga", callback_data='readmanga'), InlineKeyboardButton("Cancel", callback_data='cancel') ]] kbd_markup = InlineKeyboardMarkup(inlinekeyboard) update.message.reply_text("Choose provider", reply_markup=kbd_markup) return "choose_provider" else: update.message.reply_text("You haven't subscribed, press /subscribe for subscribing") return ConversationHandler.END
def get_subscribed_readmanga(update, context): user = get_or_create_subscriber(update.effective_user, update.message) tracking_manga = get_subscribed_manga_ids('readmanga', user.user_id) if tracking_manga is not None: text = "Your manga:\n" for manga_id in tracking_manga: text += f""" Title: {get_manga_title(manga_id)} Chapters: {get_manga_chapters_value(manga_id)} /last_chapter_{manga_id} """ update.message.reply_text(text) else: update.message.reply_text("you don't have any manga in your tracking list")
def delete_readmanga_choose(update, context): user = get_or_create_subscriber(update.effective_user, update.message) try: manga_id = int(update.message.text.replace('/delete_', '')) manga_exist = is_subscribed_to_manga(user.user_id, manga_id) if manga_exist: unsubscribe_from_manga('readmanga', user.user_id, manga_id) manga_title = get_manga_title('readmanga', manga_id) update.message.reply_text(f"{manga_title} deleted from your tracking list") else: update.message.reply_text("don't do this again") except ValueError: update.message.reply_text("don't do this again") finally: return ConversationHandler.END
def delete_readmanga_start(update, context): user = get_or_create_subscriber(update.effective_user, update.message) tracking_manga = get_subscribed_manga_ids('readmanga', user.user_id) if tracking_manga is not None: text = "Choose manga:\n" for manga_id in tracking_manga: text += f""" Title: {get_manga_title(manga_id)} /delete_{manga_id} """ update.message.reply_text(text) update.message.reply_text("press /cancel for leaving conversation") return "delete" else: update.message.reply_text("you don't have tracking manga") return ConversationHandler.END
def greet_user(update, context): user = get_or_create_subscriber(update.effective_user, update.message) text = f"Hello {user.user_id}" update.message.reply_text(text, reply_markup=get_keyboard())