From de4c28232b3dfd55ede1762f0ac73d7c9233ba76 Mon Sep 17 00:00:00 2001 From: cloveranon Date: Fri, 20 Dec 2019 04:23:00 -0500 Subject: [PATCH] Fixed bug with saving custom prompts to file with blank name --- play.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/play.py b/play.py index eae369f..a331b1b 100644 --- a/play.py +++ b/play.py @@ -104,9 +104,9 @@ def play(): context=colInput('Context>', colors['main-prompt'], colors['user-text']) prompt=colInput('Prompt>', colors['main-prompt'], colors['user-text']) filename=colInput('Name to save prompt as? (Leave blank for no save): ', colors['query'], colors['user-text']) - filename=re.sub('-$','',re.sub('^-', '', re.sub('[^a-zA-Z0-9_-]+', '-', filename)))+'.txt' + filename=re.sub('-$','',re.sub('^-', '', re.sub('[^a-zA-Z0-9_-]+', '-', filename))) if filename != '': - with open(Path('prompts', filename), 'w', encoding='utf-8') as f: + with open(Path('prompts', filename+'.txt'), 'w', encoding='utf-8') as f: #this saves unix style line endings which might be an issue #don't know how to do this properly f.write(context+'\n'+prompt+'\n')