def text_request(message): db = Db(db_dir) user_id = message.from_user.id text = message.text.split() if text: for word in text: word = word.lower() if db.get_word_by_user(user_id, word): db.add_word(user_id, word) else: db.new_word(user_id, word)
def text_request(message): db = Db(db_dir) user_id = message.from_user.id text = re.sub(r'(http.+?\s)|(http.+$)', r' ', message.text) text = re.sub(r'[_+-.,!@#$%^&*();/|<>"\']', r' ', text).split() if text: for word in text: word = word.lower() if db.get_word_by_user(user_id, word): db.add_word(user_id, word) else: db.new_word(user_id, word)