def ensure_bot_in_db(): with INSERTION_LOCK: bot = Users(dispatcher.bot.id, dispatcher.bot.username) SESSION.merge(bot) SESSION.commit()
def rem_nsfw(chat_id): with INSERTION_LOCK: nsfwchat = SESSION.query(NSFWChats).get(str(chat_id)) if nsfwchat: SESSION.delete(nsfwchat) SESSION.commit()
def add_note_button_to_db(chat_id, note_name, b_name, url, same_line): with BUTTONS_INSERTION_LOCK: button = Buttons(chat_id, note_name, b_name, url, same_line) SESSION.add(button) SESSION.commit()