cafe_basics_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_basics_duo.rb +583 -484
  3. metadata +2 -2
@@ -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,20 @@ 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
+ @driver.quit
401
+ return 0
402
+ end
350
403
  end
351
404
 
352
405
  if check_cookie_login == 0
@@ -381,8 +434,9 @@ class Naver
381
434
  puts "Failed to close tab: #{e.message}"
382
435
  end
383
436
  end
384
- return 0
385
437
  @driver.quit
438
+ return 0
439
+
386
440
  end
387
441
 
388
442
  else
@@ -405,8 +459,9 @@ class Naver
405
459
  puts "Failed to close tab: #{e.message}"
406
460
  end
407
461
  end
408
- return 0
409
462
  @driver.quit
463
+ return 0
464
+
410
465
  end
411
466
  end
412
467
 
@@ -732,8 +787,9 @@ class Naver
732
787
  puts "Failed to close tab: #{e.message}"
733
788
  end
734
789
  end
735
- return 0
736
- @driver.quit
790
+ @driver.quit
791
+ return 0
792
+
737
793
  end
738
794
 
739
795
 
@@ -761,8 +817,9 @@ class Naver
761
817
  puts "Failed to close tab: #{e.message}"
762
818
  end
763
819
  end
764
- return 0
765
820
  @driver.quit
821
+ return 0
822
+
766
823
  end
767
824
  sleep(2)
768
825
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -2279,7 +2336,15 @@ class Wordpress
2279
2336
  end
2280
2337
 
2281
2338
  if @data['포스트설정']['gpt제목'].checked?
2282
- chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2339
+ gpt_title_prompt = @data['포스트설정']['gpt제목_프롬프트'].text.to_s.force_encoding('utf-8')
2340
+
2341
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2342
+ gpt_title_prompt_sample = gpt_title_prompt.strip.empty? ? "프롬프트: 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘." : gpt_title_prompt
2343
+
2344
+ # gpt_title_prompt_sample을 Chat_title 객체에 전달
2345
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_title_prompt_sample)
2346
+
2347
+ # 메시지 요청 후 title에 저장
2283
2348
  gpt_text1 = chat.message(title)
2284
2349
  title = gpt_text1.to_s
2285
2350
  end
@@ -2324,18 +2389,16 @@ class Wordpress
2324
2389
 
2325
2390
 
2326
2391
  if @data['포스트설정']['gpt내용'].checked?
2392
+ gpt_content_prompt = @data['포스트설정']['gpt내용_프롬프트'].text.to_s.force_encoding('utf-8')
2327
2393
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2328
- #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
2329
- #imotcon_change = @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8')
2330
- #template_change = @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8')
2331
- #ttdanar_change = @data['포스트설정']['단어링크적용단어'].text.to_s.force_encoding('utf-8')
2332
- #sajine_change = @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8')
2333
- #mov_change = @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8')
2334
- #map_change = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8')
2335
- #inyong9_change = @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8')
2336
-
2337
2394
 
2338
- chat = Chat_content.new(api_key)
2395
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2396
+ gpt_content_prompt_sample = gpt_content_prompt.strip.empty? ? "프롬프트:ChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해" : gpt_content_prompt
2397
+
2398
+ # Chat_content 객체 생성 시 api_key와 gpt_content_prompt_sample을 두 개의 인자로 전달
2399
+ chat = Chat_content.new(api_key, gpt_content_prompt_sample)
2400
+
2401
+ # 메시지 요청 후 content에 저장
2339
2402
  gpt_text3 = chat.message(content)
2340
2403
  content = gpt_text3.to_s
2341
2404
  end
@@ -2539,13 +2602,17 @@ class Wordpress
2539
2602
  @data['table'] << []
2540
2603
  @data['table'].pop
2541
2604
  if @data['포스트설정']['gpt키워드'].checked?
2542
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2605
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2606
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2607
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2543
2608
  gpt_text = chat.message(keyword)
2544
- content = content + "\n(자동생성글)\n" + gpt_text
2609
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2610
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2545
2611
  elsif @data['포스트설정']['내용을자동생성'].checked?
2546
2612
  content = auto_text
2547
2613
  elsif @data['포스트설정']['내용과자동생성'].checked?
2548
- content = content + "\n(자동생성글)\n" + auto_text
2614
+ #content = content + "\n(자동생성글)\n" + auto_text
2615
+ content = content + "(자동생성글)" + auto_text
2549
2616
  end
2550
2617
 
2551
2618
  if @data['포스트설정']['내용키워드삽입'].checked?
@@ -2580,7 +2647,8 @@ class Wordpress
2580
2647
  end
2581
2648
 
2582
2649
  if @data['포스트설정']['내용을자동생성'].checked?
2583
- content2 = content.split("\n")
2650
+ #content2 = content.split("\n")
2651
+ content2 = content.split
2584
2652
  end
2585
2653
 
2586
2654
  if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
@@ -3708,423 +3776,439 @@ class Wordpress
3708
3776
  }
3709
3777
  }
3710
3778
  tab_item('내용설정'){
3779
+ horizontal_box{
3780
+ vertical_box{
3711
3781
  horizontal_box{
3712
- vertical_box{
3713
- horizontal_box{
3714
- stretchy false
3715
- button('키워드불러오기'){
3716
- on_clicked{
3717
- file = open_file
3718
- if file != nil
3719
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3720
- file_data.split("\n").each do |keyword|
3721
- if keyword.split(' ').join('').length < 2
3722
-
3723
- else
3724
- @data['키워드설정']['키워드'] << [false, keyword]
3725
- @data['키워드설정']['키워드'] << [false, keyword]
3726
- @data['키워드설정']['키워드'].pop
3727
- end
3728
- end
3729
- end
3782
+ stretchy false
3783
+ button('키워드불러오기'){
3784
+ on_clicked{
3785
+ file = open_file
3786
+ if file != nil
3787
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3788
+ file_data.split("\n").each do |keyword|
3789
+ if keyword.split(' ').join('').length < 2
3730
3790
 
3731
- }
3732
- }
3733
-
3734
- }
3735
- horizontal_box{
3736
- stretchy false
3737
- grid{
3738
- button('전체선택'){
3739
- top 1
3740
- left 1
3741
- on_clicked{
3742
- for n in 0..@data['키워드설정']['키워드'].length-1
3743
- @data['키워드설정']['키워드'][n][0] = true
3744
- @data['키워드설정']['키워드'] << []
3745
- @data['키워드설정']['키워드'].pop
3746
- end
3747
- }
3748
- }
3749
- button('선택해제'){
3750
- top 1
3751
- left 2
3752
- on_clicked{
3753
- for n in 0..@data['키워드설정']['키워드'].length-1
3754
- @data['키워드설정']['키워드'][n][0] = false
3755
- @data['키워드설정']['키워드'] << []
3791
+ else
3792
+ @data['키워드설정']['키워드'] << [false, keyword]
3793
+ @data['키워드설정']['키워드'] << [false, keyword]
3756
3794
  @data['키워드설정']['키워드'].pop
3757
3795
  end
3758
- }
3759
- }
3760
- button('삭제하기'){
3761
- top 1
3762
- left 3
3763
- on_clicked{
3764
- m = Array.new
3765
- for n in 0..@data['키워드설정']['키워드'].length-1
3766
- if @data['키워드설정']['키워드'][n][0] == true
3767
- m << n
3768
- end
3769
- end
3796
+ end
3797
+ end
3770
3798
 
3771
- m.reverse.each do |i|
3772
- @data['키워드설정']['키워드'].delete_at(i)
3773
- end
3774
- @data['키워드설정']['키워드'].delete(nil)
3775
- }
3776
- }
3777
3799
  }
3778
-
3779
- @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3780
- stretchy false
3781
- on_toggled{ |c|
3782
- if c.checked?
3783
- @data['키워드설정']['랜덤사용'].checked = false
3784
- end
3785
- }
3786
- }
3787
- @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
3788
- stretchy false
3789
- on_toggled{ |c|
3790
- if c.checked?
3791
- @data['키워드설정']['순서사용'].checked = false
3792
- end
3793
- }
3794
- }
3800
+ }
3801
+
3802
+ }
3803
+ horizontal_box{
3804
+ stretchy false
3805
+ grid{
3806
+ button('전체선택'){
3807
+ top 1
3808
+ left 1
3809
+ on_clicked{
3810
+ for n in 0..@data['키워드설정']['키워드'].length-1
3811
+ @data['키워드설정']['키워드'][n][0] = true
3812
+ @data['키워드설정']['키워드'] << []
3813
+ @data['키워드설정']['키워드'].pop
3814
+ end
3795
3815
  }
3796
- vertical_separator{
3797
- stretchy false
3816
+ }
3817
+ button('선택해제'){
3818
+ top 1
3819
+ left 2
3820
+ on_clicked{
3821
+ for n in 0..@data['키워드설정']['키워드'].length-1
3822
+ @data['키워드설정']['키워드'][n][0] = false
3823
+ @data['키워드설정']['키워드'] << []
3824
+ @data['키워드설정']['키워드'].pop
3825
+ end
3798
3826
  }
3799
- horizontal_box{
3800
- stretchy false
3801
- grid{
3802
- @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3803
- top 1
3804
- left 0
3805
- #enabled false # 기본적으로 비활성화
3806
- on_toggled {
3807
- if @data['포스트설정']['gpt키워드'].checked?
3808
- @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3809
- @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3810
- else
3811
- @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3812
- @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3813
- @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3814
- @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3815
- end
3816
- }
3817
-
3818
- }
3819
-
3820
- @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3821
- top 1
3822
- left 1
3823
- enabled false # 기본적으로 비활성화
3824
- on_toggled{
3825
- if @data['포스트설정']['gpt상단'].checked?
3826
- @data['포스트설정']['gpt하단'].checked = false
3827
- end
3828
- }
3829
- }
3830
-
3831
- @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3832
- top 1
3833
- left 2
3834
- enabled false # 기본적으로 비활성화
3835
- on_toggled{
3836
- if @data['포스트설정']['gpt하단'].checked?
3837
- @data['포스트설정']['gpt상단'].checked = false
3827
+ }
3828
+ button('삭제하기'){
3829
+ top 1
3830
+ left 3
3831
+ on_clicked{
3832
+ m = Array.new
3833
+ for n in 0..@data['키워드설정']['키워드'].length-1
3834
+ if @data['키워드설정']['키워드'][n][0] == true
3835
+ m << n
3838
3836
  end
3839
- }
3840
- }
3841
- } }
3842
- horizontal_box{
3843
- stretchy false
3844
- grid{
3845
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3846
- } } }
3847
-
3848
-
3849
- table{
3850
- checkbox_column('선택'){
3851
- editable true
3852
- }
3853
- text_column('키워드'){
3854
-
3855
- }
3837
+ end
3856
3838
 
3857
- cell_rows @data['키워드설정']['키워드']
3839
+ m.reverse.each do |i|
3840
+ @data['키워드설정']['키워드'].delete_at(i)
3841
+ end
3842
+ @data['키워드설정']['키워드'].delete(nil)
3858
3843
  }
3859
-
3860
-
3861
-
3862
3844
  }
3863
- vertical_separator{
3845
+ }
3846
+
3847
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3864
3848
  stretchy false
3849
+ on_toggled{ |c|
3850
+ if c.checked?
3851
+ @data['키워드설정']['랜덤사용'].checked = false
3852
+ end
3853
+ }
3854
+ }
3855
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
3856
+ stretchy false
3857
+ on_toggled{ |c|
3858
+ if c.checked?
3859
+ @data['키워드설정']['순서사용'].checked = false
3860
+ end
3861
+ }
3862
+ }
3863
+ }
3864
+ vertical_separator{
3865
+ stretchy false
3866
+ }
3867
+ horizontal_box{
3868
+ stretchy false
3869
+ grid{
3870
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3871
+ top 1
3872
+ left 0
3873
+ #enabled false # 기본적으로 비활성화
3874
+ on_toggled {
3875
+ if @data['포스트설정']['gpt키워드'].checked?
3876
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3877
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3878
+ else
3879
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3880
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3881
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3882
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3883
+ end
3884
+ }
3885
+
3886
+ }
3887
+
3888
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3889
+ top 1
3890
+ left 1
3891
+ enabled false # 기본적으로 비활성화
3892
+ on_toggled{
3893
+ if @data['포스트설정']['gpt상단'].checked?
3894
+ @data['포스트설정']['gpt하단'].checked = false
3895
+ end
3896
+ }
3865
3897
  }
3866
- vertical_box{
3867
- horizontal_box{
3868
- stretchy false
3869
- button('제목불러오기'){
3870
- on_clicked{
3871
- file = open_file
3872
- if file != nil
3873
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3874
- file_data.split("\n").each do |title|
3875
- if title.split(" ").join('').length < 2
3876
-
3877
- else
3878
- @data['제목설정']['제목'] << [false, title]
3879
- @data['제목설정']['제목'] << [false, title]
3880
- @data['제목설정']['제목'].pop
3881
- end
3882
- end
3883
- end
3884
- }
3885
- }
3886
3898
 
3899
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3900
+ top 1
3901
+ left 2
3902
+ enabled false # 기본적으로 비활성화
3903
+ on_toggled{
3904
+ if @data['포스트설정']['gpt하단'].checked?
3905
+ @data['포스트설정']['gpt상단'].checked = false
3906
+ end
3887
3907
  }
3888
- horizontal_box{
3889
- stretchy false
3890
- grid{
3891
- button('전체선택'){
3892
- top 1
3893
- left 1
3894
- on_clicked{
3895
- for n in 0..@data['제목설정']['제목'].length-1
3896
- @data['제목설정']['제목'][n][0] = true
3897
- @data['제목설정']['제목'] << []
3898
- @data['제목설정']['제목'].pop
3899
- end
3900
- }
3901
- }
3902
- button('선택해제'){
3903
- top 1
3904
- left 2
3905
- on_clicked{
3906
- for n in 0..@data['제목설정']['제목'].length-1
3907
- @data['제목설정']['제목'][n][0] = false
3908
- @data['제목설정']['제목'] << []
3908
+ }
3909
+ } }
3910
+ horizontal_box{
3911
+ stretchy false
3912
+ @data['포스트설정']['gpt키워드_프롬프트'] = entry(){
3913
+ text '프롬프트:관련 글을 1500자에서 2500자 사이로 만들어줘'
3914
+ }}
3915
+ horizontal_box{
3916
+ stretchy false
3917
+ grid{
3918
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3919
+ } } }
3920
+
3921
+
3922
+ table{
3923
+ checkbox_column('선택'){
3924
+ editable true
3925
+ }
3926
+ text_column('키워드'){
3927
+
3928
+ }
3929
+
3930
+ cell_rows @data['키워드설정']['키워드']
3931
+ }
3932
+
3933
+
3934
+
3935
+ }
3936
+ vertical_separator{
3937
+ stretchy false
3938
+ }
3939
+ vertical_box{
3940
+ horizontal_box{
3941
+ stretchy false
3942
+ button('제목불러오기'){
3943
+ on_clicked{
3944
+ file = open_file
3945
+ if file != nil
3946
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3947
+ file_data.split("\n").each do |title|
3948
+ if title.split(" ").join('').length < 2
3949
+
3950
+ else
3951
+ @data['제목설정']['제목'] << [false, title]
3952
+ @data['제목설정']['제목'] << [false, title]
3909
3953
  @data['제목설정']['제목'].pop
3910
3954
  end
3911
- }
3912
- }
3913
- button('삭제하기'){
3914
- top 1
3915
- left 3
3916
- on_clicked{
3917
- m = Array.new
3918
- for n in 0..@data['제목설정']['제목'].length-1
3919
- if @data['제목설정']['제목'][n][0] == true
3920
- m << n
3921
- end
3922
- end
3955
+ end
3956
+ end
3957
+ }
3958
+ }
3923
3959
 
3924
- m.reverse.each do |i|
3925
- @data['제목설정']['제목'].delete_at(i)
3926
- end
3927
- @data['제목설정']['제목'].delete(nil)
3928
- }
3929
- }
3960
+ }
3961
+ horizontal_box{
3962
+ stretchy false
3963
+ grid{
3964
+ button('전체선택'){
3965
+ top 1
3966
+ left 1
3967
+ on_clicked{
3968
+ for n in 0..@data['제목설정']['제목'].length-1
3969
+ @data['제목설정']['제목'][n][0] = true
3970
+ @data['제목설정']['제목'] << []
3971
+ @data['제목설정']['제목'].pop
3972
+ end
3930
3973
  }
3931
- @data['제목설정']['순서사용'] = checkbox('순서사용'){
3932
- stretchy false
3933
- on_toggled{ |c|
3934
- if c.checked?
3935
- @data['제목설정']['랜덤사용'].checked = false
3936
- end
3937
- }
3938
- }
3939
- @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3940
- stretchy false
3941
- on_toggled{ |c|
3942
- if c.checked?
3943
- @data['제목설정']['순서사용'].checked = false
3944
- end
3945
- }
3946
- }
3974
+ }
3975
+ button('선택해제'){
3976
+ top 1
3977
+ left 2
3978
+ on_clicked{
3979
+ for n in 0..@data['제목설정']['제목'].length-1
3980
+ @data['제목설정']['제목'][n][0] = false
3981
+ @data['제목설정']['제목'] << []
3982
+ @data['제목설정']['제목'].pop
3983
+ end
3947
3984
  }
3948
- vertical_separator{
3949
- stretchy false
3985
+ }
3986
+ button('삭제하기'){
3987
+ top 1
3988
+ left 3
3989
+ on_clicked{
3990
+ m = Array.new
3991
+ for n in 0..@data['제목설정']['제목'].length-1
3992
+ if @data['제목설정']['제목'][n][0] == true
3993
+ m << n
3994
+ end
3995
+ end
3996
+
3997
+ m.reverse.each do |i|
3998
+ @data['제목설정']['제목'].delete_at(i)
3999
+ end
4000
+ @data['제목설정']['제목'].delete(nil)
3950
4001
  }
3951
- horizontal_box{
3952
- stretchy false
3953
- grid{
3954
- @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3955
-
3956
-
3957
- }}}
3958
- horizontal_box{
3959
- stretchy false
3960
- grid{
3961
- label(' GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3962
- } } }
3963
-
4002
+ }
4003
+ }
4004
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
4005
+ stretchy false
4006
+ on_toggled{ |c|
4007
+ if c.checked?
4008
+ @data['제목설정']['랜덤사용'].checked = false
4009
+ end
4010
+ }
4011
+ }
4012
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
4013
+ stretchy false
4014
+ on_toggled{ |c|
4015
+ if c.checked?
4016
+ @data['제목설정']['순서사용'].checked = false
4017
+ end
4018
+ }
4019
+ }
4020
+ }
4021
+ vertical_separator{
4022
+ stretchy false
4023
+ }
4024
+ horizontal_box{
4025
+ stretchy false
4026
+ grid{
4027
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
4028
+
4029
+
4030
+ }}}
4031
+ horizontal_box{
4032
+ stretchy false
4033
+ @data['포스트설정']['gpt제목_프롬프트'] = entry(){
4034
+ text '프롬프트:비슷한 길이로 제목으로 사용할수있게 하나만 만들어줘'
4035
+ }}
4036
+ horizontal_box{
4037
+ stretchy false
4038
+ grid{
4039
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4040
+ } } }
4041
+
3964
4042
 
3965
- table{
3966
- checkbox_column('선택'){
3967
- editable true
3968
- }
3969
- text_column('제목'){
4043
+ table{
4044
+ checkbox_column('선택'){
4045
+ editable true
4046
+ }
4047
+ text_column('제목'){
3970
4048
 
3971
- }
4049
+ }
3972
4050
 
3973
- cell_rows @data['제목설정']['제목']
3974
- }
3975
-
4051
+ cell_rows @data['제목설정']['제목']
4052
+ }
4053
+
3976
4054
 
4055
+ }
4056
+ vertical_separator{
4057
+ stretchy false
4058
+ }
4059
+ vertical_box{
4060
+ horizontal_box{
4061
+ stretchy false
4062
+ button('내용불러오기'){
4063
+ on_clicked{
4064
+ file = open_file
4065
+ if file != nil
4066
+ file_name = file.split("\\")[-1]
4067
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
4068
+ if file_data.split("\n").length < 2
4069
+ file_data = file_data + "\n"
4070
+ end
4071
+ @data['내용설정']['내용'] << [false, file_name, file_data]
4072
+ @data['내용설정']['내용'] << [false, file_name, file_data]
4073
+ @data['내용설정']['내용'].pop
4074
+ end
4075
+ }
3977
4076
  }
3978
- vertical_separator{
3979
- stretchy false
3980
- }
3981
- vertical_box{
3982
- horizontal_box{
3983
- stretchy false
3984
- button('내용불러오기'){
3985
- on_clicked{
3986
- file = open_file
3987
- if file != nil
3988
- file_name = file.split("\\")[-1]
3989
- file_data = File.open(file,'r', :encoding => 'utf-8').read()
3990
- if file_data.split("\n").length < 2
3991
- file_data = file_data + "\n"
3992
- end
3993
- @data['내용설정']['내용'] << [false, file_name, file_data]
3994
- @data['내용설정']['내용'] << [false, file_name, file_data]
3995
- @data['내용설정']['내용'].pop
3996
- end
3997
- }
3998
- }
3999
4077
 
4078
+ }
4079
+ horizontal_box{
4080
+ stretchy false
4081
+ grid{
4082
+ button('전체선택'){
4083
+ top 1
4084
+ left 1
4085
+ on_clicked{
4086
+ for n in 0..@data['내용설정']['내용'].length-1
4087
+ @data['내용설정']['내용'][n][0] = true
4088
+ @data['내용설정']['내용'] << []
4089
+ @data['내용설정']['내용'].pop
4090
+ end
4000
4091
  }
4001
- horizontal_box{
4002
- stretchy false
4003
- grid{
4004
- button('전체선택'){
4005
- top 1
4006
- left 1
4007
- on_clicked{
4008
- for n in 0..@data['내용설정']['내용'].length-1
4009
- @data['내용설정']['내용'][n][0] = true
4010
- @data['내용설정']['내용'] << []
4011
- @data['내용설정']['내용'].pop
4012
- end
4013
- }
4014
- }
4015
- button('선택해제'){
4016
- top 1
4017
- left 2
4018
- on_clicked{
4019
- for n in 0..@data['내용설정']['내용'].length-1
4020
- @data['내용설정']['내용'][n][0] = false
4021
- @data['내용설정']['내용'] << []
4022
- @data['내용설정']['내용'].pop
4023
- end
4024
- }
4025
- }
4026
- button('삭제하기'){
4027
- top 1
4028
- left 3
4029
- on_clicked{
4030
- m = Array.new
4031
- for n in 0..@data['내용설정']['내용'].length-1
4032
- if @data['내용설정']['내용'][n][0] == true
4033
- m << n
4034
- end
4035
- end
4092
+ }
4093
+ button('선택해제'){
4094
+ top 1
4095
+ left 2
4096
+ on_clicked{
4097
+ for n in 0..@data['내용설정']['내용'].length-1
4098
+ @data['내용설정']['내용'][n][0] = false
4099
+ @data['내용설정']['내용'] << []
4100
+ @data['내용설정']['내용'].pop
4101
+ end
4102
+ }
4103
+ }
4104
+ button('삭제하기'){
4105
+ top 1
4106
+ left 3
4107
+ on_clicked{
4108
+ m = Array.new
4109
+ for n in 0..@data['내용설정']['내용'].length-1
4110
+ if @data['내용설정']['내용'][n][0] == true
4111
+ m << n
4112
+ end
4113
+ end
4036
4114
 
4037
- m.reverse.each do |i|
4038
- @data['내용설정']['내용'].delete_at(i)
4039
- end
4040
- @data['내용설정']['내용'].delete(nil)
4041
- }
4042
- }
4115
+ m.reverse.each do |i|
4116
+ @data['내용설정']['내용'].delete_at(i)
4117
+ end
4118
+ @data['내용설정']['내용'].delete(nil)
4043
4119
  }
4044
- @data['내용설정']['순서사용'] = checkbox('순서사용'){
4045
- stretchy false
4046
- on_toggled{ |c|
4047
- if c.checked?
4048
- @data['내용설정']['랜덤사용'].checked = false
4049
- end
4050
- }
4051
- }
4052
- @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4053
- stretchy false
4054
- on_toggled{ |c|
4055
- if c.checked?
4056
- @data['내용설정']['순서사용'].checked = false
4057
- end
4058
- }
4059
- }
4120
+ }
4121
+ }
4122
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
4123
+ stretchy false
4124
+ on_toggled{ |c|
4125
+ if c.checked?
4126
+ @data['내용설정']['랜덤사용'].checked = false
4127
+ end
4060
4128
  }
4061
- vertical_separator{
4062
- stretchy false
4129
+ }
4130
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4131
+ stretchy false
4132
+ on_toggled{ |c|
4133
+ if c.checked?
4134
+ @data['내용설정']['순서사용'].checked = false
4135
+ end
4063
4136
  }
4064
- horizontal_box{
4065
- stretchy false
4066
- grid{
4067
- @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4068
-
4069
-
4070
- }}}
4071
- horizontal_box{
4072
- stretchy false
4073
- grid{
4074
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4075
- } } }
4076
-
4077
- table{
4078
- checkbox_column('선택'){
4079
- editable true
4080
- }
4081
- text_column('내용파일'){
4137
+ }
4138
+ }
4139
+ vertical_separator{
4140
+ stretchy false
4141
+ }
4142
+ horizontal_box{
4143
+ stretchy false
4144
+ grid{
4145
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4146
+
4147
+
4148
+ }}}
4149
+ horizontal_box{
4150
+ stretchy false
4151
+ @data['포스트설정']['gpt내용_프롬프트'] = entry(){
4152
+ text '프롬프트:동의어,유사어를 이용해 변경해줘'
4153
+ }}
4154
+ horizontal_box{
4155
+ stretchy false
4156
+ grid{
4157
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4158
+ } } }
4159
+
4160
+ table{
4161
+ checkbox_column('선택'){
4162
+ editable true
4163
+ }
4164
+ text_column('내용파일'){
4082
4165
 
4083
- }
4166
+ }
4084
4167
 
4085
- cell_rows @data['내용설정']['내용']
4086
- }
4168
+ cell_rows @data['내용설정']['내용']
4169
+ }
4087
4170
 
4088
- horizontal_box{
4089
- stretchy false
4090
- @data['이미지설정']['폴더경로2'] = entry{
4091
- stretchy false
4092
- text "내용폴더경로 ex)C:\\내용\\폴더1"
4093
- }
4094
- button('폴더째로 불러오기') {
4095
- on_clicked {
4096
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4097
-
4098
- # 경로가 유효한지 확인
4099
- if Dir.exist?(path)
4100
- Dir.entries(path).each do |file|
4101
- if file == '.' or file == '..'
4102
- next
4103
- else
4104
- begin
4105
- # 파일을 열고 내용을 읽어서 추가
4106
- file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4107
- @data['내용설정']['내용'] << [false, file, file_data]
4108
- rescue => e
4109
- # 파일을 열 수 없는 경우, 오류 메시지 출력
4110
- puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4111
- end
4112
- end
4113
- end
4171
+ horizontal_box{
4172
+ stretchy false
4173
+ @data['이미지설정']['폴더경로2'] = entry{
4174
+ stretchy false
4175
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
4176
+ }
4114
4177
 
4115
- # 내용 배열에서 마지막 빈 항목 제거
4116
- @data['내용설정']['내용'] << []
4117
- @data['내용설정']['내용'].pop
4178
+ button('폴더째로 불러오기') {
4179
+ on_clicked {
4180
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4181
+
4182
+ # 경로가 유효한지 확인
4183
+ if Dir.exist?(path)
4184
+ Dir.entries(path).each do |file|
4185
+ if file == '.' or file == '..'
4186
+ next
4118
4187
  else
4119
- # 경로가 유효하지 않을 경우, 오류 메시지 출력
4120
- puts "경로가 존재하지 않습니다: #{path}"
4188
+ begin
4189
+ # 파일을 열고 내용을 읽어서 추가
4190
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4191
+ @data['내용설정']['내용'] << [false, file, file_data]
4192
+ rescue => e
4193
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4194
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4195
+ end
4121
4196
  end
4122
- }
4123
- }
4197
+ end
4198
+
4199
+ # 내용 배열에서 마지막 빈 항목 제거
4200
+ @data['내용설정']['내용'] << []
4201
+ @data['내용설정']['내용'].pop
4202
+ else
4203
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4204
+ puts "경로가 존재하지 않습니다: #{path}"
4205
+ end
4124
4206
  }
4125
4207
  }
4126
4208
  }
4127
4209
  }
4210
+ }
4211
+ }
4128
4212
  tab_item('이미지설정'){
4129
4213
  horizontal_box{
4130
4214
  vertical_box{
@@ -4600,7 +4684,7 @@ class Wordpress
4600
4684
  left 1
4601
4685
  text 'URL'
4602
4686
  }
4603
- @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 생성으로만 등록(GPT사용시 자체 생성)'){
4687
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 글만 등록(GPT사용시 체크 해제)'){
4604
4688
  top 9
4605
4689
  left 0
4606
4690
  on_toggled{
@@ -4608,31 +4692,46 @@ class Wordpress
4608
4692
  @data['포스트설정']['내용과자동생성'].checked = false
4609
4693
  @data['포스트설정']['내용투명'].checked = false
4610
4694
  @data['포스트설정']['자동글 수식에 입력'].checked = false
4611
-
4695
+
4612
4696
  end
4613
4697
  }
4614
4698
  }
4615
-
4616
-
4699
+ label('※GPT사용시 내용설정 탭에서 설정'){
4700
+ top 9
4701
+ left 1
4702
+ }
4703
+
4704
+ label('※GPT 미 사용시 세팅 권장'){
4705
+ top 9
4706
+ left 3
4707
+ }
4708
+
4617
4709
 
4618
-
4619
4710
  aa1 = 2
4620
- @data['포스트설정']['내용과자동생성'] = checkbox('내용파일+키워드기반 생성 등록(GPT사용시 자체 생성)') {
4711
+ @data['포스트설정']['내용과자동생성'] = checkbox('원고+키워드기반 등록(GPT사용시 체크 해제)') {
4621
4712
  top 10 + aa1
4622
4713
  left 0
4623
4714
  on_toggled {
4624
- if @data['포스트설정']['내용과자동생성'].checked?
4715
+ if @data['포스트설정']['내용과자동생성'].checked?
4625
4716
  @data['포스트설정']['내용을자동생성'].checked = false
4626
4717
  @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4627
4718
  @data['포스트설정']['자동글 수식에 입력'].enabled = true # '내용투명' 활성화
4628
- else
4719
+ else
4629
4720
  @data['포스트설정']['내용투명'].checked = false # 체크 해제
4630
4721
  @data['포스트설정']['내용투명'].enabled = false # 비활성화
4631
4722
  @data['포스트설정']['자동글 수식에 입력'].checked = false # 체크 해제
4632
4723
  @data['포스트설정']['자동글 수식에 입력'].enabled = false # 비활성화
4633
- end
4724
+ end
4634
4725
  }
4635
- }
4726
+ }
4727
+ label('※GPT사용시 내용설정 탭에서 설정'){
4728
+ top 10 + aa1
4729
+ left 1
4730
+ }
4731
+ label('※GPT 미 사용시 세팅 권장'){
4732
+ top 10 + aa1
4733
+ left 3
4734
+ }
4636
4735
 
4637
4736
  @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4638
4737
  top 11 + aa1