def save(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] conn = connected(bot, update, chat, user.id) if not conn == False: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": chat_name = "local notes" else: chat_name = chat.title msg = update.effective_message # type: Optional[Message] note_name, text, data_type, content, buttons = get_note_type(msg) if data_type is None: msg.reply_text("Dude, there's no note") return if len(text.strip()) == 0: text = note_name sql.add_note_to_db(chat_id, note_name, text, data_type, buttons=buttons, file=content) msg.reply_text( "Ok, added `{note_name}` note in *{chat_name}*.\nGet it with `/get {note_name}`, or `#{note_name}`".format(note_name=note_name, chat_name=chat_name), parse_mode=ParseMode.MARKDOWN)
def save(bot: Bot, update: Update): chat = update.effective_chat user = update.effective_user conn = connected(bot, update, chat, user.id) if conn: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": chat_name = tld(chat.id, "note_is_local") else: chat_name = chat.title msg = update.effective_message note_name, text, data_type, content, buttons = get_note_type(msg) note_name = note_name.lower() if data_type is None: msg.reply_text(tld(chat.id, "save_invalid")) return if len(text.strip()) == 0: text = note_name if not sql.get_note(chat_id, note_name): sql.add_note_to_db(chat_id, note_name, text, data_type, buttons=buttons, file=content) msg.reply_text(tld(chat.id, "save_success").format(note_name, chat_name, note_name, note_name), parse_mode=ParseMode.MARKDOWN) else: sql.add_note_to_db(chat_id, note_name, text, data_type, buttons=buttons, file=content) msg.reply_text(tld(chat.id, "save_updated").format(note_name, chat_name, note_name, note_name), parse_mode=ParseMode.MARKDOWN)