cafe_buy_duo 0.0.55 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_buy_duo.rb +582 -482
  3. metadata +2 -2
data/lib/cafe_buy_duo.rb CHANGED
@@ -22,97 +22,107 @@ using Rainbow
22
22
  include Glimmer
23
23
 
24
24
  class Chat
25
-
26
- def initialize(api_key)
25
+ def initialize(api_key, gpt_keyword_prompt)
27
26
  @api_key = api_key
27
+ @gpt_keyword_prompt = gpt_keyword_prompt
28
28
  end
29
29
 
30
- def message2(keyword)
31
- puts'[GPT] 키워드 기반 글을 생성 중입니다.......'.yellow
32
- url = 'https://api.openai.com/v1/chat/completions'
33
- h = {
34
- 'Content-Type' => 'application/json',
35
- 'Authorization' => 'Bearer ' + @api_key
36
- }
37
- d = {
38
- #'model' => 'gpt-3.5-turbo',
39
- 'model' => 'gpt-4',
40
- 'messages' => [{
41
- "role" => "assistant",
42
- "content" => keyword.to_s+" 소개하는 글을 1500자에서 2500자 사이로 만들어줘"
43
- }]
44
- }
45
- answer = ''
46
- begin
47
- req = HTTP.headers(h).post(url, :json => d)
48
- print(req.to_s)
49
- answer = JSON.parse(req.to_s)['choices'][0]['message']['content']
50
- rescue => e
51
- begin
52
- answer = JSON.parse(req.to_s)['choices'][0]['message']['message']
53
- rescue
30
+ def message(keyword)
31
+ puts 'Sending request to GPT...(키워드 기반 생성 중...)'
54
32
 
33
+ # "키워드 기반 글 생성 중..." 메시지 출력 스레드
34
+ thread = Thread.new do
35
+ while true
36
+ print "▶"
37
+ sleep 3
55
38
  end
56
39
  end
57
40
 
58
-
59
- print('api return ==> ')
60
- puts(answer)
61
-
62
- return answer
63
- end
64
-
65
- def message(keyword)
66
- puts 'chat gpt ...'
67
41
  url = 'https://api.openai.com/v1/chat/completions'
68
- h = {
42
+ headers = {
69
43
  'Content-Type' => 'application/json',
70
44
  'Authorization' => 'Bearer ' + @api_key
71
45
  }
72
- d = {
73
- #'model' => 'gpt-3.5-turbo',
46
+
47
+ # 사용자로부터 받은 입력과 GPT 프롬프트의 토큰 수 계산
48
+ message_tokens = calculate_tokens(keyword) + calculate_tokens(@gpt_keyword_prompt)
49
+
50
+ # 8,192 토큰을 초과하지 않도록 최대 토큰 수를 설정
51
+ max_response_tokens = [8192 - message_tokens, 4000].min # 8,192 - 입력된 토큰 수, 4,000 이하로 설정
52
+
53
+ # 요청 데이터 설정
54
+ data = {
74
55
  'model' => 'gpt-4',
75
- 'messages' => [{
76
- "role" => "assistant",
77
- "content" => keyword.to_s+" 관련된 글을 1500자에서 2500자 사이로 만들어줘"
78
- }]
56
+ 'messages' => [
57
+ {
58
+ "role" => "assistant",
59
+ "content" => "#{keyword}\n#{@gpt_keyword_prompt}"
60
+ }
61
+ ],
62
+ 'max_tokens' => max_response_tokens # 최대 응답 토큰 설정
79
63
  }
64
+
65
+
66
+
80
67
  answer = ''
81
68
  begin
82
- req = HTTP.headers(h).post(url, :json => d)
83
- print(req.to_s)
84
- answer = JSON.parse(req.to_s)['choices'][0]['message']['content']
85
- rescue => e
86
- begin
87
- answer = JSON.parse(req.to_s)['choices'][0]['message']['message']
88
- rescue
69
+ req = HTTP.headers(headers).post(url, :json => data)
89
70
 
71
+ # 상태 코드 확인
72
+ if req.status != 200
73
+ raise "HTTP Error: #{req.status}, Response Body: #{req.body.to_s}"
90
74
  end
91
- end
92
- con = 0
93
- while con > 5
94
- answer = answer + message2(keyword)
95
- if answer.length > 2000
96
- break
75
+
76
+ # 응답 내용 출력 (디버깅용)
77
+ response = JSON.parse(req.to_s)
78
+
79
+
80
+ # 응답 데이터에서 안전하게 값 추출
81
+ if response['choices'] && response['choices'][0] && response['choices'][0]['message']
82
+ answer = response['choices'][0]['message']['content']
83
+ else
84
+ raise "Invalid API response format"
97
85
  end
98
- con += 1
86
+ rescue => e
87
+ # 오류 메시지 출력
88
+ puts "Error occurred: #{e.message}"
89
+ answer = "오류가 발생했습니다."
99
90
  end
100
91
 
101
- print('api return ==> ')
102
- puts(answer)
92
+ # "생성 중..." 메시지 출력 종료
93
+ thread.kill
103
94
 
95
+ # 결과 로그 출력
96
+ puts "Final API response ==> #{answer}"
104
97
  return answer
105
98
  end
99
+
100
+ def calculate_tokens(text)
101
+ # 간단한 방식으로 텍스트의 토큰 수 계산 (정확도는 다를 수 있음)
102
+ # OpenAI API는 1토큰이 대략 4글자 정도임
103
+ text.split(/\s+/).length # 간단한 단어 수로 계산
104
+ end
106
105
  end
107
106
 
107
+
108
+
109
+
110
+
108
111
  class Chat_title
109
-
110
- def initialize(api_key)
112
+ def initialize(api_key, gpt_title_prompt)
111
113
  @api_key = api_key
114
+ @gpt_title_prompt = gpt_title_prompt
112
115
  end
113
116
 
114
117
  def message(title)
115
- puts'[GPT] 유사 제목을 생성 중입니다.......'.yellow
118
+ puts 'Sending request to GPT...(제목 생성 중...)'
119
+ # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
120
+ thread = Thread.new do
121
+ while true
122
+ print "▶"
123
+ sleep(3)
124
+ end
125
+ end
116
126
  url = 'https://api.openai.com/v1/chat/completions'
117
127
  headers = {
118
128
  'Content-Type' => 'application/json',
@@ -126,15 +136,15 @@ class Chat_title
126
136
  },
127
137
  {
128
138
  "role" => "user",
129
- "content" => "#{title}\n위 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘."
139
+ "content" => "#{@gpt_title_prompt}\n#{title}"
130
140
  }]
131
141
  }
132
142
 
133
143
  begin
134
144
  req = HTTP.headers(headers).post(url, json: data)
135
- puts "HTTP Status: #{req.status}" # 상태 코드 확인
145
+
136
146
  response = JSON.parse(req.body.to_s)
137
- puts "API Response: #{response}" # 전체 응답 출력
147
+
138
148
 
139
149
  if req.status == 429
140
150
  return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
@@ -142,11 +152,18 @@ class Chat_title
142
152
 
143
153
  # 응답 데이터에서 안전하게 값 추출
144
154
  answer = response.dig('choices', 0, 'message', 'content')
145
- answer ||= (title) # 응답이 없을 경우 기본 메시지 설정
155
+
156
+ # 따옴표 제거
157
+ answer = answer.gsub('"', '') if answer
158
+
159
+ answer ||= title # 응답이 없을 경우 기본 메시지 설정
146
160
  rescue => e
147
161
  puts "Error: #{e.message}"
148
162
  answer = "오류가 발생했습니다."
149
163
  end
164
+
165
+ # "생성 중..." 메시지 출력 종료
166
+ thread.kill
150
167
 
151
168
  puts 'API return ==> '
152
169
  puts answer
@@ -154,14 +171,24 @@ class Chat_title
154
171
  end
155
172
  end
156
173
 
174
+
157
175
  class Chat_content
158
-
159
- def initialize(api_key)
176
+ def initialize(api_key, gpt_content_prompt)
160
177
  @api_key = api_key
178
+ @gpt_content_prompt = gpt_content_prompt
161
179
  end
162
180
 
163
181
  def message(content)
164
- puts'[GPT] 유사 내용을 생성 중입니다! 조금만 기다려주세요.......'.yellow
182
+ puts '주의:GPT 특성상 원고 길이가 공백 포함 4천자를 넘기면 오류가 발생할 수 있습니다.'
183
+ puts 'Sending request to GPT...(내용 변형 중...)'
184
+ # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
185
+ thread = Thread.new do
186
+ while true
187
+ print "▶"
188
+ sleep(3)
189
+ end
190
+ end
191
+
165
192
  url = 'https://api.openai.com/v1/chat/completions'
166
193
  headers = {
167
194
  'Content-Type' => 'application/json',
@@ -175,15 +202,16 @@ class Chat_content
175
202
  },
176
203
  {
177
204
  "role" => "user",
178
- "content" => "#{content}\nChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해"
205
+ "content" => "#{@gpt_content_prompt}\n#{content}"
206
+
179
207
  }]
180
208
  }
181
209
 
182
210
  begin
183
211
  req = HTTP.headers(headers).post(url, json: data)
184
- puts "HTTP Status: #{req.status}" # 상태 코드 확인
212
+
185
213
  response = JSON.parse(req.body.to_s)
186
- puts "API Response: #{response}" # 전체 응답 출력
214
+
187
215
 
188
216
  if req.status == 429
189
217
  return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
@@ -197,6 +225,9 @@ class Chat_content
197
225
  answer = "오류가 발생했습니다."
198
226
  end
199
227
 
228
+ # "생성 중..." 메시지 출력 종료
229
+ thread.kill
230
+
200
231
  puts 'API return ==> '
201
232
  puts answer
202
233
  answer
@@ -204,6 +235,7 @@ class Chat_content
204
235
  end
205
236
 
206
237
 
238
+
207
239
  #############################################gpt############################################
208
240
 
209
241
  class Naver
@@ -214,9 +246,13 @@ class Naver
214
246
  naver_cookie_dir = "C:/naver_cookie"
215
247
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
216
248
  if proxy == ''
217
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
249
+
250
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --no-first-run --no-default-browser-check --disable-sync})
251
+
218
252
  else
219
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" "https://naver.com/" --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s}})
253
+
254
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync})
255
+
220
256
  end
221
257
  end
222
258
  def chrome_start(proxy, user_id)
@@ -228,6 +264,9 @@ class Naver
228
264
  options = Selenium::WebDriver::Chrome::Options.new
229
265
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
230
266
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
267
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
268
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
269
+ options.add_argument('--no-default-browser-check')
231
270
  options.page_load_strategy = :normal
232
271
  options.timeouts = {page_load: 20_000}
233
272
  options.page_load_strategy = 'none'
@@ -253,6 +292,9 @@ class Naver
253
292
  options = Selenium::WebDriver::Chrome::Options.new
254
293
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
255
294
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
295
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
296
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
297
+ options.add_argument('--no-default-browser-check')
256
298
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
257
299
  options.page_load_strategy = :normal
258
300
  options.timeouts = {page_load: 20_000}
@@ -277,6 +319,9 @@ class Naver
277
319
  options = Selenium::WebDriver::Chrome::Options.new
278
320
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
279
321
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
322
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
323
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
324
+ options.add_argument('--no-default-browser-check')
280
325
  options.page_load_strategy = :normal
281
326
  options.timeouts = {page_load: 20_000}
282
327
  options.page_load_strategy = 'none'
@@ -302,6 +347,7 @@ class Naver
302
347
 
303
348
 
304
349
 
350
+
305
351
  def login(user_id, user_pw, proxy)
306
352
  @user_id = user_id
307
353
  @user_id11 = user_id
@@ -340,13 +386,21 @@ class Naver
340
386
  puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
341
387
  sleep(2.5)
342
388
  rescue
343
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
344
- #요소가 나타날 때까지 3초 동안 기다립니다.
345
- wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
346
- sleep(1.5)
347
- @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
348
- check_cookie_login = 0
349
- sleep(1)
389
+ begin
390
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
391
+ # 요소가 나타날 때까지 기다립니다.
392
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
393
+ sleep(1.5)
394
+
395
+ # 요소가 있으면 클릭
396
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
397
+ check_cookie_login = 0
398
+ sleep(1)
399
+ rescue
400
+
401
+ return 0
402
+ @driver.quit
403
+ end
350
404
  end
351
405
 
352
406
  if check_cookie_login == 0
@@ -381,8 +435,9 @@ class Naver
381
435
  puts "Failed to close tab: #{e.message}"
382
436
  end
383
437
  end
384
- return 0
385
438
  @driver.quit
439
+ return 0
440
+
386
441
  end
387
442
 
388
443
  else
@@ -405,8 +460,9 @@ class Naver
405
460
  puts "Failed to close tab: #{e.message}"
406
461
  end
407
462
  end
408
- return 0
409
463
  @driver.quit
464
+ return 0
465
+
410
466
  end
411
467
  end
412
468
 
@@ -1045,8 +1101,9 @@ end
1045
1101
  puts "Failed to close tab: #{e.message}"
1046
1102
  end
1047
1103
  end
1104
+ @driver.quit
1048
1105
  return 0
1049
- @driver.quit
1106
+
1050
1107
  end
1051
1108
 
1052
1109
 
@@ -1074,8 +1131,9 @@ end
1074
1131
  puts "Failed to close tab: #{e.message}"
1075
1132
  end
1076
1133
  end
1077
- return 0
1078
1134
  @driver.quit
1135
+ return 0
1136
+
1079
1137
  end
1080
1138
  sleep(2)
1081
1139
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -2609,7 +2667,15 @@ class Wordpress
2609
2667
  end
2610
2668
 
2611
2669
  if @data['포스트설정']['gpt제목'].checked?
2612
- chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2670
+ gpt_title_prompt = @data['포스트설정']['gpt제목_프롬프트'].text.to_s.force_encoding('utf-8')
2671
+
2672
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2673
+ gpt_title_prompt_sample = gpt_title_prompt.strip.empty? ? "프롬프트: 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘." : gpt_title_prompt
2674
+
2675
+ # gpt_title_prompt_sample을 Chat_title 객체에 전달
2676
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_title_prompt_sample)
2677
+
2678
+ # 메시지 요청 후 title에 저장
2613
2679
  gpt_text1 = chat.message(title)
2614
2680
  title = gpt_text1.to_s
2615
2681
  end
@@ -2654,18 +2720,16 @@ class Wordpress
2654
2720
 
2655
2721
 
2656
2722
  if @data['포스트설정']['gpt내용'].checked?
2723
+ gpt_content_prompt = @data['포스트설정']['gpt내용_프롬프트'].text.to_s.force_encoding('utf-8')
2657
2724
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2658
- #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
2659
- #imotcon_change = @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8')
2660
- #template_change = @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8')
2661
- #ttdanar_change = @data['포스트설정']['단어링크적용단어'].text.to_s.force_encoding('utf-8')
2662
- #sajine_change = @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8')
2663
- #mov_change = @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8')
2664
- #map_change = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8')
2665
- #inyong9_change = @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8')
2666
-
2667
2725
 
2668
- chat = Chat_content.new(api_key)
2726
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2727
+ gpt_content_prompt_sample = gpt_content_prompt.strip.empty? ? "프롬프트:ChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해" : gpt_content_prompt
2728
+
2729
+ # Chat_content 객체 생성 시 api_key와 gpt_content_prompt_sample을 두 개의 인자로 전달
2730
+ chat = Chat_content.new(api_key, gpt_content_prompt_sample)
2731
+
2732
+ # 메시지 요청 후 content에 저장
2669
2733
  gpt_text3 = chat.message(content)
2670
2734
  content = gpt_text3.to_s
2671
2735
  end
@@ -2869,13 +2933,17 @@ class Wordpress
2869
2933
  @data['table'] << []
2870
2934
  @data['table'].pop
2871
2935
  if @data['포스트설정']['gpt키워드'].checked?
2872
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2936
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2937
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2938
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2873
2939
  gpt_text = chat.message(keyword)
2874
- content = content + "\n(자동생성글)\n" + gpt_text
2940
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2941
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2875
2942
  elsif @data['포스트설정']['내용을자동생성'].checked?
2876
2943
  content = auto_text
2877
2944
  elsif @data['포스트설정']['내용과자동생성'].checked?
2878
- content = content + "\n(자동생성글)\n" + auto_text
2945
+ #content = content + "\n(자동생성글)\n" + auto_text
2946
+ content = content + "(자동생성글)" + auto_text
2879
2947
  end
2880
2948
 
2881
2949
  if @data['포스트설정']['내용키워드삽입'].checked?
@@ -2910,7 +2978,8 @@ class Wordpress
2910
2978
  end
2911
2979
 
2912
2980
  if @data['포스트설정']['내용을자동생성'].checked?
2913
- content2 = content.split("\n")
2981
+ #content2 = content.split("\n")
2982
+ content2 = content.split
2914
2983
  end
2915
2984
 
2916
2985
  if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
@@ -4039,423 +4108,439 @@ class Wordpress
4039
4108
  }
4040
4109
  }
4041
4110
  tab_item('내용설정'){
4111
+ horizontal_box{
4112
+ vertical_box{
4042
4113
  horizontal_box{
4043
- vertical_box{
4044
- horizontal_box{
4045
- stretchy false
4046
- button('키워드불러오기'){
4047
- on_clicked{
4048
- file = open_file
4049
- if file != nil
4050
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4051
- file_data.split("\n").each do |keyword|
4052
- if keyword.split(' ').join('').length < 2
4053
-
4054
- else
4055
- @data['키워드설정']['키워드'] << [false, keyword]
4056
- @data['키워드설정']['키워드'] << [false, keyword]
4057
- @data['키워드설정']['키워드'].pop
4058
- end
4059
- end
4060
- end
4061
-
4062
- }
4063
- }
4114
+ stretchy false
4115
+ button('키워드불러오기'){
4116
+ on_clicked{
4117
+ file = open_file
4118
+ if file != nil
4119
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4120
+ file_data.split("\n").each do |keyword|
4121
+ if keyword.split(' ').join('').length < 2
4064
4122
 
4065
- }
4066
- horizontal_box{
4067
- stretchy false
4068
- grid{
4069
- button('전체선택'){
4070
- top 1
4071
- left 1
4072
- on_clicked{
4073
- for n in 0..@data['키워드설정']['키워드'].length-1
4074
- @data['키워드설정']['키워드'][n][0] = true
4075
- @data['키워드설정']['키워드'] << []
4076
- @data['키워드설정']['키워드'].pop
4077
- end
4078
- }
4079
- }
4080
- button('선택해제'){
4081
- top 1
4082
- left 2
4083
- on_clicked{
4084
- for n in 0..@data['키워드설정']['키워드'].length-1
4085
- @data['키워드설정']['키워드'][n][0] = false
4086
- @data['키워드설정']['키워드'] << []
4123
+ else
4124
+ @data['키워드설정']['키워드'] << [false, keyword]
4125
+ @data['키워드설정']['키워드'] << [false, keyword]
4087
4126
  @data['키워드설정']['키워드'].pop
4088
4127
  end
4089
- }
4090
- }
4091
- button('삭제하기'){
4092
- top 1
4093
- left 3
4094
- on_clicked{
4095
- m = Array.new
4096
- for n in 0..@data['키워드설정']['키워드'].length-1
4097
- if @data['키워드설정']['키워드'][n][0] == true
4098
- m << n
4099
- end
4100
- end
4128
+ end
4129
+ end
4101
4130
 
4102
- m.reverse.each do |i|
4103
- @data['키워드설정']['키워드'].delete_at(i)
4104
- end
4105
- @data['키워드설정']['키워드'].delete(nil)
4106
- }
4107
- }
4108
4131
  }
4109
-
4110
- @data['키워드설정']['순서사용'] = checkbox('순서사용'){
4111
- stretchy false
4112
- on_toggled{ |c|
4113
- if c.checked?
4114
- @data['키워드설정']['랜덤사용'].checked = false
4115
- end
4116
- }
4117
- }
4118
- @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
4119
- stretchy false
4120
- on_toggled{ |c|
4121
- if c.checked?
4122
- @data['키워드설정']['순서사용'].checked = false
4123
- end
4124
- }
4125
- }
4132
+ }
4133
+
4134
+ }
4135
+ horizontal_box{
4136
+ stretchy false
4137
+ grid{
4138
+ button('전체선택'){
4139
+ top 1
4140
+ left 1
4141
+ on_clicked{
4142
+ for n in 0..@data['키워드설정']['키워드'].length-1
4143
+ @data['키워드설정']['키워드'][n][0] = true
4144
+ @data['키워드설정']['키워드'] << []
4145
+ @data['키워드설정']['키워드'].pop
4146
+ end
4126
4147
  }
4127
- vertical_separator{
4128
- stretchy false
4148
+ }
4149
+ button('선택해제'){
4150
+ top 1
4151
+ left 2
4152
+ on_clicked{
4153
+ for n in 0..@data['키워드설정']['키워드'].length-1
4154
+ @data['키워드설정']['키워드'][n][0] = false
4155
+ @data['키워드설정']['키워드'] << []
4156
+ @data['키워드설정']['키워드'].pop
4157
+ end
4129
4158
  }
4130
- horizontal_box{
4131
- stretchy false
4132
- grid{
4133
- @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
4134
- top 1
4135
- left 0
4136
- #enabled false # 기본적으로 비활성화
4137
- on_toggled {
4138
- if @data['포스트설정']['gpt키워드'].checked?
4139
- @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
4140
- @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
4141
- else
4142
- @data['포스트설정']['gpt상단'].checked = false # 체크 해제
4143
- @data['포스트설정']['gpt상단'].enabled = false # 비활성화
4144
- @data['포스트설정']['gpt하단'].checked = false # 체크 해제
4145
- @data['포스트설정']['gpt하단'].enabled = false # 비활성화
4146
- end
4147
- }
4148
-
4149
- }
4150
-
4151
- @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
4152
- top 1
4153
- left 1
4154
- enabled false # 기본적으로 비활성화
4155
- on_toggled{
4156
- if @data['포스트설정']['gpt상단'].checked?
4157
- @data['포스트설정']['gpt하단'].checked = false
4158
- end
4159
- }
4160
- }
4161
-
4162
- @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
4163
- top 1
4164
- left 2
4165
- enabled false # 기본적으로 비활성화
4166
- on_toggled{
4167
- if @data['포스트설정']['gpt하단'].checked?
4168
- @data['포스트설정']['gpt상단'].checked = false
4159
+ }
4160
+ button('삭제하기'){
4161
+ top 1
4162
+ left 3
4163
+ on_clicked{
4164
+ m = Array.new
4165
+ for n in 0..@data['키워드설정']['키워드'].length-1
4166
+ if @data['키워드설정']['키워드'][n][0] == true
4167
+ m << n
4169
4168
  end
4170
- }
4171
- }
4172
- } }
4173
- horizontal_box{
4174
- stretchy false
4175
- grid{
4176
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4177
- } } }
4178
-
4179
-
4180
- table{
4181
- checkbox_column('선택'){
4182
- editable true
4183
- }
4184
- text_column('키워드'){
4185
-
4186
- }
4169
+ end
4187
4170
 
4188
- cell_rows @data['키워드설정']['키워드']
4171
+ m.reverse.each do |i|
4172
+ @data['키워드설정']['키워드'].delete_at(i)
4173
+ end
4174
+ @data['키워드설정']['키워드'].delete(nil)
4189
4175
  }
4190
-
4191
-
4192
-
4193
4176
  }
4194
- vertical_separator{
4177
+ }
4178
+
4179
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
4195
4180
  stretchy false
4181
+ on_toggled{ |c|
4182
+ if c.checked?
4183
+ @data['키워드설정']['랜덤사용'].checked = false
4184
+ end
4185
+ }
4186
+ }
4187
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
4188
+ stretchy false
4189
+ on_toggled{ |c|
4190
+ if c.checked?
4191
+ @data['키워드설정']['순서사용'].checked = false
4192
+ end
4193
+ }
4194
+ }
4195
+ }
4196
+ vertical_separator{
4197
+ stretchy false
4198
+ }
4199
+ horizontal_box{
4200
+ stretchy false
4201
+ grid{
4202
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
4203
+ top 1
4204
+ left 0
4205
+ #enabled false # 기본적으로 비활성화
4206
+ on_toggled {
4207
+ if @data['포스트설정']['gpt키워드'].checked?
4208
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
4209
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
4210
+ else
4211
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
4212
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
4213
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
4214
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
4215
+ end
4216
+ }
4217
+
4218
+ }
4219
+
4220
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
4221
+ top 1
4222
+ left 1
4223
+ enabled false # 기본적으로 비활성화
4224
+ on_toggled{
4225
+ if @data['포스트설정']['gpt상단'].checked?
4226
+ @data['포스트설정']['gpt하단'].checked = false
4227
+ end
4228
+ }
4196
4229
  }
4197
- vertical_box{
4198
- horizontal_box{
4199
- stretchy false
4200
- button('제목불러오기'){
4201
- on_clicked{
4202
- file = open_file
4203
- if file != nil
4204
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4205
- file_data.split("\n").each do |title|
4206
- if title.split(" ").join('').length < 2
4207
-
4208
- else
4209
- @data['제목설정']['제목'] << [false, title]
4210
- @data['제목설정']['제목'] << [false, title]
4211
- @data['제목설정']['제목'].pop
4212
- end
4213
- end
4214
- end
4215
- }
4216
- }
4217
4230
 
4231
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
4232
+ top 1
4233
+ left 2
4234
+ enabled false # 기본적으로 비활성화
4235
+ on_toggled{
4236
+ if @data['포스트설정']['gpt하단'].checked?
4237
+ @data['포스트설정']['gpt상단'].checked = false
4238
+ end
4218
4239
  }
4219
- horizontal_box{
4220
- stretchy false
4221
- grid{
4222
- button('전체선택'){
4223
- top 1
4224
- left 1
4225
- on_clicked{
4226
- for n in 0..@data['제목설정']['제목'].length-1
4227
- @data['제목설정']['제목'][n][0] = true
4228
- @data['제목설정']['제목'] << []
4229
- @data['제목설정']['제목'].pop
4230
- end
4231
- }
4232
- }
4233
- button('선택해제'){
4234
- top 1
4235
- left 2
4236
- on_clicked{
4237
- for n in 0..@data['제목설정']['제목'].length-1
4238
- @data['제목설정']['제목'][n][0] = false
4239
- @data['제목설정']['제목'] << []
4240
+ }
4241
+ } }
4242
+ horizontal_box{
4243
+ stretchy false
4244
+ @data['포스트설정']['gpt키워드_프롬프트'] = entry(){
4245
+ text '프롬프트:관련 글을 1500자에서 2500자 사이로 만들어줘'
4246
+ }}
4247
+ horizontal_box{
4248
+ stretchy false
4249
+ grid{
4250
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4251
+ } } }
4252
+
4253
+
4254
+ table{
4255
+ checkbox_column('선택'){
4256
+ editable true
4257
+ }
4258
+ text_column('키워드'){
4259
+
4260
+ }
4261
+
4262
+ cell_rows @data['키워드설정']['키워드']
4263
+ }
4264
+
4265
+
4266
+
4267
+ }
4268
+ vertical_separator{
4269
+ stretchy false
4270
+ }
4271
+ vertical_box{
4272
+ horizontal_box{
4273
+ stretchy false
4274
+ button('제목불러오기'){
4275
+ on_clicked{
4276
+ file = open_file
4277
+ if file != nil
4278
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4279
+ file_data.split("\n").each do |title|
4280
+ if title.split(" ").join('').length < 2
4281
+
4282
+ else
4283
+ @data['제목설정']['제목'] << [false, title]
4284
+ @data['제목설정']['제목'] << [false, title]
4240
4285
  @data['제목설정']['제목'].pop
4241
4286
  end
4242
- }
4243
- }
4244
- button('삭제하기'){
4245
- top 1
4246
- left 3
4247
- on_clicked{
4248
- m = Array.new
4249
- for n in 0..@data['제목설정']['제목'].length-1
4250
- if @data['제목설정']['제목'][n][0] == true
4251
- m << n
4252
- end
4253
- end
4287
+ end
4288
+ end
4289
+ }
4290
+ }
4254
4291
 
4255
- m.reverse.each do |i|
4256
- @data['제목설정']['제목'].delete_at(i)
4257
- end
4258
- @data['제목설정']['제목'].delete(nil)
4259
- }
4260
- }
4292
+ }
4293
+ horizontal_box{
4294
+ stretchy false
4295
+ grid{
4296
+ button('전체선택'){
4297
+ top 1
4298
+ left 1
4299
+ on_clicked{
4300
+ for n in 0..@data['제목설정']['제목'].length-1
4301
+ @data['제목설정']['제목'][n][0] = true
4302
+ @data['제목설정']['제목'] << []
4303
+ @data['제목설정']['제목'].pop
4304
+ end
4261
4305
  }
4262
- @data['제목설정']['순서사용'] = checkbox('순서사용'){
4263
- stretchy false
4264
- on_toggled{ |c|
4265
- if c.checked?
4266
- @data['제목설정']['랜덤사용'].checked = false
4267
- end
4268
- }
4269
- }
4270
- @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
4271
- stretchy false
4272
- on_toggled{ |c|
4273
- if c.checked?
4274
- @data['제목설정']['순서사용'].checked = false
4275
- end
4276
- }
4277
- }
4306
+ }
4307
+ button('선택해제'){
4308
+ top 1
4309
+ left 2
4310
+ on_clicked{
4311
+ for n in 0..@data['제목설정']['제목'].length-1
4312
+ @data['제목설정']['제목'][n][0] = false
4313
+ @data['제목설정']['제목'] << []
4314
+ @data['제목설정']['제목'].pop
4315
+ end
4278
4316
  }
4279
- vertical_separator{
4280
- stretchy false
4317
+ }
4318
+ button('삭제하기'){
4319
+ top 1
4320
+ left 3
4321
+ on_clicked{
4322
+ m = Array.new
4323
+ for n in 0..@data['제목설정']['제목'].length-1
4324
+ if @data['제목설정']['제목'][n][0] == true
4325
+ m << n
4326
+ end
4327
+ end
4328
+
4329
+ m.reverse.each do |i|
4330
+ @data['제목설정']['제목'].delete_at(i)
4331
+ end
4332
+ @data['제목설정']['제목'].delete(nil)
4281
4333
  }
4282
- horizontal_box{
4283
- stretchy false
4284
- grid{
4285
- @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
4286
-
4287
-
4288
- }}}
4289
- horizontal_box{
4290
- stretchy false
4291
- grid{
4292
- label(' GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4293
- } } }
4294
-
4334
+ }
4335
+ }
4336
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
4337
+ stretchy false
4338
+ on_toggled{ |c|
4339
+ if c.checked?
4340
+ @data['제목설정']['랜덤사용'].checked = false
4341
+ end
4342
+ }
4343
+ }
4344
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
4345
+ stretchy false
4346
+ on_toggled{ |c|
4347
+ if c.checked?
4348
+ @data['제목설정']['순서사용'].checked = false
4349
+ end
4350
+ }
4351
+ }
4352
+ }
4353
+ vertical_separator{
4354
+ stretchy false
4355
+ }
4356
+ horizontal_box{
4357
+ stretchy false
4358
+ grid{
4359
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
4360
+
4361
+
4362
+ }}}
4363
+ horizontal_box{
4364
+ stretchy false
4365
+ @data['포스트설정']['gpt제목_프롬프트'] = entry(){
4366
+ text '프롬프트:비슷한 길이로 제목으로 사용할수있게 하나만 만들어줘'
4367
+ }}
4368
+ horizontal_box{
4369
+ stretchy false
4370
+ grid{
4371
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4372
+ } } }
4373
+
4295
4374
 
4296
- table{
4297
- checkbox_column('선택'){
4298
- editable true
4299
- }
4300
- text_column('제목'){
4375
+ table{
4376
+ checkbox_column('선택'){
4377
+ editable true
4378
+ }
4379
+ text_column('제목'){
4301
4380
 
4302
- }
4381
+ }
4303
4382
 
4304
- cell_rows @data['제목설정']['제목']
4305
- }
4306
-
4383
+ cell_rows @data['제목설정']['제목']
4384
+ }
4385
+
4307
4386
 
4387
+ }
4388
+ vertical_separator{
4389
+ stretchy false
4390
+ }
4391
+ vertical_box{
4392
+ horizontal_box{
4393
+ stretchy false
4394
+ button('내용불러오기'){
4395
+ on_clicked{
4396
+ file = open_file
4397
+ if file != nil
4398
+ file_name = file.split("\\")[-1]
4399
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
4400
+ if file_data.split("\n").length < 2
4401
+ file_data = file_data + "\n"
4402
+ end
4403
+ @data['내용설정']['내용'] << [false, file_name, file_data]
4404
+ @data['내용설정']['내용'] << [false, file_name, file_data]
4405
+ @data['내용설정']['내용'].pop
4406
+ end
4407
+ }
4308
4408
  }
4309
- vertical_separator{
4310
- stretchy false
4311
- }
4312
- vertical_box{
4313
- horizontal_box{
4314
- stretchy false
4315
- button('내용불러오기'){
4316
- on_clicked{
4317
- file = open_file
4318
- if file != nil
4319
- file_name = file.split("\\")[-1]
4320
- file_data = File.open(file,'r', :encoding => 'utf-8').read()
4321
- if file_data.split("\n").length < 2
4322
- file_data = file_data + "\n"
4323
- end
4324
- @data['내용설정']['내용'] << [false, file_name, file_data]
4325
- @data['내용설정']['내용'] << [false, file_name, file_data]
4326
- @data['내용설정']['내용'].pop
4327
- end
4328
- }
4329
- }
4330
4409
 
4410
+ }
4411
+ horizontal_box{
4412
+ stretchy false
4413
+ grid{
4414
+ button('전체선택'){
4415
+ top 1
4416
+ left 1
4417
+ on_clicked{
4418
+ for n in 0..@data['내용설정']['내용'].length-1
4419
+ @data['내용설정']['내용'][n][0] = true
4420
+ @data['내용설정']['내용'] << []
4421
+ @data['내용설정']['내용'].pop
4422
+ end
4331
4423
  }
4332
- horizontal_box{
4333
- stretchy false
4334
- grid{
4335
- button('전체선택'){
4336
- top 1
4337
- left 1
4338
- on_clicked{
4339
- for n in 0..@data['내용설정']['내용'].length-1
4340
- @data['내용설정']['내용'][n][0] = true
4341
- @data['내용설정']['내용'] << []
4342
- @data['내용설정']['내용'].pop
4343
- end
4344
- }
4345
- }
4346
- button('선택해제'){
4347
- top 1
4348
- left 2
4349
- on_clicked{
4350
- for n in 0..@data['내용설정']['내용'].length-1
4351
- @data['내용설정']['내용'][n][0] = false
4352
- @data['내용설정']['내용'] << []
4353
- @data['내용설정']['내용'].pop
4354
- end
4355
- }
4356
- }
4357
- button('삭제하기'){
4358
- top 1
4359
- left 3
4360
- on_clicked{
4361
- m = Array.new
4362
- for n in 0..@data['내용설정']['내용'].length-1
4363
- if @data['내용설정']['내용'][n][0] == true
4364
- m << n
4365
- end
4366
- end
4424
+ }
4425
+ button('선택해제'){
4426
+ top 1
4427
+ left 2
4428
+ on_clicked{
4429
+ for n in 0..@data['내용설정']['내용'].length-1
4430
+ @data['내용설정']['내용'][n][0] = false
4431
+ @data['내용설정']['내용'] << []
4432
+ @data['내용설정']['내용'].pop
4433
+ end
4434
+ }
4435
+ }
4436
+ button('삭제하기'){
4437
+ top 1
4438
+ left 3
4439
+ on_clicked{
4440
+ m = Array.new
4441
+ for n in 0..@data['내용설정']['내용'].length-1
4442
+ if @data['내용설정']['내용'][n][0] == true
4443
+ m << n
4444
+ end
4445
+ end
4367
4446
 
4368
- m.reverse.each do |i|
4369
- @data['내용설정']['내용'].delete_at(i)
4370
- end
4371
- @data['내용설정']['내용'].delete(nil)
4372
- }
4373
- }
4447
+ m.reverse.each do |i|
4448
+ @data['내용설정']['내용'].delete_at(i)
4449
+ end
4450
+ @data['내용설정']['내용'].delete(nil)
4374
4451
  }
4375
- @data['내용설정']['순서사용'] = checkbox('순서사용'){
4376
- stretchy false
4377
- on_toggled{ |c|
4378
- if c.checked?
4379
- @data['내용설정']['랜덤사용'].checked = false
4380
- end
4381
- }
4382
- }
4383
- @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4384
- stretchy false
4385
- on_toggled{ |c|
4386
- if c.checked?
4387
- @data['내용설정']['순서사용'].checked = false
4388
- end
4389
- }
4390
- }
4452
+ }
4453
+ }
4454
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
4455
+ stretchy false
4456
+ on_toggled{ |c|
4457
+ if c.checked?
4458
+ @data['내용설정']['랜덤사용'].checked = false
4459
+ end
4391
4460
  }
4392
- vertical_separator{
4393
- stretchy false
4461
+ }
4462
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4463
+ stretchy false
4464
+ on_toggled{ |c|
4465
+ if c.checked?
4466
+ @data['내용설정']['순서사용'].checked = false
4467
+ end
4394
4468
  }
4395
- horizontal_box{
4396
- stretchy false
4397
- grid{
4398
- @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4399
-
4400
-
4401
- }}}
4402
- horizontal_box{
4403
- stretchy false
4404
- grid{
4405
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4406
- } } }
4407
-
4408
- table{
4409
- checkbox_column('선택'){
4410
- editable true
4411
- }
4412
- text_column('내용파일'){
4469
+ }
4470
+ }
4471
+ vertical_separator{
4472
+ stretchy false
4473
+ }
4474
+ horizontal_box{
4475
+ stretchy false
4476
+ grid{
4477
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4478
+
4479
+
4480
+ }}}
4481
+ horizontal_box{
4482
+ stretchy false
4483
+ @data['포스트설정']['gpt내용_프롬프트'] = entry(){
4484
+ text '프롬프트:동의어,유사어를 이용해 변경해줘'
4485
+ }}
4486
+ horizontal_box{
4487
+ stretchy false
4488
+ grid{
4489
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4490
+ } } }
4491
+
4492
+ table{
4493
+ checkbox_column('선택'){
4494
+ editable true
4495
+ }
4496
+ text_column('내용파일'){
4413
4497
 
4414
- }
4498
+ }
4415
4499
 
4416
- cell_rows @data['내용설정']['내용']
4417
- }
4500
+ cell_rows @data['내용설정']['내용']
4501
+ }
4418
4502
 
4419
- horizontal_box{
4420
- stretchy false
4421
- @data['이미지설정']['폴더경로2'] = entry{
4422
- stretchy false
4423
- text "내용폴더경로 ex)C:\\내용\\폴더1"
4424
- }
4425
- button('폴더째로 불러오기') {
4426
- on_clicked {
4427
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4503
+ horizontal_box{
4504
+ stretchy false
4505
+ @data['이미지설정']['폴더경로2'] = entry{
4506
+ stretchy false
4507
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
4508
+ }
4428
4509
 
4429
- # 경로가 유효한지 확인
4430
- if Dir.exist?(path)
4431
- Dir.entries(path).each do |file|
4432
- if file == '.' or file == '..'
4433
- next
4434
- else
4435
- begin
4436
- # 파일을 열고 내용을 읽어서 추가
4437
- file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4438
- @data['내용설정']['내용'] << [false, file, file_data]
4439
- rescue => e
4440
- # 파일을 열 수 없는 경우, 오류 메시지 출력
4441
- puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4442
- end
4443
- end
4444
- end
4510
+ button('폴더째로 불러오기') {
4511
+ on_clicked {
4512
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4445
4513
 
4446
- # 내용 배열에서 마지막 빈 항목 제거
4447
- @data['내용설정']['내용'] << []
4448
- @data['내용설정']['내용'].pop
4514
+ # 경로가 유효한지 확인
4515
+ if Dir.exist?(path)
4516
+ Dir.entries(path).each do |file|
4517
+ if file == '.' or file == '..'
4518
+ next
4449
4519
  else
4450
- # 경로가 유효하지 않을 경우, 오류 메시지 출력
4451
- puts "경로가 존재하지 않습니다: #{path}"
4520
+ begin
4521
+ # 파일을 열고 내용을 읽어서 추가
4522
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4523
+ @data['내용설정']['내용'] << [false, file, file_data]
4524
+ rescue => e
4525
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4526
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4527
+ end
4452
4528
  end
4453
- }
4454
- }
4529
+ end
4530
+
4531
+ # 내용 배열에서 마지막 빈 항목 제거
4532
+ @data['내용설정']['내용'] << []
4533
+ @data['내용설정']['내용'].pop
4534
+ else
4535
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4536
+ puts "경로가 존재하지 않습니다: #{path}"
4537
+ end
4455
4538
  }
4456
4539
  }
4457
4540
  }
4458
4541
  }
4542
+ }
4543
+ }
4459
4544
  tab_item('이미지설정'){
4460
4545
  horizontal_box{
4461
4546
  vertical_box{
@@ -4929,7 +5014,7 @@ class Wordpress
4929
5014
  left 1
4930
5015
  text 'URL'
4931
5016
  }
4932
- @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 생성으로만 등록(GPT사용시 자체 생성)'){
5017
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 글만 등록(GPT사용시 체크 해제)'){
4933
5018
  top 9
4934
5019
  left 0
4935
5020
  on_toggled{
@@ -4937,31 +5022,46 @@ class Wordpress
4937
5022
  @data['포스트설정']['내용과자동생성'].checked = false
4938
5023
  @data['포스트설정']['내용투명'].checked = false
4939
5024
  @data['포스트설정']['자동글 수식에 입력'].checked = false
4940
-
5025
+
4941
5026
  end
4942
5027
  }
4943
5028
  }
4944
-
5029
+ label('※GPT사용시 내용설정 탭에서 설정'){
5030
+ top 9
5031
+ left 1
5032
+ }
5033
+
5034
+ label('※GPT 미 사용시 세팅 권장'){
5035
+ top 9
5036
+ left 3
5037
+ }
4945
5038
 
4946
-
4947
-
5039
+
4948
5040
  aa1 = 2
4949
- @data['포스트설정']['내용과자동생성'] = checkbox('내용파일+키워드기반 생성 등록(GPT사용시 자체 생성)') {
5041
+ @data['포스트설정']['내용과자동생성'] = checkbox('원고+키워드기반 등록(GPT사용시 체크 해제)') {
4950
5042
  top 10 + aa1
4951
5043
  left 0
4952
5044
  on_toggled {
4953
- if @data['포스트설정']['내용과자동생성'].checked?
5045
+ if @data['포스트설정']['내용과자동생성'].checked?
4954
5046
  @data['포스트설정']['내용을자동생성'].checked = false
4955
5047
  @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4956
5048
  @data['포스트설정']['자동글 수식에 입력'].enabled = true # '내용투명' 활성화
4957
- else
5049
+ else
4958
5050
  @data['포스트설정']['내용투명'].checked = false # 체크 해제
4959
5051
  @data['포스트설정']['내용투명'].enabled = false # 비활성화
4960
5052
  @data['포스트설정']['자동글 수식에 입력'].checked = false # 체크 해제
4961
5053
  @data['포스트설정']['자동글 수식에 입력'].enabled = false # 비활성화
4962
- end
5054
+ end
4963
5055
  }
4964
- }
5056
+ }
5057
+ label('※GPT사용시 내용설정 탭에서 설정'){
5058
+ top 10 + aa1
5059
+ left 1
5060
+ }
5061
+ label('※GPT 미 사용시 세팅 권장'){
5062
+ top 10 + aa1
5063
+ left 3
5064
+ }
4965
5065
 
4966
5066
  @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4967
5067
  top 11 + aa1