cafe_buy 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.rb +584 -483
  3. metadata +2 -2
data/lib/cafe_buy.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
1048
- return 0
1049
- @driver.quit
1104
+ @driver.quit
1105
+ return 0
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
@@ -2029,6 +2087,7 @@ end
2029
2087
  end
2030
2088
  end
2031
2089
 
2090
+
2032
2091
  class Wordpress
2033
2092
  include Glimmer
2034
2093
  def get_mac_address
@@ -2540,7 +2599,15 @@ class Wordpress
2540
2599
  end
2541
2600
 
2542
2601
  if @data['포스트설정']['gpt제목'].checked?
2543
- chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2602
+ gpt_title_prompt = @data['포스트설정']['gpt제목_프롬프트'].text.to_s.force_encoding('utf-8')
2603
+
2604
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2605
+ gpt_title_prompt_sample = gpt_title_prompt.strip.empty? ? "프롬프트: 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘." : gpt_title_prompt
2606
+
2607
+ # gpt_title_prompt_sample을 Chat_title 객체에 전달
2608
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_title_prompt_sample)
2609
+
2610
+ # 메시지 요청 후 title에 저장
2544
2611
  gpt_text1 = chat.message(title)
2545
2612
  title = gpt_text1.to_s
2546
2613
  end
@@ -2585,18 +2652,16 @@ class Wordpress
2585
2652
 
2586
2653
 
2587
2654
  if @data['포스트설정']['gpt내용'].checked?
2655
+ gpt_content_prompt = @data['포스트설정']['gpt내용_프롬프트'].text.to_s.force_encoding('utf-8')
2588
2656
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2589
- #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
2590
- #imotcon_change = @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8')
2591
- #template_change = @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8')
2592
- #ttdanar_change = @data['포스트설정']['단어링크적용단어'].text.to_s.force_encoding('utf-8')
2593
- #sajine_change = @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8')
2594
- #mov_change = @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8')
2595
- #map_change = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8')
2596
- #inyong9_change = @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8')
2597
-
2598
2657
 
2599
- chat = Chat_content.new(api_key)
2658
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2659
+ gpt_content_prompt_sample = gpt_content_prompt.strip.empty? ? "프롬프트:ChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해" : gpt_content_prompt
2660
+
2661
+ # Chat_content 객체 생성 시 api_key와 gpt_content_prompt_sample을 두 개의 인자로 전달
2662
+ chat = Chat_content.new(api_key, gpt_content_prompt_sample)
2663
+
2664
+ # 메시지 요청 후 content에 저장
2600
2665
  gpt_text3 = chat.message(content)
2601
2666
  content = gpt_text3.to_s
2602
2667
  end
@@ -2800,13 +2865,17 @@ class Wordpress
2800
2865
  @data['table'] << []
2801
2866
  @data['table'].pop
2802
2867
  if @data['포스트설정']['gpt키워드'].checked?
2803
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2868
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2869
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2870
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2804
2871
  gpt_text = chat.message(keyword)
2805
- content = content + "\n(자동생성글)\n" + gpt_text
2872
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2873
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2806
2874
  elsif @data['포스트설정']['내용을자동생성'].checked?
2807
2875
  content = auto_text
2808
2876
  elsif @data['포스트설정']['내용과자동생성'].checked?
2809
- content = content + "\n(자동생성글)\n" + auto_text
2877
+ #content = content + "\n(자동생성글)\n" + auto_text
2878
+ content = content + "(자동생성글)" + auto_text
2810
2879
  end
2811
2880
 
2812
2881
  if @data['포스트설정']['내용키워드삽입'].checked?
@@ -2841,7 +2910,8 @@ class Wordpress
2841
2910
  end
2842
2911
 
2843
2912
  if @data['포스트설정']['내용을자동생성'].checked?
2844
- content2 = content.split("\n")
2913
+ #content2 = content.split("\n")
2914
+ content2 = content.split
2845
2915
  end
2846
2916
 
2847
2917
  if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
@@ -3964,423 +4034,439 @@ class Wordpress
3964
4034
  }
3965
4035
  }
3966
4036
  tab_item('내용설정'){
4037
+ horizontal_box{
4038
+ vertical_box{
3967
4039
  horizontal_box{
3968
- vertical_box{
3969
- horizontal_box{
3970
- stretchy false
3971
- button('키워드불러오기'){
3972
- on_clicked{
3973
- file = open_file
3974
- if file != nil
3975
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3976
- file_data.split("\n").each do |keyword|
3977
- if keyword.split(' ').join('').length < 2
3978
-
3979
- else
3980
- @data['키워드설정']['키워드'] << [false, keyword]
3981
- @data['키워드설정']['키워드'] << [false, keyword]
3982
- @data['키워드설정']['키워드'].pop
3983
- end
3984
- end
3985
- end
3986
-
3987
- }
3988
- }
4040
+ stretchy false
4041
+ button('키워드불러오기'){
4042
+ on_clicked{
4043
+ file = open_file
4044
+ if file != nil
4045
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4046
+ file_data.split("\n").each do |keyword|
4047
+ if keyword.split(' ').join('').length < 2
3989
4048
 
3990
- }
3991
- horizontal_box{
3992
- stretchy false
3993
- grid{
3994
- button('전체선택'){
3995
- top 1
3996
- left 1
3997
- on_clicked{
3998
- for n in 0..@data['키워드설정']['키워드'].length-1
3999
- @data['키워드설정']['키워드'][n][0] = true
4000
- @data['키워드설정']['키워드'] << []
4001
- @data['키워드설정']['키워드'].pop
4002
- end
4003
- }
4004
- }
4005
- button('선택해제'){
4006
- top 1
4007
- left 2
4008
- on_clicked{
4009
- for n in 0..@data['키워드설정']['키워드'].length-1
4010
- @data['키워드설정']['키워드'][n][0] = false
4011
- @data['키워드설정']['키워드'] << []
4049
+ else
4050
+ @data['키워드설정']['키워드'] << [false, keyword]
4051
+ @data['키워드설정']['키워드'] << [false, keyword]
4012
4052
  @data['키워드설정']['키워드'].pop
4013
4053
  end
4014
- }
4015
- }
4016
- button('삭제하기'){
4017
- top 1
4018
- left 3
4019
- on_clicked{
4020
- m = Array.new
4021
- for n in 0..@data['키워드설정']['키워드'].length-1
4022
- if @data['키워드설정']['키워드'][n][0] == true
4023
- m << n
4024
- end
4025
- end
4054
+ end
4055
+ end
4026
4056
 
4027
- m.reverse.each do |i|
4028
- @data['키워드설정']['키워드'].delete_at(i)
4029
- end
4030
- @data['키워드설정']['키워드'].delete(nil)
4031
- }
4032
- }
4033
4057
  }
4034
-
4035
- @data['키워드설정']['순서사용'] = checkbox('순서사용'){
4036
- stretchy false
4037
- on_toggled{ |c|
4038
- if c.checked?
4039
- @data['키워드설정']['랜덤사용'].checked = false
4040
- end
4041
- }
4042
- }
4043
- @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
4044
- stretchy false
4045
- on_toggled{ |c|
4046
- if c.checked?
4047
- @data['키워드설정']['순서사용'].checked = false
4048
- end
4049
- }
4050
- }
4058
+ }
4059
+
4060
+ }
4061
+ horizontal_box{
4062
+ stretchy false
4063
+ grid{
4064
+ button('전체선택'){
4065
+ top 1
4066
+ left 1
4067
+ on_clicked{
4068
+ for n in 0..@data['키워드설정']['키워드'].length-1
4069
+ @data['키워드설정']['키워드'][n][0] = true
4070
+ @data['키워드설정']['키워드'] << []
4071
+ @data['키워드설정']['키워드'].pop
4072
+ end
4051
4073
  }
4052
- vertical_separator{
4053
- stretchy false
4074
+ }
4075
+ button('선택해제'){
4076
+ top 1
4077
+ left 2
4078
+ on_clicked{
4079
+ for n in 0..@data['키워드설정']['키워드'].length-1
4080
+ @data['키워드설정']['키워드'][n][0] = false
4081
+ @data['키워드설정']['키워드'] << []
4082
+ @data['키워드설정']['키워드'].pop
4083
+ end
4054
4084
  }
4055
- horizontal_box{
4056
- stretchy false
4057
- grid{
4058
- @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
4059
- top 1
4060
- left 0
4061
- #enabled false # 기본적으로 비활성화
4062
- on_toggled {
4063
- if @data['포스트설정']['gpt키워드'].checked?
4064
- @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
4065
- @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
4066
- else
4067
- @data['포스트설정']['gpt상단'].checked = false # 체크 해제
4068
- @data['포스트설정']['gpt상단'].enabled = false # 비활성화
4069
- @data['포스트설정']['gpt하단'].checked = false # 체크 해제
4070
- @data['포스트설정']['gpt하단'].enabled = false # 비활성화
4071
- end
4072
- }
4073
-
4074
- }
4075
-
4076
- @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
4077
- top 1
4078
- left 1
4079
- enabled false # 기본적으로 비활성화
4080
- on_toggled{
4081
- if @data['포스트설정']['gpt상단'].checked?
4082
- @data['포스트설정']['gpt하단'].checked = false
4083
- end
4084
- }
4085
- }
4086
-
4087
- @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
4088
- top 1
4089
- left 2
4090
- enabled false # 기본적으로 비활성화
4091
- on_toggled{
4092
- if @data['포스트설정']['gpt하단'].checked?
4093
- @data['포스트설정']['gpt상단'].checked = false
4085
+ }
4086
+ button('삭제하기'){
4087
+ top 1
4088
+ left 3
4089
+ on_clicked{
4090
+ m = Array.new
4091
+ for n in 0..@data['키워드설정']['키워드'].length-1
4092
+ if @data['키워드설정']['키워드'][n][0] == true
4093
+ m << n
4094
4094
  end
4095
- }
4096
- }
4097
- } }
4098
- horizontal_box{
4099
- stretchy false
4100
- grid{
4101
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4102
- } } }
4103
-
4104
-
4105
- table{
4106
- checkbox_column('선택'){
4107
- editable true
4108
- }
4109
- text_column('키워드'){
4110
-
4111
- }
4095
+ end
4112
4096
 
4113
- cell_rows @data['키워드설정']['키워드']
4097
+ m.reverse.each do |i|
4098
+ @data['키워드설정']['키워드'].delete_at(i)
4099
+ end
4100
+ @data['키워드설정']['키워드'].delete(nil)
4114
4101
  }
4115
-
4116
-
4117
-
4118
4102
  }
4119
- vertical_separator{
4103
+ }
4104
+
4105
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
4120
4106
  stretchy false
4107
+ on_toggled{ |c|
4108
+ if c.checked?
4109
+ @data['키워드설정']['랜덤사용'].checked = false
4110
+ end
4111
+ }
4112
+ }
4113
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
4114
+ stretchy false
4115
+ on_toggled{ |c|
4116
+ if c.checked?
4117
+ @data['키워드설정']['순서사용'].checked = false
4118
+ end
4119
+ }
4120
+ }
4121
+ }
4122
+ vertical_separator{
4123
+ stretchy false
4124
+ }
4125
+ horizontal_box{
4126
+ stretchy false
4127
+ grid{
4128
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
4129
+ top 1
4130
+ left 0
4131
+ #enabled false # 기본적으로 비활성화
4132
+ on_toggled {
4133
+ if @data['포스트설정']['gpt키워드'].checked?
4134
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
4135
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
4136
+ else
4137
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
4138
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
4139
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
4140
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
4141
+ end
4142
+ }
4143
+
4144
+ }
4145
+
4146
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
4147
+ top 1
4148
+ left 1
4149
+ enabled false # 기본적으로 비활성화
4150
+ on_toggled{
4151
+ if @data['포스트설정']['gpt상단'].checked?
4152
+ @data['포스트설정']['gpt하단'].checked = false
4153
+ end
4154
+ }
4121
4155
  }
4122
- vertical_box{
4123
- horizontal_box{
4124
- stretchy false
4125
- button('제목불러오기'){
4126
- on_clicked{
4127
- file = open_file
4128
- if file != nil
4129
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4130
- file_data.split("\n").each do |title|
4131
- if title.split(" ").join('').length < 2
4132
-
4133
- else
4134
- @data['제목설정']['제목'] << [false, title]
4135
- @data['제목설정']['제목'] << [false, title]
4136
- @data['제목설정']['제목'].pop
4137
- end
4138
- end
4139
- end
4140
- }
4141
- }
4142
4156
 
4157
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
4158
+ top 1
4159
+ left 2
4160
+ enabled false # 기본적으로 비활성화
4161
+ on_toggled{
4162
+ if @data['포스트설정']['gpt하단'].checked?
4163
+ @data['포스트설정']['gpt상단'].checked = false
4164
+ end
4143
4165
  }
4144
- horizontal_box{
4145
- stretchy false
4146
- grid{
4147
- button('전체선택'){
4148
- top 1
4149
- left 1
4150
- on_clicked{
4151
- for n in 0..@data['제목설정']['제목'].length-1
4152
- @data['제목설정']['제목'][n][0] = true
4153
- @data['제목설정']['제목'] << []
4154
- @data['제목설정']['제목'].pop
4155
- end
4156
- }
4157
- }
4158
- button('선택해제'){
4159
- top 1
4160
- left 2
4161
- on_clicked{
4162
- for n in 0..@data['제목설정']['제목'].length-1
4163
- @data['제목설정']['제목'][n][0] = false
4164
- @data['제목설정']['제목'] << []
4166
+ }
4167
+ } }
4168
+ horizontal_box{
4169
+ stretchy false
4170
+ @data['포스트설정']['gpt키워드_프롬프트'] = entry(){
4171
+ text '프롬프트:관련 글을 1500자에서 2500자 사이로 만들어줘'
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
+ }
4187
+
4188
+ cell_rows @data['키워드설정']['키워드']
4189
+ }
4190
+
4191
+
4192
+
4193
+ }
4194
+ vertical_separator{
4195
+ stretchy false
4196
+ }
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]
4165
4211
  @data['제목설정']['제목'].pop
4166
4212
  end
4167
- }
4168
- }
4169
- button('삭제하기'){
4170
- top 1
4171
- left 3
4172
- on_clicked{
4173
- m = Array.new
4174
- for n in 0..@data['제목설정']['제목'].length-1
4175
- if @data['제목설정']['제목'][n][0] == true
4176
- m << n
4177
- end
4178
- end
4213
+ end
4214
+ end
4215
+ }
4216
+ }
4179
4217
 
4180
- m.reverse.each do |i|
4181
- @data['제목설정']['제목'].delete_at(i)
4182
- end
4183
- @data['제목설정']['제목'].delete(nil)
4184
- }
4185
- }
4218
+ }
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
4186
4231
  }
4187
- @data['제목설정']['순서사용'] = checkbox('순서사용'){
4188
- stretchy false
4189
- on_toggled{ |c|
4190
- if c.checked?
4191
- @data['제목설정']['랜덤사용'].checked = false
4192
- end
4193
- }
4194
- }
4195
- @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
4196
- stretchy false
4197
- on_toggled{ |c|
4198
- if c.checked?
4199
- @data['제목설정']['순서사용'].checked = false
4200
- end
4201
- }
4202
- }
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
+ @data['제목설정']['제목'].pop
4241
+ end
4203
4242
  }
4204
- vertical_separator{
4205
- stretchy false
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
4254
+
4255
+ m.reverse.each do |i|
4256
+ @data['제목설정']['제목'].delete_at(i)
4257
+ end
4258
+ @data['제목설정']['제목'].delete(nil)
4206
4259
  }
4207
- horizontal_box{
4208
- stretchy false
4209
- grid{
4210
- @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
4211
-
4212
-
4213
- }}}
4214
- horizontal_box{
4215
- stretchy false
4216
- grid{
4217
- label(' GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4218
- } } }
4219
-
4260
+ }
4261
+ }
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
+ }
4278
+ }
4279
+ vertical_separator{
4280
+ stretchy false
4281
+ }
4282
+ horizontal_box{
4283
+ stretchy false
4284
+ grid{
4285
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
4286
+
4287
+
4288
+ }}}
4289
+ horizontal_box{
4290
+ stretchy false
4291
+ @data['포스트설정']['gpt제목_프롬프트'] = entry(){
4292
+ text '프롬프트:비슷한 길이로 제목으로 사용할수있게 하나만 만들어줘'
4293
+ }}
4294
+ horizontal_box{
4295
+ stretchy false
4296
+ grid{
4297
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4298
+ } } }
4299
+
4220
4300
 
4221
- table{
4222
- checkbox_column('선택'){
4223
- editable true
4224
- }
4225
- text_column('제목'){
4301
+ table{
4302
+ checkbox_column('선택'){
4303
+ editable true
4304
+ }
4305
+ text_column('제목'){
4226
4306
 
4227
- }
4307
+ }
4228
4308
 
4229
- cell_rows @data['제목설정']['제목']
4230
- }
4231
-
4309
+ cell_rows @data['제목설정']['제목']
4310
+ }
4311
+
4232
4312
 
4313
+ }
4314
+ vertical_separator{
4315
+ stretchy false
4316
+ }
4317
+ vertical_box{
4318
+ horizontal_box{
4319
+ stretchy false
4320
+ button('내용불러오기'){
4321
+ on_clicked{
4322
+ file = open_file
4323
+ if file != nil
4324
+ file_name = file.split("\\")[-1]
4325
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
4326
+ if file_data.split("\n").length < 2
4327
+ file_data = file_data + "\n"
4328
+ end
4329
+ @data['내용설정']['내용'] << [false, file_name, file_data]
4330
+ @data['내용설정']['내용'] << [false, file_name, file_data]
4331
+ @data['내용설정']['내용'].pop
4332
+ end
4333
+ }
4233
4334
  }
4234
- vertical_separator{
4235
- stretchy false
4236
- }
4237
- vertical_box{
4238
- horizontal_box{
4239
- stretchy false
4240
- button('내용불러오기'){
4241
- on_clicked{
4242
- file = open_file
4243
- if file != nil
4244
- file_name = file.split("\\")[-1]
4245
- file_data = File.open(file,'r', :encoding => 'utf-8').read()
4246
- if file_data.split("\n").length < 2
4247
- file_data = file_data + "\n"
4248
- end
4249
- @data['내용설정']['내용'] << [false, file_name, file_data]
4250
- @data['내용설정']['내용'] << [false, file_name, file_data]
4251
- @data['내용설정']['내용'].pop
4252
- end
4253
- }
4254
- }
4255
4335
 
4336
+ }
4337
+ horizontal_box{
4338
+ stretchy false
4339
+ grid{
4340
+ button('전체선택'){
4341
+ top 1
4342
+ left 1
4343
+ on_clicked{
4344
+ for n in 0..@data['내용설정']['내용'].length-1
4345
+ @data['내용설정']['내용'][n][0] = true
4346
+ @data['내용설정']['내용'] << []
4347
+ @data['내용설정']['내용'].pop
4348
+ end
4256
4349
  }
4257
- horizontal_box{
4258
- stretchy false
4259
- grid{
4260
- button('전체선택'){
4261
- top 1
4262
- left 1
4263
- on_clicked{
4264
- for n in 0..@data['내용설정']['내용'].length-1
4265
- @data['내용설정']['내용'][n][0] = true
4266
- @data['내용설정']['내용'] << []
4267
- @data['내용설정']['내용'].pop
4268
- end
4269
- }
4270
- }
4271
- button('선택해제'){
4272
- top 1
4273
- left 2
4274
- on_clicked{
4275
- for n in 0..@data['내용설정']['내용'].length-1
4276
- @data['내용설정']['내용'][n][0] = false
4277
- @data['내용설정']['내용'] << []
4278
- @data['내용설정']['내용'].pop
4279
- end
4280
- }
4281
- }
4282
- button('삭제하기'){
4283
- top 1
4284
- left 3
4285
- on_clicked{
4286
- m = Array.new
4287
- for n in 0..@data['내용설정']['내용'].length-1
4288
- if @data['내용설정']['내용'][n][0] == true
4289
- m << n
4290
- end
4291
- end
4350
+ }
4351
+ button('선택해제'){
4352
+ top 1
4353
+ left 2
4354
+ on_clicked{
4355
+ for n in 0..@data['내용설정']['내용'].length-1
4356
+ @data['내용설정']['내용'][n][0] = false
4357
+ @data['내용설정']['내용'] << []
4358
+ @data['내용설정']['내용'].pop
4359
+ end
4360
+ }
4361
+ }
4362
+ button('삭제하기'){
4363
+ top 1
4364
+ left 3
4365
+ on_clicked{
4366
+ m = Array.new
4367
+ for n in 0..@data['내용설정']['내용'].length-1
4368
+ if @data['내용설정']['내용'][n][0] == true
4369
+ m << n
4370
+ end
4371
+ end
4292
4372
 
4293
- m.reverse.each do |i|
4294
- @data['내용설정']['내용'].delete_at(i)
4295
- end
4296
- @data['내용설정']['내용'].delete(nil)
4297
- }
4298
- }
4373
+ m.reverse.each do |i|
4374
+ @data['내용설정']['내용'].delete_at(i)
4375
+ end
4376
+ @data['내용설정']['내용'].delete(nil)
4299
4377
  }
4300
- @data['내용설정']['순서사용'] = checkbox('순서사용'){
4301
- stretchy false
4302
- on_toggled{ |c|
4303
- if c.checked?
4304
- @data['내용설정']['랜덤사용'].checked = false
4305
- end
4306
- }
4307
- }
4308
- @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4309
- stretchy false
4310
- on_toggled{ |c|
4311
- if c.checked?
4312
- @data['내용설정']['순서사용'].checked = false
4313
- end
4314
- }
4315
- }
4378
+ }
4379
+ }
4380
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
4381
+ stretchy false
4382
+ on_toggled{ |c|
4383
+ if c.checked?
4384
+ @data['내용설정']['랜덤사용'].checked = false
4385
+ end
4316
4386
  }
4317
- vertical_separator{
4318
- stretchy false
4387
+ }
4388
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4389
+ stretchy false
4390
+ on_toggled{ |c|
4391
+ if c.checked?
4392
+ @data['내용설정']['순서사용'].checked = false
4393
+ end
4319
4394
  }
4320
- horizontal_box{
4321
- stretchy false
4322
- grid{
4323
- @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4324
-
4325
-
4326
- }}}
4327
- horizontal_box{
4328
- stretchy false
4329
- grid{
4330
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4331
- } } }
4332
-
4333
- table{
4334
- checkbox_column('선택'){
4335
- editable true
4336
- }
4337
- text_column('내용파일'){
4395
+ }
4396
+ }
4397
+ vertical_separator{
4398
+ stretchy false
4399
+ }
4400
+ horizontal_box{
4401
+ stretchy false
4402
+ grid{
4403
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4404
+
4405
+
4406
+ }}}
4407
+ horizontal_box{
4408
+ stretchy false
4409
+ @data['포스트설정']['gpt내용_프롬프트'] = entry(){
4410
+ text '프롬프트:동의어,유사어를 이용해 변경해줘'
4411
+ }}
4412
+ horizontal_box{
4413
+ stretchy false
4414
+ grid{
4415
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4416
+ } } }
4417
+
4418
+ table{
4419
+ checkbox_column('선택'){
4420
+ editable true
4421
+ }
4422
+ text_column('내용파일'){
4338
4423
 
4339
- }
4424
+ }
4340
4425
 
4341
- cell_rows @data['내용설정']['내용']
4342
- }
4426
+ cell_rows @data['내용설정']['내용']
4427
+ }
4343
4428
 
4344
- horizontal_box{
4345
- stretchy false
4346
- @data['이미지설정']['폴더경로2'] = entry{
4347
- stretchy false
4348
- text "내용폴더경로 ex)C:\\내용\\폴더1"
4349
- }
4350
- button('폴더째로 불러오기') {
4351
- on_clicked {
4352
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4429
+ horizontal_box{
4430
+ stretchy false
4431
+ @data['이미지설정']['폴더경로2'] = entry{
4432
+ stretchy false
4433
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
4434
+ }
4353
4435
 
4354
- # 경로가 유효한지 확인
4355
- if Dir.exist?(path)
4356
- Dir.entries(path).each do |file|
4357
- if file == '.' or file == '..'
4358
- next
4359
- else
4360
- begin
4361
- # 파일을 열고 내용을 읽어서 추가
4362
- file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4363
- @data['내용설정']['내용'] << [false, file, file_data]
4364
- rescue => e
4365
- # 파일을 열 수 없는 경우, 오류 메시지 출력
4366
- puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4367
- end
4368
- end
4369
- end
4436
+ button('폴더째로 불러오기') {
4437
+ on_clicked {
4438
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4370
4439
 
4371
- # 내용 배열에서 마지막 빈 항목 제거
4372
- @data['내용설정']['내용'] << []
4373
- @data['내용설정']['내용'].pop
4440
+ # 경로가 유효한지 확인
4441
+ if Dir.exist?(path)
4442
+ Dir.entries(path).each do |file|
4443
+ if file == '.' or file == '..'
4444
+ next
4374
4445
  else
4375
- # 경로가 유효하지 않을 경우, 오류 메시지 출력
4376
- puts "경로가 존재하지 않습니다: #{path}"
4446
+ begin
4447
+ # 파일을 열고 내용을 읽어서 추가
4448
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4449
+ @data['내용설정']['내용'] << [false, file, file_data]
4450
+ rescue => e
4451
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4452
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4453
+ end
4377
4454
  end
4378
- }
4379
- }
4455
+ end
4456
+
4457
+ # 내용 배열에서 마지막 빈 항목 제거
4458
+ @data['내용설정']['내용'] << []
4459
+ @data['내용설정']['내용'].pop
4460
+ else
4461
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4462
+ puts "경로가 존재하지 않습니다: #{path}"
4463
+ end
4380
4464
  }
4381
4465
  }
4382
4466
  }
4383
4467
  }
4468
+ }
4469
+ }
4384
4470
  tab_item('이미지설정'){
4385
4471
  horizontal_box{
4386
4472
  vertical_box{
@@ -4854,7 +4940,7 @@ class Wordpress
4854
4940
  left 1
4855
4941
  text 'URL'
4856
4942
  }
4857
- @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 생성으로만 등록(GPT사용시 자체 생성)'){
4943
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 글만 등록(GPT사용시 체크 해제)'){
4858
4944
  top 9
4859
4945
  left 0
4860
4946
  on_toggled{
@@ -4862,31 +4948,46 @@ class Wordpress
4862
4948
  @data['포스트설정']['내용과자동생성'].checked = false
4863
4949
  @data['포스트설정']['내용투명'].checked = false
4864
4950
  @data['포스트설정']['자동글 수식에 입력'].checked = false
4865
-
4951
+
4866
4952
  end
4867
4953
  }
4868
4954
  }
4869
-
4955
+ label('※GPT사용시 내용설정 탭에서 설정'){
4956
+ top 9
4957
+ left 1
4958
+ }
4959
+
4960
+ label('※GPT 미 사용시 세팅 권장'){
4961
+ top 9
4962
+ left 3
4963
+ }
4870
4964
 
4871
-
4872
-
4965
+
4873
4966
  aa1 = 2
4874
- @data['포스트설정']['내용과자동생성'] = checkbox('내용파일+키워드기반 생성 등록(GPT사용시 자체 생성)') {
4967
+ @data['포스트설정']['내용과자동생성'] = checkbox('원고+키워드기반 등록(GPT사용시 체크 해제)') {
4875
4968
  top 10 + aa1
4876
4969
  left 0
4877
4970
  on_toggled {
4878
- if @data['포스트설정']['내용과자동생성'].checked?
4971
+ if @data['포스트설정']['내용과자동생성'].checked?
4879
4972
  @data['포스트설정']['내용을자동생성'].checked = false
4880
4973
  @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4881
4974
  @data['포스트설정']['자동글 수식에 입력'].enabled = true # '내용투명' 활성화
4882
- else
4975
+ else
4883
4976
  @data['포스트설정']['내용투명'].checked = false # 체크 해제
4884
4977
  @data['포스트설정']['내용투명'].enabled = false # 비활성화
4885
4978
  @data['포스트설정']['자동글 수식에 입력'].checked = false # 체크 해제
4886
4979
  @data['포스트설정']['자동글 수식에 입력'].enabled = false # 비활성화
4887
- end
4980
+ end
4888
4981
  }
4889
- }
4982
+ }
4983
+ label('※GPT사용시 내용설정 탭에서 설정'){
4984
+ top 10 + aa1
4985
+ left 1
4986
+ }
4987
+ label('※GPT 미 사용시 세팅 권장'){
4988
+ top 10 + aa1
4989
+ left 3
4990
+ }
4890
4991
 
4891
4992
  @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4892
4993
  top 11 + aa1