diff --git a/linkulator b/linkulator index 8a14292..6fc333d 100755 --- a/linkulator +++ b/linkulator @@ -252,22 +252,28 @@ def reply(owner, tstamp, post_id): comment = input("Enter your comment (or leave empty to abort): ") - if comment == "": - input("Reply aborted. Hit [Enter] to continue.") - else: - if os.path.exists(config.USER.datafile): - append_write = "a" # append if already exists + while True: + if comment == "": + input("Reply aborted. Hit [Enter] to continue.") + break + elif not posts.is_valid(comment): + print("Please try again, that response contains invalid characters.") + comment = posts.rlinput("Enter your comment (or leave empty to abort):") else: - append_write = "w+" # make a new file if not - with open(config.USER.datafile, append_write) as file: - timestamp = str(time.time()) - file.write(timestamp + "|" + owner + "+" + tstamp + "|||" + comment + "\n") + if os.path.exists(config.USER.datafile): + append_write = "a" # append if already exists + else: + append_write = "w+" # make a new file if not + with open(config.USER.datafile, append_write) as file: + timestamp = str(time.time()) + file.write(timestamp + "|" + owner + "+" + tstamp + "|||" + comment + "\n") - link_data.insert( - 0, ["", username, timestamp, owner + "+" + tstamp, "", "", comment] - ) + link_data.insert( + 0, ["", username, timestamp, owner + "+" + tstamp, "", "", comment] + ) - input("Reply added. Hit [Enter] to return to thread.") + input("Reply added. Hit [Enter] to return to thread.") + break view_thread(post_id)