def get_keyword(update: Update, context: CallbackContext): chat_id = update.message.from_user.id gif = Gif.get(Gif.id == context.user_data['gif']) text = update.message.text if text == 'DONE': context.bot.send_message(chat_id, 'do you agree to show this gif to others?!', reply_markup=ReplyKeyboardMarkup([['YES'], ['NO']])) return PUBLIC try: keyword = Keyword.get(Keyword.text == text.lower()) if keyword in gif.keywords: context.bot.send_message(chat_id, 'You have already added this keyword!') else: gif.keywords.add(keyword) context.bot.send_message(chat_id, 'keyword successfully added!') except: keyword = Keyword.insert({ Keyword.text: text.lower() }).execute() gif.keywords.add(keyword) context.bot.send_message(chat_id, 'keyword successfully added!') return