tblog_zon 0.0.1 → 0.0.9

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/tblog_zon.rb +1267 -1080
  3. metadata +2 -2
data/lib/tblog_zon.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'glimmer-dsl-libui'
2
2
  require 'selenium-webdriver'
3
- # require 'webdrivers'
3
+ require 'webdrivers'
4
4
  require 'iconv'
5
5
  require 'nokogiri'
6
6
  require 'http'
@@ -19,14 +19,11 @@ require 'auto_click'
19
19
  require 'rainbow/refinement'
20
20
  include AutoClickMethods
21
21
  using Rainbow
22
+ include Glimmer
22
23
 
23
24
 
24
25
 
25
26
 
26
-
27
- #driver.find_element(:class, 'highlight-java')
28
- # or
29
- #driver.find_element(:class_name, 'highlight-java')
30
27
  class Chat
31
28
  def initialize(api_key)
32
29
  @api_key = api_key
@@ -39,10 +36,11 @@ class Chat
39
36
  'Authorization' => 'Bearer ' + @api_key
40
37
  }
41
38
  d = {
42
- 'model' => 'gpt-3.5-turbo',
39
+ #'model' => 'gpt-3.5-turbo',
40
+ 'model' => 'gpt-4',
43
41
  'messages' => [{
44
42
  "role" => "assistant",
45
- "content" => keyword.to_s+" 소개하는 글을 1000자에서 2000자 사이로 만들어줘"
43
+ "content" => keyword.to_s+" 소개하는 글을 1500자에서 2500자 사이로 만들어줘"
46
44
  }]
47
45
  }
48
46
  answer = ''
@@ -73,10 +71,11 @@ class Chat
73
71
  'Authorization' => 'Bearer ' + @api_key
74
72
  }
75
73
  d = {
76
- 'model' => 'gpt-3.5-turbo',
74
+ #'model' => 'gpt-3.5-turbo',
75
+ 'model' => 'gpt-4',
77
76
  'messages' => [{
78
77
  "role" => "assistant",
79
- "content" => keyword.to_s+" 관련된 글을 1000자에서 2000자 사이로 만들어줘"
78
+ "content" => keyword.to_s+" 관련된 글을 1500자에서 2500자 사이로 만들어줘"
80
79
  }]
81
80
  }
82
81
  answer = ''
@@ -107,215 +106,218 @@ class Chat
107
106
  end
108
107
  end
109
108
 
110
- class Naver
111
- def initialize
112
- @seed = 1
113
- @cookie = ''
109
+ class Chat_title
110
+ def initialize(api_key)
111
+ @api_key = api_key
114
112
  end
115
-
116
- def chrome_start(proxy)
117
- if proxy == ''
118
- begin
119
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
120
- options = Selenium::WebDriver::Chrome::Options.new #(options: {"excludeSwitches" => ["enable-automation"]}) #자동화된 테스트...제거(options: {"excludeSwitches" => ["enable-automation"]})
121
- options.add_extension('./crx/app.crx')
122
- options.add_argument('--disable-blink-features=AutomationControlled')
123
- options.add_argument('--disable-popup-blocking')
124
- options.add_argument('--dns-prefetch-disable')
125
- options.add_argument('--disable-dev-shm-usage')
126
- options.add_argument('--disable-software-rasterizer')
127
- options.add_argument('--ignore-certificate-errors')
128
- options.add_argument('--disable-gpu') # GPU가속 끄기
129
- options.excludeSwitches('enable-automation') #자동화된 테스트...제거
130
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36') # user-agent 위조
131
-
132
- options.add_argument('--disable-web-security')
133
- options.add_argument('--allow-running-insecure-content')
134
- options.add_argument('--ignore-certificate-errors')
135
- options.add_argument('--allow-insecure-localhost')
136
- options.add_argument('--no-sandbox')
137
-
138
- options.add_argument('--disable-translate')
139
- options.add_argument('--disable-extensions-file-access-check')
140
- options.add_argument('--disable-impl-side-painting')
141
-
142
-
143
113
 
144
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
145
- rescue
146
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
147
- end
148
- else
149
- begin
150
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
151
- # profile = Selenium::WebDriver::Chrome::Profile.new
152
- # profile['network.proxy.type'] = 1
153
- # profile['network.proxy.http'] = proxy.split(':')[0]
154
- # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
155
- # options = Selenium::WebDriver::Chrome::Options.new
156
- # options.profile = profile
157
- options = Selenium::WebDriver::Chrome::Options.new #(options: {"excludeSwitches" => ["enable-automation"]}) #자동화된 테스트...제거(options: {"excludeSwitches" => ["enable-automation"]})
158
- options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
159
- options.add_extension('./crx/app.crx')
160
- options.add_argument('--disable-blink-features=AutomationControlled')
161
- options.add_argument('--disable-popup-blocking')
162
- options.add_argument('--dns-prefetch-disable')
163
- options.add_argument('--disable-dev-shm-usage')
164
- options.add_argument('--disable-software-rasterizer')
165
- options.add_argument('--ignore-certificate-errors')
166
- options.add_argument('--disable-gpu') # GPU가속 끄기
167
- options.excludeSwitches('enable-automation') #자동화된 테스트...제거
168
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36') # user-agent 위조
169
-
170
- options.add_argument('--disable-web-security')
171
- options.add_argument('--allow-running-insecure-content')
172
- options.add_argument('--ignore-certificate-errors')
173
- options.add_argument('--allow-insecure-localhost')
174
- options.add_argument('--no-sandbox')
175
-
176
- options.add_argument('--disable-translate')
177
- options.add_argument('--disable-extensions-file-access-check')
178
- options.add_argument('--disable-impl-side-painting')
179
-
114
+ def message(title)
115
+ url = 'https://api.openai.com/v1/chat/completions'
116
+ headers = {
117
+ 'Content-Type' => 'application/json',
118
+ 'Authorization' => 'Bearer ' + @api_key
119
+ }
120
+ data = {
121
+ 'model' => 'gpt-4',
122
+ 'messages' => [{
123
+ "role" => "system",
124
+ "content" => "너는 매우 친절하고 성의 있게 답변하는 AI 어시스턴트야."
125
+ },
126
+ {
127
+ "role" => "user",
128
+ "content" => "#{title}\n위 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘."
129
+ }]
130
+ }
180
131
 
181
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
182
- rescue => e
183
- puts e
184
- puts 'proxy error...'
185
- begin
186
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
187
- options.add_extension('./crx/app.crx')
188
- options.add_argument('--disable-blink-features=AutomationControlled')
189
- options.add_argument('--disable-popup-blocking')
190
- options.add_argument('--dns-prefetch-disable')
191
- options.add_argument('--disable-dev-shm-usage')
192
- options.add_argument('--disable-software-rasterizer')
193
- options.add_argument('--ignore-certificate-errors')
194
- options.add_argument('--disable-gpu') # GPU가속 끄기
195
- options.excludeSwitches('enable-automation') #자동화된 테스트...제거
196
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36') # user-agent 위조
197
-
198
- options.add_argument('--disable-web-security')
199
- options.add_argument('--allow-running-insecure-content')
200
- options.add_argument('--ignore-certificate-errors')
201
- options.add_argument('--allow-insecure-localhost')
202
- options.add_argument('--no-sandbox')
203
-
204
- options.add_argument('--disable-translate')
205
- options.add_argument('--disable-extensions-file-access-check')
206
- options.add_argument('--disable-impl-side-painting')
132
+ begin
133
+ req = HTTP.headers(headers).post(url, json: data)
134
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
135
+ response = JSON.parse(req.body.to_s)
136
+ puts "API Response: #{response}" # 전체 응답 출력
207
137
 
208
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
209
- rescue
210
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
211
- end
138
+ if req.status == 429
139
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
212
140
  end
141
+
142
+ # 응답 데이터에서 안전하게 값 추출
143
+ answer = response.dig('choices', 0, 'message', 'content')
144
+ answer ||= (title) # 응답이 없을 경우 기본 메시지 설정
145
+ rescue => e
146
+ puts "Error: #{e.message}"
147
+ answer = "오류가 발생했습니다."
213
148
  end
149
+
150
+ puts 'API return ==> '
151
+ puts answer
152
+ answer
214
153
  end
154
+ end
215
155
 
156
+ class Chat_content
157
+ def initialize(api_key)
158
+ @api_key = api_key
159
+ end
216
160
 
217
-
218
-
219
- def login(user_id, user_pw, proxy ,captcha_key)
220
- chrome_start(proxy)
221
- sleep(2)
222
- @captcha_key = captcha_key
223
- @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
224
- sleep(3)
225
- begin
226
- @driver.switch_to.window(@driver.window_handles[1])
227
- @driver.close()
228
- rescue
229
- @driver.switch_to.window(@driver.window_handles[0])
230
- end
231
- sleep(2)
232
- # @driver.close()
233
- sleep(2)
234
- ####################탭나누기 수정중######################################
235
- begin
236
- puts '-[√] 투 캡챠 api 입력 시도 1.......'.green
237
- sleep(1)
238
- @driver.switch_to.window(@driver.window_handles[0])
239
- sleep(1)
240
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
241
- sleep(1)
242
- Clipboard.copy(captcha_key)
243
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
244
- sleep(3)
245
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
246
- sleep(3)
247
- @driver.switch_to.alert.dismiss
248
- #팝업창 닫기
249
- #key_down('ctrl')
250
- #key_stroke('tab')
251
- #key_up('ctrl')
252
- #sleep(1)
253
- #@driver.close()
254
- rescue
255
- begin
256
- puts '-[√] 투 캡챠 api 입력 시도 2.......'.green
257
- sleep(1)
258
- @driver.switch_to.window(@driver.window_handles[0])
259
- sleep(1)
260
- @driver.find_element(:name, 'apiKey').click
261
- sleep(1)
262
- Clipboard.copy(captcha_key)
263
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
264
- sleep(3)
265
- @driver.find_element(:class_name, 'default-btn').click
266
- sleep(3)
267
- @driver.switch_to.alert.dismiss
268
- #팝업창 닫기
269
- #key_down('ctrl')
270
- #key_stroke('tab')
271
- #key_up('ctrl')
272
- #sleep(1)
273
- #@driver.close()
274
- rescue
275
- begin
276
- @driver.quit()
277
- rescue
278
- end
279
- end
280
- end
281
- @driver.switch_to.window(@driver.window_handles[0])
282
- ####################탭나누기 수정중######################################
283
- @user_id = user_id
284
- @user_id11 = user_id
285
- sleep(3)
286
- @driver.get('https://www.tistory.com/auth/login')
287
- sleep(3)
161
+ def message(content)
288
162
 
289
- user_cookie_file = Array.new
290
- begin
291
- Dir.entries('./cookie').each do |i|
292
- if i == '.' or i == '..'
163
+ url = 'https://api.openai.com/v1/chat/completions'
164
+ headers = {
165
+ 'Content-Type' => 'application/json',
166
+ 'Authorization' => 'Bearer ' + @api_key
167
+ }
168
+ data = {
169
+ 'model' => 'gpt-4',
170
+ 'messages' => [{
171
+ "role" => "system",
172
+ "content" => "너는 매우 친절하고 성의 있게 답변하는 AI 어시스턴트야."
173
+ },
174
+ {
175
+ "role" => "user",
176
+ "content" => "#{content}\nChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해"
177
+ }]
178
+ }
293
179
 
294
- else
295
- user_cookie_file << i
296
- end
180
+ begin
181
+ req = HTTP.headers(headers).post(url, json: data)
182
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
183
+ response = JSON.parse(req.body.to_s)
184
+ puts "API Response: #{response}" # 전체 응답 출력
185
+
186
+ if req.status == 429
187
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
297
188
  end
298
- rescue
299
- end
300
189
 
301
- @cookie4 = Hash.new
302
- if user_cookie_file.include?(user_id+'.txt')
303
- f = File.open('./cookie/'+user_id+'.txt', 'r')
304
- @cookie4 = JSON.parse(f.read())
305
- f.close
190
+ # 응답 데이터에서 안전하게 값 추출
191
+ answer = response.dig('choices', 0, 'message', 'content')
192
+ answer ||= (content) # 응답이 없을 경우 기본 메시지 설정
193
+ rescue => e
194
+ puts "Error: #{e.message}"
195
+ answer = "오류가 발생했습니다."
306
196
  end
307
197
 
308
- begin
309
- @cookie4.each do |i|
310
- p i
311
- @driver.manage.add_cookie(name: i['name'], value: i['value'], same_site: i['same_site'], domain: i['domain'], path: i['path'])
312
- end
313
- rescue
314
- end
198
+ puts 'API return ==> '
199
+ puts answer
200
+ answer
201
+ end
202
+ end
203
+
204
+
205
+ #############################################gpt############################################
206
+
207
+ class Naver
208
+ def initialize
209
+ @seed = 1
210
+ @cookie = ''
211
+ end
212
+
213
+ def chrome_start(proxy)
214
+ # 공통 옵션 설정
215
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
216
+ options = Selenium::WebDriver::Chrome::Options.new
217
+
218
+ options.add_extension('./crx/app.crx') # 확장 프로그램을 첫 번째 탭에 추가
219
+ options.add_argument('--disable-blink-features=AutomationControlled')
220
+ options.add_argument('--disable-popup-blocking')
221
+ options.add_argument('--dns-prefetch-disable')
222
+ options.add_argument('--disable-dev-shm-usage')
223
+ options.add_argument('--disable-software-rasterizer')
224
+ options.add_argument('--ignore-certificate-errors')
225
+ options.add_argument('--disable-gpu') # GPU 가속 끄기
226
+ options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36') # user-agent 위조
227
+ options.add_argument('--disable-web-security')
228
+ options.add_argument('--allow-running-insecure-content')
229
+ options.add_argument('--allow-insecure-localhost')
230
+ options.add_argument('--no-sandbox')
231
+ options.add_argument('--disable-translate')
232
+ options.add_argument('--disable-extensions-file-access-check')
233
+ options.add_argument('--disable-impl-side-painting')
234
+
235
+ # 자동화된 테스트 제거
236
+ options.exclude_switches = ['enable-automation']
237
+
238
+ options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
239
+ options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
240
+ #options.add_preference("profile.managed_default_content_settings.cookies", 2) # 쿠키 관련 팝업 차단
241
+ options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
242
+ options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
243
+
244
+
245
+ # Proxy 설정
246
+ if proxy != ''
247
+ options.add_argument('--proxy-server=' + proxy.to_s.force_encoding('utf-8'))
248
+ end
249
+
250
+ # 브라우저 실행
251
+ begin
252
+ # :capabilities에 options를 배열로 전달
253
+ capabilities = [options]
254
+
255
+ # Selenium WebDriver에서 options를 capabilities로 전달
256
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
257
+
315
258
 
316
259
  sleep(1)
260
+ # 두 번째 탭에서 로그인 페이지 열기
317
261
  @driver.get('https://www.tistory.com/auth/login')
262
+ sleep(1)
263
+
264
+ rescue => e
265
+
266
+ puts "Error: #{e.message}"
267
+ puts 'Using default Chrome driver without proxy'
268
+ # :capabilities에 options를 배열로 전달
269
+ capabilities = [options]
270
+
271
+ # Selenium WebDriver에서 options를 capabilities로 전달
272
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
273
+
274
+ # 첫 번째 탭에서 확장 프로그램을 로드
275
+ #@driver.get("chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html")
276
+ sleep(1)
277
+ # 두 번째 탭에서 로그인 페이지 열기
278
+ @driver.get('https://www.tistory.com/auth/login')
279
+ sleep(1)
280
+ end
281
+ end
282
+
283
+ def login(user_id, user_pw, proxy, captcha_api_key)
284
+ chrome_start(proxy)
285
+ @captcha_api_key = captcha_api_key
286
+ @user_id = user_id
287
+
288
+ user_cookie_file = []
289
+ begin
290
+ Dir.entries('./cookie').each do |i|
291
+ if i != '.' && i != '..'
292
+ user_cookie_file << i
293
+ end
294
+ end
295
+ rescue
296
+ end
297
+
298
+ @cookie4 = {}
299
+ if user_cookie_file.include?(user_id+'.txt')
300
+ f = File.open('./cookie/'+user_id+'.txt', 'r')
301
+ @cookie4 = JSON.parse(f.read)
302
+ f.close
303
+ end
304
+
305
+ # 기존 쿠키가 있으면 쿠키를 추가
306
+ begin
307
+ @cookie4.each do |i|
308
+ @driver.manage.add_cookie(name: i['name'], value: i['value'], same_site: i['same_site'], domain: i['domain'], path: i['path'])
309
+ end
310
+ rescue
311
+ end
312
+
313
+ @driver.switch_to.window(@driver.window_handles.last)
314
+ sleep(1.5)
315
+ @driver.get('https://www.tistory.com/auth/login')
316
+
317
+ sleep(1)
318
318
  begin
319
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
320
+ wait.until { @driver.find_element(:xpath, '//*[@id="cMain"]/div/div/div/div/a[2]/span[2]') }
319
321
  @driver.find_element(:xpath, '//*[@id="cMain"]/div/div/div/div/a[2]/span[2]').click
320
322
  check_cookie_login = 0
321
323
  rescue
@@ -323,45 +325,67 @@ class Naver
323
325
  end
324
326
 
325
327
  if check_cookie_login == 0
326
- sleep(3)
328
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
329
+ wait.until { @driver.find_element(:xpath, '//*[@id="loginId--1"]') }
327
330
  @driver.find_element(:xpath, '//*[@id="loginId--1"]').click
328
331
  Clipboard.copy(user_id)
332
+ sleep(0.5)
329
333
  @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
330
334
  puts '-[√] 1 아이디 입력.......'.yellow
331
- sleep(3)
335
+
336
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
337
+ wait.until { @driver.find_element(:xpath, '//*[@id="password--2"]') }
332
338
  @driver.find_element(:xpath, '//*[@id="password--2"]').click
333
339
  Clipboard.copy(user_pw)
340
+ sleep(0.5)
334
341
  @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
335
342
  puts '-[√] 2 비밀번호 입력.......'.yellow
336
- sleep(3)
343
+
344
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
345
+ wait.until { @driver.find_element(:xpath, '//*[@class="btn_g highlight submit"]') }
337
346
  @driver.find_element(:xpath, '//*[@type="submit"]').click
338
- #@driver.find_element(:xpath, '//*[@id="mainContent"]/div/div/form/div[4]/button[1]').click
339
347
  puts '-[√] 3 로그인 버튼 클릭.......'.yellow
340
-
341
- sleep(5)
342
-
343
-
344
- puts '-[√] 3 캡챠 발생 및 이메일 인증 유무 확인.......'.green
345
- sleep(1)
346
- puts '-[√] 3 캡챠 발생 및 이메일 인증 유무 확인.......'.green
347
- sleep(1)
348
- puts '-[√] 3 캡챠 발생 및 이메일 인증 유무 확인.......'.green
349
- sleep(1)
350
-
351
348
 
349
+ #캡챠 해제시
350
+ begin
351
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
352
+ wait.until { @driver.find_element(:xpath, '//*[@id="captchaContainer"]') }
353
+ puts '-[√] 로그인 중 캡챠 요구 발생 처리 진행.......'.yellow
354
+ sleep(1)
355
+ @driver.switch_to.window(@driver.window_handles[0])
356
+ sleep(1)
357
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
358
+ Clipboard.copy(captcha_api_key)
359
+ sleep(0.5)
360
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
361
+ sleep(0.5)
362
+ @driver.find_element(:xpath, '//*[@data-lang="login"]').click
363
+
364
+ begin
365
+ sleep(2)
366
+ @driver.switch_to.alert.dismiss
367
+ sleep(1)
368
+ rescue
369
+
370
+ end
352
371
 
372
+ # 두 번째 탭으로 전환
373
+ @driver.switch_to.window(@driver.window_handles[1])
353
374
 
354
375
  begin
376
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
377
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
355
378
  @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
356
379
  puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
357
380
  sleep(10)
381
+
358
382
  begin
359
383
  @driver.find_element(:xpath, '//*[@data-state="error"]').click
360
384
  puts '-[√] 1 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
361
385
  puts '-[√] 2 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
362
- @driver.quit()
386
+ sleep(1)
387
+ @driver.quit
363
388
  rescue
364
-
365
389
  # 타임아웃을 77초로 설정
366
390
  wait = Selenium::WebDriver::Wait.new(:timeout => 100)
367
391
  # 요소가 나타날 때까지 100초 동안 기다립니다.
@@ -373,89 +397,107 @@ class Naver
373
397
  @driver.find_element(:xpath, '//*[@id="password--2"]').click #비번 클릭
374
398
  sleep(1)
375
399
  @driver.action.send_keys(:enter).perform #엔터키 주기
376
- sleep(5)
377
- end
378
- rescue
379
- puts '-[√] 캡챠 인증 없음 확인.......'.yellow
380
- sleep(1)
381
- end
382
-
400
+ end
383
401
 
402
+ rescue
403
+ end
384
404
 
385
- begin
386
- puts '-[√]'
387
- puts '-[√] 이메일 인증 체크 확인 중.......'.yellow
388
- sleep(2)
389
- # 타임아웃을 10초로 설정
390
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
391
- #요소가 나타날 때까지 3초 동안 기다립니다.
392
- wait.until { @driver.find_element(:xpath, '//*[@class="ico_comm ico_mail"]') }
393
- @driver.find_element(:xpath, '//*[@class="ico_comm ico_mail"]')
394
- print "이메일 인증 요구 발생!! 수동으로 인증 완료 후 여기에 엔터를 쳐주세요".cyan
395
- input = gets.chomp()
396
- rescue
397
- puts '-[√] 이메일 인증 없음 확인.......'.yellow
398
- sleep(1)
399
- end
400
-
405
+ rescue
406
+ end
401
407
 
402
408
 
403
- begin
404
- puts '-[√]'
405
- puts '-[] 로그인 성공 여부 확인.......'.yellow
406
- @driver.get('https://www.tistory.com')
407
- sleep(2)
408
- # 타임아웃을 77초로 설정
409
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
410
- # 요소가 나타날 때까지 10초 동안 기다립니다.
411
- wait.until { @driver.find_element(:xpath, '//*[@class="thumb_profile"]') }
412
- sleep(1)
413
- @driver.find_element(:xpath, '//*[@class="thumb_profile"]').click
414
- puts '-[√] 로그인 성공 완료 포스팅 준비 중 .......'.yellow
415
- sleep(1)
416
- rescue
417
- puts '-[√]'
418
- puts '-[] 로그인 실패 확인 !! 종료 후 다음 작업 실행 준비.......'.red
419
- puts '-[] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
420
- sleep(1)
421
- @driver.quit()
422
- end
409
+ # 아이디/비밀번호 오류 처리 부분
410
+ begin
411
+ @driver.find_element(:xpath, '//*[@class="desc_error"]')
412
+ sleep(1)
413
+ @driver.quit
414
+ puts 'error = 아이디/비밀번호 오류'.yellow
415
+ rescue
416
+ end
417
+
418
+
419
+ #예외 변수
420
+ begin
421
+ # 타임아웃을 10초로 설정
422
+ wait = Selenium::WebDriver::Wait.new(:timeout => 1)
423
+ #요소가 나타날 때까지 3초 동안 기다립니다.
424
+ wait.until { @driver.find_element(:xpath, '//*[@class="ico_comm ico_mail"]') }
425
+ @driver.find_element(:xpath, '//*[@class="ico_comm ico_mail"]')
426
+ print "이메일 인증 요구 발생!! 수동으로 인증 완료 후 여기에 엔터를 쳐주세요".cyan
427
+ input = gets.chomp()
428
+ rescue
429
+ end
430
+
431
+ #예외 변수
432
+ begin
433
+ @driver.find_element(:xpath, '//*[@class="link_comm link_g"]').click
434
+ puts '비밀번호 재 요청 다음에하기 클릭'.yellow
435
+ sleep(1)
436
+ rescue
437
+ end
438
+
439
+ #예외 변수
440
+ begin
441
+ @driver.find_element(:xpath, '//*[@class="inner_error inner_error_type2"]')
442
+ puts 'error = 평소와 다른 로그인이 감지되어 추가 인증이 필요합니다.'.yellow
443
+ @driver.quit
444
+ rescue
445
+ end
446
+
447
+ #최종 로그인 실패시
448
+ begin
449
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
450
+ wait.until { @driver.find_element(:xpath, '//*[@class="my_tistory border_box"]') }
451
+ rescue => e
452
+ puts '-[√] 로그인 실패.......'.red
453
+ @driver.quit
454
+ return 0
455
+ end
456
+
423
457
  end
424
458
 
425
459
  @cookie = ''
426
- cookie2 = Array.new
460
+ cookie2 = []
427
461
  @driver.manage.all_cookies.each do |i|
428
- puts i
429
- @cookie += i[:name]+'='+i[:value]+'; '
430
462
  cookie2 << i
431
463
  end
432
464
 
465
+ # 쿠키 만료 시간을 1년으로 설정
466
+ cookie2.each do |cookie|
467
+ cookie[:expiry] = Time.now.to_i + 365 * 24 * 60 * 60 # 만료 시간을 1년 후로 설정
468
+ end
469
+
433
470
  File.open('./cookie/'+user_id+'.txt', 'w') do |ff|
434
471
  ff.write(cookie2.to_json)
435
472
  end
436
473
  end
437
-
438
474
 
439
475
  sleep(2)
440
476
 
441
- def update(title, content, option, dd_time, url, keyword)
477
+
478
+
479
+ def update(title, content, option, url, keyword, captcha_api_key)#dd_time
442
480
  puts 'start...'.yellow
443
481
  puts(url)
444
482
  sleep(1)
445
483
  @driver.get(url)
446
- sleep(5)
447
-
484
+ sleep(2)
485
+
448
486
 
449
487
 
450
488
  begin
451
- #@driver.switch_to.window(@driver.window_handles[1])
452
- @driver.switch_to.alert.dismiss
453
- rescue
454
- #@driver.switch_to.window(@driver.window_handles[0])
455
- #@driver.switch_to.alert.dismiss
489
+ # alert이 뜨기를 기다리기
490
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 10초 대기
491
+ alert = wait.until { @driver.switch_to.alert }
492
+
493
+ # alert 처리 (예: dismiss나 accept)
494
+ alert.dismiss # 또는 alert.accept
495
+ sleep(2)
496
+ rescue
497
+ sleep(1)
456
498
  end
457
499
 
458
- sleep(1)
500
+
459
501
 
460
502
 
461
503
 
@@ -489,7 +531,8 @@ class Naver
489
531
  rescue => e
490
532
  puts '-[√] 카테고리 ERROR 발생.......'.red
491
533
  puts '-[√] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
492
- puts e
534
+ @driver.quit
535
+ return 0
493
536
  end
494
537
 
495
538
 
@@ -503,8 +546,10 @@ class Naver
503
546
 
504
547
  begin
505
548
  @driver.find_element(:xpath, '//*[@id="post-title-inp"]').send_keys(title)
506
- rescue
507
- puts '-[√] 페이지 로드(로딩)시간 초과로 작업을 중지합니다.......'.red
549
+ rescue => e
550
+ @driver.quit
551
+ return 0
552
+ puts '-[√] 페이지 로드(로딩)시간 초과 및 알수없는 오류로 종료.......'.red
508
553
  puts '-[√] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
509
554
  puts e
510
555
  end
@@ -517,61 +562,26 @@ class Naver
517
562
 
518
563
  sleep(1)
519
564
 
565
+ begin
566
+ @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click()
567
+ @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click()
568
+ rescue => e
569
+ @driver.quit
570
+ return 0
571
+ puts '-[√] 페이지 로드(로딩)시간 초과 및 알수없는 오류로 종료.......'.red
572
+ puts '-[√] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
573
+
574
+ end
520
575
 
521
- @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click()
522
- @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click()
523
-
524
576
 
525
577
  puts content
526
578
  noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
527
579
  toomung = 0
528
580
  h = Hash.new
529
- # h[:authority] = 'blog.naver.com'
530
- # h[:method] = 'POST'
531
- # h[:path] = '/RabbitWrite.naver'
532
- # h[:scheme] = 'https'
533
- # h['accept'] = 'application/json, text/plain, */*'
534
- # h['accept-encoding'] = 'gzip, deflate, br'
535
- # h['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
536
- # h['content-type'] = 'application/x-www-form-urlencoded'
537
- # h['cookie'] = @cookie
538
- # h['origin'] = 'https://blog.naver.com'
539
- # h['referer'] = 'https://blog.naver.com/'+@user_id+'/postwrite?categoryNo=1'
540
- # h['sec-ch-ua'] = '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"'
541
- # h['sec-ch-ua-mobile'] = '?0'
542
- # h['sec-ch-ua-platform'] = '"Windows"'
543
- # h['sec-fetch-dest'] = 'empty'
544
- # h['sec-fetch-mode'] = 'cors'
545
- # h['sec-fetch-site'] = 'same-origin'
546
- # h['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'
581
+
547
582
 
548
583
  data = Hash.new
549
- # data['blogId'] = @user_id
550
- # data['documentModel'] = Hash.new
551
- # data['documentModel']['documentId'] = ''
552
- # data['documentModel']['document'] = Hash.new
553
- # data['documentModel']['document']['version'] = '2.6.0'
554
- # data['documentModel']['document']['theme'] = 'default'
555
- # data['documentModel']['document']['language'] = 'ko-KR'
556
- # data['documentModel']['document']['components'] = Array.new
557
- # data['documentModel']['document']['components'][0] = {
558
- # 'id' => create_id(),
559
- # 'layout' => 'default',
560
- # 'title' => [
561
- # {
562
- # 'id' => create_id(),
563
- # 'nodes' => [{
564
- # 'id' => create_id(),
565
- # 'value' => title,
566
- # '@ctype' => 'textNode'
567
- # }],
568
- # '@ctype' => 'paragraph'
569
- # }
570
- # ],
571
- # 'subTitle' => nil,
572
- # 'align' => 'left',
573
- # '@ctype' => 'documentTitle'
574
- # }
584
+
575
585
 
576
586
  check_position = 1
577
587
  noko.css('p').each do |i|
@@ -971,7 +981,7 @@ class Naver
971
981
  end
972
982
 
973
983
 
974
- #######################################여기까지 복원코드#########################################################
984
+
975
985
 
976
986
 
977
987
  #링크 넣는 코드 ↓
@@ -1042,22 +1052,7 @@ class Naver
1042
1052
  end
1043
1053
  end
1044
1054
  end
1045
- #@driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="editor-tistory_ifr"]'))
1046
- #아이프레임 선택
1047
- #sleep(0.5)
1048
- #@driver.find_element(:xpath, '//*[@id="tinymce"]/p').click
1049
- #아이프레임에서 코드 선택
1050
- #sleep(0.5)
1051
- #@driver.action.key_down(:control).key_down(:end).perform
1052
- #sleep(0.5)
1053
- #@driver.action.key_up(:control).key_up(:end).perform
1054
- #sleep(0.5)
1055
- #@driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
1056
- #sleep(0.5)
1057
- #@driver.switch_to.default_content()
1058
- #sleep(0.5)
1059
- #아이프레임 나오기
1060
-
1055
+
1061
1056
 
1062
1057
 
1063
1058
  @driver.action.key_down(:end).key_up(:end).perform
@@ -1069,52 +1064,10 @@ class Naver
1069
1064
 
1070
1065
  sleep(1)
1071
1066
 
1072
-
1073
- #sleep(1)
1074
- #@driver.action.key_down(:end).key_up(:end).perform
1075
- #sleep(0.5)
1076
- #@driver.action.key_down(:enter).key_up(:enter).perform
1077
-
1078
- #sleep(1)
1079
- ## 줄바꿈~~~~~~~~
1080
-
1081
-
1082
-
1083
- #@driver.find_element(:xpath, '/html/body/div[1]/div/main/div/div[1]').click
1084
- #빈공간 클릭
1085
- #sleep(1)
1086
- #@driver.action.key_down(:end).key_up(:end).perform
1087
- #스크롤 내리기
1088
- #sleep(1)
1089
-
1090
1067
  end
1091
1068
 
1092
1069
 
1093
-
1094
-
1095
-
1096
-
1097
-
1098
-
1099
-
1100
-
1101
-
1102
-
1103
-
1104
-
1105
-
1106
-
1107
-
1108
-
1109
-
1110
-
1111
-
1112
-
1113
-
1114
-
1115
-
1116
-
1117
- if option['중앙정렬'] == 'false'
1070
+ if option['중앙정렬'] == 'true'
1118
1071
  puts '-[√] 중앙정렬 선택.......'.yellow
1119
1072
  begin
1120
1073
 
@@ -1128,7 +1081,7 @@ class Naver
1128
1081
  sleep(1.5)
1129
1082
 
1130
1083
 
1131
- if option['좌측정렬'] == 'false'
1084
+ if option['좌측정렬'] == 'true'
1132
1085
  puts '-[√] 좌측정렬 선택.......'.yellow
1133
1086
  begin
1134
1087
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -1140,7 +1093,7 @@ class Naver
1140
1093
  sleep(1.5)
1141
1094
 
1142
1095
 
1143
- if option['우측정렬'] == 'false'
1096
+ if option['우측정렬'] == 'true'
1144
1097
  puts '-[√] 우측정렬 선택.......'.yellow
1145
1098
  begin
1146
1099
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -1167,224 +1120,287 @@ class Naver
1167
1120
  #태그 입력 항목
1168
1121
 
1169
1122
  sleep(1.5)
1170
-
1171
- @driver.find_element(:xpath, '/html/body/div[1]/div/div[2]/div[3]/button').click
1172
- #1차 완료버튼
1173
- sleep(1.5)
1174
-
1175
- # 타임아웃을 10초로 설정
1176
- wait = Selenium::WebDriver::Wait.new(:timeout => 60)
1177
- #요소가 나타날 때까지 60초 동안 기다립니다.
1178
- wait.until { @driver.find_element(:xpath, '//*[@id="open20"]') }
1179
-
1180
-
1181
- if option['전체공개'] == 'false'
1182
- puts '-[√] 전체공개 선택.......'.yellow
1183
- begin
1184
- sleep(2)
1185
- @driver.find_element(:xpath, '//*[@id="open20"]').click
1186
- rescue
1187
- end
1188
- end
1189
- sleep(2)
1190
-
1191
- if option['비공개'] == 'false'
1192
- puts '-[√] 비공개 선택.......'.yellow
1193
- begin
1194
- sleep(2)
1195
- @driver.find_element(:xpath, '//*[@id="open0"]').click
1196
- rescue
1197
- end
1198
- end
1199
- sleep(2)
1200
-
1201
- if option['댓글허용'] == 'false'
1202
- puts '-[√] 댓글허용 선택.......'.yellow
1203
- begin
1204
- sleep(2)
1205
- @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1206
- sleep(2)
1207
- @driver.find_element(:partial_link_text, '댓글 허용').click
1208
- rescue
1209
- end
1210
- end
1211
- sleep(2)
1212
-
1213
- if option['댓글 비 허용'] == 'false'
1214
- puts '-[√] 댓글 비 허용 선택.......'.yellow
1215
- begin
1216
- sleep(2)
1217
- @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1218
- sleep(2)
1219
- @driver.find_element(:partial_link_text, '댓글 비허용').click
1220
- rescue
1221
- end
1222
- end
1223
-
1224
1123
 
1225
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1226
- sleep(1)
1227
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1228
- sleep(1)
1229
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1230
- sleep(1)
1231
-
1232
- begin
1233
- sleep(1)
1234
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1235
- @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼 (xpath값에서 data-state="ready를 지목하고자 한다면 //*[@data-state="ready"] 입력)
1236
- puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
1237
- sleep(10)
1124
+ ##################글 발행##################
1125
+
1126
+ if option['글발생하기'] == 'true'
1127
+ puts '-[√] 글 발행 선택.......'.yellow
1238
1128
  begin
1239
- sleep(1)
1240
- @driver.find_element(:xpath, '//*[@data-state="error"]').click #캡챠 해제 오류 버튼
1241
- puts '-[] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1242
- sleep(1)
1243
- puts '-[√] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1244
- sleep(1)
1245
- @driver.close
1246
- puts '-[√] 작업 종료 중........다음 포스팅 작업을 준비 합니다........'.red
1247
- sleep(1)
1248
- sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1249
- @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1250
- rescue
1251
- # 타임아웃을 100초로 설정
1252
- wait = Selenium::WebDriver::Wait.new(:timeout => 100)
1253
- # 요소가 나타날 때까지 100초 동안 기다립니다.
1254
- wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
1255
- sleep(2)
1256
- @driver.find_element(:xpath, '//*[@data-state="solved"]').click #캡챠 해제 완료 버튼
1257
- puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
1258
- sleep(3.7)
1259
- puts '-[√] 등록 버튼 클릭.......'.yellow
1260
- sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1261
- @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1262
- puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1263
- sleep(5)
1264
- @driver.find_element(:xpath, '//*[@class="post_cont"]')
1265
- sleep(1)
1266
- puts '-[√] 포스트 등록 완료.......'.yellow
1267
- @driver.close
1268
- end
1269
- rescue
1270
- #puts '-[체크] 등록 버튼 클릭.......'
1271
- sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1272
- @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1273
- puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1274
-
1275
- ###########포스트 캡챠해제 팝업 시 재시도 작업 시작▼▼▼▼▼▼▼▼▼▼▼▼
1276
- begin
1277
- sleep(1)
1278
- @driver.switch_to.alert.accept
1279
- puts '-[√] 캡챠 체크 시간 초과!! 재 등록 시도.......'.green
1280
- sleep(2)
1281
- @driver.get(url)
1282
- puts '-[√] 등록 내용 불러오기 시도.......'.yellow
1283
- sleep(2)
1284
- @driver.switch_to.alert.accept
1285
- sleep(2)
1286
- puts '-[√] 재 등록 시도 시작.......'.yellow
1287
- @driver.find_element(:xpath, '//*[@id="publish-layer-btn"]').click
1288
- sleep(2)
1129
+
1130
+
1131
+ @driver.find_element(:xpath, '/html/body/div[1]/div/div[2]/div[3]/button').click
1132
+ #1차 완료버튼
1133
+ sleep(1.5)
1289
1134
 
1290
1135
  # 타임아웃을 10초로 설정
1291
1136
  wait = Selenium::WebDriver::Wait.new(:timeout => 60)
1292
1137
  #요소가 나타날 때까지 60초 동안 기다립니다.
1293
1138
  wait.until { @driver.find_element(:xpath, '//*[@id="open20"]') }
1294
-
1295
1139
 
1296
- if option['전체공개'] == 'false'
1140
+
1141
+ if option['전체공개'] == 'true'
1297
1142
  puts '-[√] 전체공개 선택.......'.yellow
1298
1143
  begin
1299
- sleep(2)
1144
+
1300
1145
  @driver.find_element(:xpath, '//*[@id="open20"]').click
1146
+ sleep(1)
1301
1147
  rescue
1302
1148
  end
1303
1149
  end
1304
- sleep(2)
1305
-
1306
- if option['비공개'] == 'false'
1150
+
1151
+
1152
+ if option['비공개'] == 'true'
1307
1153
  puts '-[√] 비공개 선택.......'.yellow
1308
1154
  begin
1309
- sleep(2)
1310
1155
  @driver.find_element(:xpath, '//*[@id="open0"]').click
1156
+ sleep(1)
1311
1157
  rescue
1312
1158
  end
1313
1159
  end
1314
- sleep(2)
1315
-
1316
- if option['댓글허용'] == 'false'
1160
+
1161
+
1162
+ if option['댓글허용'] == 'true'
1317
1163
  puts '-[√] 댓글허용 선택.......'.yellow
1318
1164
  begin
1319
- sleep(2)
1165
+
1320
1166
  @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1321
1167
  sleep(2)
1322
1168
  @driver.find_element(:partial_link_text, '댓글 허용').click
1169
+ sleep(1)
1323
1170
  rescue
1324
1171
  end
1325
1172
  end
1326
1173
  sleep(2)
1327
-
1328
- if option['댓글 비 허용'] == 'false'
1174
+
1175
+ if option['댓글 비 허용'] == 'true'
1329
1176
  puts '-[√] 댓글 비 허용 선택.......'.yellow
1330
1177
  begin
1331
- sleep(2)
1332
1178
  @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1333
1179
  sleep(2)
1334
1180
  @driver.find_element(:partial_link_text, '댓글 비허용').click
1181
+ sleep(1)
1335
1182
  rescue
1336
1183
  end
1337
1184
  end
1338
-
1339
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1340
- sleep(1)
1341
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1342
- sleep(1)
1343
- puts '-[√] 캡챠 발생 유무 확인.......'.green
1344
- sleep(1)
1345
-
1346
- begin
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+ #캡챠 해제시######################################################################
1195
+ begin
1196
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3.7)
1197
+ wait.until { @driver.find_element(:xpath, '//*[@id="captchaContainer"]') }
1198
+ puts '-[√] 로그인 중 캡챠 요구 발생 처리 진행.......'.yellow
1347
1199
  sleep(1)
1348
- puts '-[] 캡챠 발생 유무 확인.......'.green
1349
- @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼 (xpath값에서 data-state="ready를 지목하고자 한다면 //*[@data-state="ready"] 입력)
1200
+ @driver.switch_to.window(@driver.window_handles[0])
1201
+ sleep(1)
1202
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
1203
+ sleep(0.5)
1204
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').clear
1205
+ sleep(0.5)
1206
+ Clipboard.copy(captcha_api_key)
1207
+ sleep(0.5)
1208
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1209
+ sleep(0.5)
1210
+ @driver.find_element(:xpath, '//*[@data-lang="login"]').click
1211
+
1212
+ begin
1213
+ sleep(2)
1214
+ @driver.switch_to.alert.dismiss
1215
+ sleep(1)
1216
+ rescue
1217
+
1218
+ end
1219
+
1220
+ # 두 번째 탭으로 전환
1221
+ @driver.switch_to.window(@driver.window_handles[1])
1222
+
1223
+ begin
1224
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
1225
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
1226
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
1350
1227
  puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
1351
1228
  sleep(10)
1229
+
1230
+ begin
1231
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click
1232
+ puts '-[√] 1 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
1233
+ puts '-[√] 2 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
1234
+
1235
+ @driver.quit
1236
+ puts '-[√] 다음 작업을 진행합니다. 약 10~60초 소요 될 수 있습니다.......'.red
1237
+ rescue
1238
+ # 타임아웃을 77초로 설정
1239
+ wait = Selenium::WebDriver::Wait.new(:timeout => 100)
1240
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
1241
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
1242
+ sleep(1)
1243
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click
1244
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
1245
+ sleep(1)
1246
+
1247
+ end
1248
+
1249
+ rescue
1250
+ end
1251
+
1252
+ rescue
1253
+ end
1254
+ #캡챠 해제시######################################################################
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+ #sleep(dd_time.to_i) # 등록버튼 누르기 전 딜레이
1262
+ # 등록 버튼 클릭
1263
+ @driver.find_element(:xpath, '//*[@id="publish-btn"]').click
1264
+ puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1265
+ sleep(2)
1266
+ ###########포스트 캡챠해제 팝업 시 재시도 작업 시작▼▼▼▼▼▼▼▼▼▼▼▼
1267
+ begin
1268
+ sleep(1)
1269
+ @driver.switch_to.alert.accept
1270
+ puts '-[√] 캡챠 체크 시간 초과!! 재 등록 시도.......'.green
1271
+ sleep(2)
1272
+ @driver.get(url)
1273
+ puts '-[√] 등록 내용 불러오기 시도.......'.yellow
1274
+ sleep(2)
1275
+ @driver.switch_to.alert.accept
1276
+ sleep(2)
1277
+ puts '-[√] 재 등록 시도 시작.......'.yellow
1278
+ @driver.find_element(:xpath, '//*[@id="publish-layer-btn"]').click
1279
+ sleep(2)
1280
+
1281
+ # 타임아웃을 10초로 설정
1282
+ wait = Selenium::WebDriver::Wait.new(:timeout => 60)
1283
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1284
+ wait.until { @driver.find_element(:xpath, '//*[@id="open20"]') }
1285
+
1286
+ if option['전체공개'] == 'true'
1287
+ puts '-[√] 전체공개 선택.......'.yellow
1288
+ begin
1289
+
1290
+ @driver.find_element(:xpath, '//*[@id="open20"]').click
1291
+ sleep(2)
1292
+ rescue
1293
+ end
1294
+ end
1295
+
1296
+
1297
+ if option['비공개'] == 'true'
1298
+ puts '-[√] 비공개 선택.......'.yellow
1299
+ begin
1300
+ @driver.find_element(:xpath, '//*[@id="open0"]').click
1301
+ sleep(2)
1302
+ rescue
1303
+ end
1304
+ end
1305
+
1306
+
1307
+ if option['댓글허용'] == 'true'
1308
+ puts '-[√] 댓글허용 선택.......'.yellow
1309
+ begin
1310
+
1311
+ @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1312
+ sleep(2)
1313
+ @driver.find_element(:partial_link_text, '댓글 허용').click
1314
+ sleep(2)
1315
+ rescue
1316
+ end
1317
+ end
1318
+ sleep(2)
1319
+
1320
+ if option['댓글 비 허용'] == 'true'
1321
+ puts '-[√] 댓글 비 허용 선택.......'.yellow
1322
+ begin
1323
+ @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1324
+ sleep(2)
1325
+ @driver.find_element(:partial_link_text, '댓글 비허용').click
1326
+ sleep(2)
1327
+ rescue
1328
+ end
1329
+ end
1330
+
1352
1331
  begin
1353
1332
  sleep(1)
1354
- @driver.find_element(:xpath, '//*[@data-state="error"]').click #캡챠 해제 오류 버튼
1355
- puts '-[√] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1356
- sleep(1)
1357
- puts '-[√] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1358
- sleep(1)
1359
- @driver.close
1360
- puts '-[√] 작업 종료 중........다음 포스팅 작업을 준비 합니다........'.red
1361
- sleep(1)
1362
- sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1363
- @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1333
+ puts '-[] 캡챠 발생 유무 확인.......'.green
1334
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼 (xpath값에서 data-state="ready를 지목하고자 한다면 //*[@data-state="ready"] 입력)
1335
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
1336
+ sleep(10)
1337
+ begin
1338
+ sleep(1)
1339
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click #캡챠 해제 오류 버튼
1340
+ puts '-[√] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1341
+ sleep(1)
1342
+ puts '-[] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1343
+ sleep(1)
1344
+ @driver.close
1345
+ puts '-[√] 작업 종료 중........다음 포스팅 작업을 준비 합니다........'.red
1346
+ sleep(1)
1347
+ sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1348
+ @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1349
+ rescue
1350
+ # 타임아웃을 100초로 설정
1351
+ wait = Selenium::WebDriver::Wait.new(:timeout => 100)
1352
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
1353
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
1354
+ sleep(2)
1355
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click #캡챠 해제 완료 버튼
1356
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
1357
+ sleep(3.7)
1358
+ end
1364
1359
  rescue
1365
- # 타임아웃을 100초로 설정
1366
- wait = Selenium::WebDriver::Wait.new(:timeout => 100)
1367
- # 요소가 나타날 때까지 100초 동안 기다립니다.
1368
- wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
1369
- sleep(2)
1370
- @driver.find_element(:xpath, '//*[@data-state="solved"]').click #캡챠 해제 완료 버튼
1371
- puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
1372
- sleep(3.7)
1373
1360
  end
1361
+
1362
+ @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1363
+ puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1374
1364
  rescue
1375
1365
  end
1376
- sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1377
- @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1378
- puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1366
+
1367
+
1368
+
1369
+ # 포스트 등록 완료 확인
1370
+ begin
1371
+ # 포스트 등록 완료를 확인할 수 있는 요소(예: 등록 후 확인 페이지로 이동)
1372
+ wait.until { @driver.find_element(:xpath, '//*[@class="post_cont"]') }
1373
+ puts '-[√] 포스트 등록 완료.......'.yellow
1374
+ sleep(1.5)
1375
+ @driver.quit
1376
+ rescue => e
1377
+ puts '-[×] 포스트 등록 실패!'.red
1378
+ @driver.quit
1379
+ return 0
1380
+ end
1381
+
1379
1382
  rescue
1380
1383
  end
1381
- ###########포스트 캡챠해제 팝업 시 재시도 작업 끝 ▲▲▲▲▲▲▲▲▲▲▲▲
1382
- sleep(5)
1383
- @driver.find_element(:xpath, '//*[@class="post_cont"]')
1384
- sleep(1)
1385
- puts '-[√] 포스트 등록 완료.......'.yellow
1386
- @driver.close
1387
1384
  end
1385
+
1386
+
1387
+ if option['글임시저장'] == 'true'
1388
+ puts '-[√] 임시 저장 선택.......'.yellow
1389
+ begin
1390
+
1391
+ @driver.find_element(:xpath, '//*[@class="btn btn-draft"]').click
1392
+ sleep(1.5)
1393
+ @driver.quit
1394
+ rescue
1395
+ end
1396
+ end
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1388
1404
 
1389
1405
 
1390
1406
  end
@@ -1452,10 +1468,19 @@ class Wordpress
1452
1468
 
1453
1469
  def get_naver_text(q)
1454
1470
  begin
1455
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1456
- @driver = Selenium::WebDriver.for :chrome
1471
+ options = Selenium::WebDriver::Chrome::Options.new
1472
+ # :capabilities에 options를 배열로 전달
1473
+ capabilities = [options]
1474
+
1475
+ # Selenium WebDriver에서 options를 capabilities로 전달
1476
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1457
1477
  rescue
1458
- @driver = Selenium::WebDriver.for :chrome
1478
+ options = Selenium::WebDriver::Chrome::Options.new
1479
+ # :capabilities에 options를 배열로 전달
1480
+ capabilities = [options]
1481
+
1482
+ # Selenium WebDriver에서 options를 capabilities로 전달
1483
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1459
1484
  end
1460
1485
  @driver.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page=3&query='+q.to_s+'&research_url=&sm=tab_pge&start=16&where=web')
1461
1486
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1485,10 +1510,19 @@ class Wordpress
1485
1510
 
1486
1511
  def get_naver_text2(keyword)
1487
1512
  begin
1488
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1489
- @driver = Selenium::WebDriver.for :chrome
1513
+ options = Selenium::WebDriver::Chrome::Options.new
1514
+ # :capabilities에 options를 배열로 전달
1515
+ capabilities = [options]
1516
+
1517
+ # Selenium WebDriver에서 options를 capabilities로 전달
1518
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1490
1519
  rescue
1491
- @driver = Selenium::WebDriver.for :chrome
1520
+ options = Selenium::WebDriver::Chrome::Options.new
1521
+ # :capabilities에 options를 배열로 전달
1522
+ capabilities = [options]
1523
+
1524
+ # Selenium WebDriver에서 options를 capabilities로 전달
1525
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1492
1526
  end
1493
1527
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1494
1528
  for n3 in 1..10
@@ -1525,108 +1559,28 @@ class Wordpress
1525
1559
 
1526
1560
 
1527
1561
 
1528
- def chrome_start(url, user_id, user_pw, captcha_key)
1562
+ def chrome_start(url, user_id, user_pw, captcha_api_key)
1529
1563
  @url = url
1530
1564
  @user_id = user_id
1531
1565
  @user_pw = user_pw
1532
- @captcha_key = captcha_key
1566
+ @captcha_api_key = captcha_api_key
1533
1567
  begin
1534
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1535
- @driver = Selenium::WebDriver.for :chrome
1568
+ options = Selenium::WebDriver::Chrome::Options.new
1569
+ # :capabilities에 options를 배열로 전달
1570
+ capabilities = [options]
1571
+
1572
+ # Selenium WebDriver에서 options를 capabilities로 전달
1573
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1536
1574
  rescue
1537
- @driver = Selenium::WebDriver.for :chrome
1538
- end
1539
- end
1540
-
1541
- def login
1542
- @driver.get(@url+'/wp-admin')
1543
- @driver.find_element(:xpath , '//*[@id="user_login"]').send_keys(@user_id)
1544
- @driver.find_element(:xpath , '//*[@id="user_pass"]').send_keys(@user_pw)
1545
- @driver.find_element(:xpath , '//*[@id="wp-submit"]').click
1546
- @cookie = Hash.new
1547
- @driver.manage.all_cookies.each do |i|
1548
- @cookie[i[:name]] = i[:value]
1549
- end
1550
- sleep(2)
1551
- begin
1552
- puts @driver.find_element(:xpath , '/html/body/div/div/div[1]/div[1]/div/div[1]/a[1]/span').text
1553
- @driver.close
1554
- return 1
1555
- rescue => e
1556
- puts e
1557
- @driver.close
1558
- return 0
1575
+ # :capabilities에 options를 배열로 전달
1576
+ capabilities = [options]
1577
+
1578
+ # Selenium WebDriver에서 options를 capabilities로 전달
1579
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1559
1580
  end
1560
1581
  end
1561
1582
 
1562
- def update
1563
- http = HTTP.cookies(@cookie).get(@url+'/wp-admin/post-new.php')
1564
- noko = Nokogiri::HTML(http.to_s)
1565
- @wpnonce = http.to_s.split('_wpnonce":"')[1].split('"')[0]
1566
- @data2 = Hash.new
1567
- @data2['_wpnonce'] = noko.xpath('//*[@id="_wpnonce"]')[0]['value']
1568
- @data2['_wp_http_referer'] = '/wp-admin/post-new.php'
1569
- @data2['user_ID'] = '1'
1570
- @data2['action'] = 'editpost'
1571
- @data2['originalaction'] = 'editpost'
1572
- @data2['post_author'] = '1'
1573
- @data2['post_type'] = 'post'
1574
- @data2['original_post_status'] = 'auto-draft'
1575
- @data2['referredby'] = @url+'/wp-admin/update-core.php'
1576
- @data2['_wp_original_http_referer'] = @url+'/wp-admin/update-core.php'
1577
- @data2['auto_draft'] = nil
1578
- @data2['post_ID'] = noko.xpath('//*[@id="post_ID"]')[0]['value']
1579
- @data2['meta-box-order-nonce'] = noko.xpath('//*[@id="meta-box-order-nonce"]')[0]['value']
1580
- @data2['closedpostboxesnonce'] = noko.xpath('//*[@id="closedpostboxesnonce"]')[0]['value']
1581
- @data2['post_title'] = 'title3'
1582
- @data2['samplepermalinknonce'] = noko.xpath('//*[@id="samplepermalinknonce"]')[0]['value']
1583
- @data2['content'] = 'content3'
1584
- @data2['wp-preview'] = nil
1585
- @data2['hidden_post_status'] = 'draft'
1586
- @data2['post_status'] = 'draft'
1587
- @data2['hidden_post_password'] = nil
1588
- @data2['hidden_post_visibility'] = 'public'
1589
- @data2['visibility'] = 'post'
1590
- @data2['post_password'] = nil
1591
- @data2['mm'] = '10'
1592
- @data2['jj'] = '24'
1593
- @data2['aa'] = '2022'
1594
- @data2['hh'] = '02'
1595
- @data2['mn'] = '41'
1596
- @data2['ss'] = '32'
1597
- @data2['hidden_mm'] = '10'
1598
- @data2['cur_mm'] = '10'
1599
- @data2['hidden_jj'] = '24'
1600
- @data2['cur_jj'] = '24'
1601
- @data2['hidden_aa'] = '2022'
1602
- @data2['cur_aa'] = '2022'
1603
- @data2['hidden_hh'] = '02'
1604
- @data2['cur_hh'] = '02'
1605
- @data2['hidden_mn'] = '41'
1606
- @data2['cur_mn'] = '41'
1607
- @data2['original_publish'] = '공개'
1608
- @data2['publish'] = '공개'
1609
- @data2['post_format'] = '0'
1610
- @data2['post_category[]'] = '0'
1611
- @data2['newcategory'] = '새 카테고리 이름'
1612
- @data2['newcategory_parent'] = -1
1613
- @data2['_ajax_nonce-add-category'] = noko.xpath('//*[@id="_ajax_nonce-add-category"]')[0]['value']
1614
- @data2['tax_input[post_tag]'] = nil
1615
- @data2['newtag[post_tag]'] = nil
1616
- @data2['_thumbnail_id'] = -1
1617
- @data2['excerpt'] = nil
1618
- @data2['trackback_url'] = nil
1619
- @data2['metakeyinput'] = nil
1620
- @data2['metavalue'] = nil
1621
- @data2['_ajax_nonce-add-meta'] = noko.xpath('//*[@id="_ajax_nonce-add-meta"]')[0]['value']
1622
- @data2['advanced_view'] = '1'
1623
- @data2['comment_status'] = 'open'
1624
- @data2['ping_status'] = 'open'
1625
- @data2['post_name'] = nil
1626
- @data2['post_author_override'] = '1'
1627
- #result_http = HTTP.cookies(@cookie).post(@url+'/wp-admin/post.php', :form => @data)
1628
- return @data2
1629
- end
1583
+
1630
1584
 
1631
1585
  def auto_image
1632
1586
  begin
@@ -1859,7 +1813,7 @@ class Wordpress
1859
1813
 
1860
1814
  while true
1861
1815
  for n in 0..@data['table'].length-1
1862
- @data['table'][n][10] = 0
1816
+ @data['table'][n][8] = 0
1863
1817
  end
1864
1818
 
1865
1819
  while true
@@ -1881,6 +1835,7 @@ class Wordpress
1881
1835
  option['category'] = ''
1882
1836
  end
1883
1837
 
1838
+
1884
1839
  #begin
1885
1840
  # option['category2'] = table[5].to_s.force_encoding('utf-8').to_s
1886
1841
  # if option['category2'].to_s == '편집모드'
@@ -1892,10 +1847,10 @@ class Wordpress
1892
1847
 
1893
1848
  option['proxy'] = ''
1894
1849
  if @data['포스트설정']['프록시'].checked?
1895
- if table[6].to_s.include?('ex)') or table[6].to_i == 0
1850
+ if table[5].to_s.include?('ex)') or table[5].to_i == 0
1896
1851
  option['proxy'] = @data['포스트설정']['프록시리스트'].sample.to_s
1897
1852
  else
1898
- option['proxy'] = table[6].to_s.force_encoding('utf-8').to_s
1853
+ option['proxy'] = table[5].to_s.force_encoding('utf-8').to_s
1899
1854
  end
1900
1855
  end
1901
1856
 
@@ -1903,9 +1858,10 @@ class Wordpress
1903
1858
 
1904
1859
 
1905
1860
 
1906
- puts table[7]
1907
- puts table[10]
1908
- if table[7].to_i > table[10].to_i
1861
+ puts table[6]
1862
+ puts table[8]
1863
+
1864
+ if table[6].to_i > table[8].to_i
1909
1865
  if @data['포스트설정']['테더링'].checked?
1910
1866
  puts 'tedering ip change...'
1911
1867
  stdout, stderr, status = Open3.capture3('./adb devices')
@@ -1953,6 +1909,14 @@ class Wordpress
1953
1909
  end
1954
1910
  end
1955
1911
  end
1912
+
1913
+ if @data['포스트설정']['gpt제목'].checked?
1914
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
1915
+ gpt_text1 = chat.message(title)
1916
+ title = gpt_text1.to_s
1917
+ end
1918
+
1919
+
1956
1920
  @data['table'][index][-1] = 5
1957
1921
  @data['table'] << []
1958
1922
  @data['table'].pop
@@ -1990,6 +1954,25 @@ class Wordpress
1990
1954
  end
1991
1955
  end
1992
1956
  end
1957
+
1958
+ if @data['포스트설정']['gpt내용'].checked?
1959
+ api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
1960
+ #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
1961
+ #imotcon_change = @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8')
1962
+ #template_change = @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8')
1963
+ #ttdanar_change = @data['포스트설정']['단어링크적용단어'].text.to_s.force_encoding('utf-8')
1964
+ #sajine_change = @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8')
1965
+ #mov_change = @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8')
1966
+ #map_change = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8')
1967
+ #inyong9_change = @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8')
1968
+
1969
+
1970
+ chat = Chat_content.new(api_key)
1971
+ gpt_text3 = chat.message(content)
1972
+ content = gpt_text3.to_s
1973
+ end
1974
+
1975
+
1993
1976
  content_tag = content.split('@##@')[1]
1994
1977
  content = content.split('@##@')[0]
1995
1978
  @data['table'][index][-1] = 15
@@ -2006,14 +1989,14 @@ class Wordpress
2006
1989
  proxy = table[3].to_s
2007
1990
  user_id = table[1].to_s
2008
1991
  user_pw = table[2].to_s
2009
- captcha_key = table[6].to_s
1992
+ captcha_api_key = @data['포스트설정']['captcha_api_key'].text.to_s.force_encoding('utf-8')
2010
1993
  naver = Naver.new
2011
1994
  @data['table'][index][-1] = 25
2012
1995
  @data['table'] << []
2013
1996
  @data['table'].pop
2014
1997
 
2015
- #네이버로그인
2016
- login_check = naver.login(user_id, user_pw, option['proxy'], captcha_key)
1998
+ #네이버로그인login(user_id, user_pw, proxy ,captcha_api_key)
1999
+ login_check = naver.login(user_id, user_pw, option['proxy'], captcha_api_key)
2017
2000
  if login_check == 0
2018
2001
  black_users << table[1].to_s
2019
2002
  next
@@ -2185,11 +2168,11 @@ class Wordpress
2185
2168
  content = content2
2186
2169
  end
2187
2170
  end
2188
-
2171
+
2189
2172
  @data['table'][index][-1] = 50
2190
2173
  @data['table'] << []
2191
2174
  @data['table'].pop
2192
- if @data['포스트설정']['gpt'].checked?
2175
+ if @data['포스트설정']['gpt키워드'].checked?
2193
2176
  chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2194
2177
  gpt_text = chat.message(keyword)
2195
2178
  content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
@@ -2210,7 +2193,7 @@ class Wordpress
2210
2193
  joongbok_check = 0
2211
2194
  counter10 = 0
2212
2195
  while joongbok_check == 0
2213
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2196
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2214
2197
  content22 = content.split("(자동생성글)")[1].split("\n")
2215
2198
  else
2216
2199
  content22 = content.split("\n")
@@ -2234,12 +2217,12 @@ class Wordpress
2234
2217
  content2 = content.split("\n")
2235
2218
  end
2236
2219
 
2237
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2220
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2238
2221
  content2 = content.split("(자동생성글)")[1].split("\n")
2239
2222
  position.pop
2240
2223
  end
2241
2224
 
2242
- if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt'].checked? == false
2225
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2243
2226
  content2 = content.split("\n")
2244
2227
  end
2245
2228
 
@@ -2285,7 +2268,7 @@ class Wordpress
2285
2268
  content = content3.join("\n")
2286
2269
  end
2287
2270
 
2288
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2271
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2289
2272
  content2.each_with_index do |con, index|
2290
2273
  if position.include?(index)
2291
2274
  insert_keyword_text = keyword.to_s
@@ -2315,7 +2298,7 @@ class Wordpress
2315
2298
  end
2316
2299
  end
2317
2300
 
2318
- if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt'].checked? == false
2301
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2319
2302
  begin
2320
2303
  content2.each_with_index do |con, index|
2321
2304
  if position.include?(index)
@@ -2374,101 +2357,70 @@ class Wordpress
2374
2357
  end
2375
2358
 
2376
2359
  image_thum_ids = Array.new
2377
-
2378
2360
  image_memory = Array.new
2379
-
2361
+
2380
2362
  if @data['포스트설정']['내용사진자동삽입'].checked?
2381
2363
  puts '내용사진자동삽입...'
2364
+
2382
2365
  sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2383
2366
  en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2367
+
2384
2368
  begin
2385
2369
  cn = rand(sn..en)
2386
2370
  rescue
2387
2371
  cn = 0
2388
2372
  puts 'cn = rand(sn..en) error cn = 1'
2389
2373
  end
2390
-
2374
+
2391
2375
  if cn != 0
2392
- position = Array.new
2393
- if @data['포스트설정']['내용과자동생성'].checked?
2394
- for n in 1..cn
2395
- position << rand(0..(content.split("(자동생성글)")[1].split("\n").length-1))
2396
- sleep(2)
2397
- end
2398
- position.pop
2399
- else
2400
- for n in 1..cn
2401
- position << rand(0..(content.split("\n").length-2))
2402
- sleep(2)
2403
- end
2404
- end
2405
-
2406
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2407
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2408
- content55 = content.split("(자동생성글)")[1].to_s
2409
-
2410
- else
2411
- content55 = ''
2412
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2413
- end
2414
-
2415
- p content5
2416
- puts content55
2417
- p position
2418
-
2419
- while true
2420
- check11 = 0
2421
- for nn in 0..position.length-1
2422
- if content5[position[nn]].to_s.include?('style') or content5[position[nn]].to_s.include?('<') or content5[position[nn]].to_s.include?('>')
2423
- check11 = 1
2424
- position[nn] += 4
2425
- end
2426
- end
2427
- if check11 == 0
2428
- break
2376
+ # 내용 분할 (자동 생성 글과 텍스트)
2377
+ content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2378
+ content55 = content.split("(자동생성글)")[1].to_s if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2379
+
2380
+ # 빈 줄 찾기
2381
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index }
2382
+
2383
+ # 빈 줄이 부족하면 텍스트 끝에 빈 줄 추가
2384
+ if empty_positions.length < cn
2385
+ # 부족한 빈 줄의 수
2386
+ missing_empty_lines = cn - empty_positions.length
2387
+ missing_empty_lines.times do
2388
+ content5 << "" # 텍스트 마지막에 빈 줄 추가
2429
2389
  end
2390
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index } # 다시 빈 줄 위치 계산
2430
2391
  end
2431
-
2432
- position = position.sort
2433
-
2434
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2392
+
2393
+ # 이미지 삽입할 위치를 지정 (빈 줄 위치에 삽입)
2394
+ position = empty_positions[0..cn-1]
2395
+
2396
+ # 이미지 URL 가져오기
2397
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2435
2398
  image_url22 = get_image_file().force_encoding('utf-8')
2436
2399
  end
2437
-
2400
+
2401
+ # 각 위치에 이미지를 하나씩만 삽입
2438
2402
  position.each do |i|
2439
2403
  image_url = get_image_file().force_encoding('utf-8')
2440
- puts image_url
2441
-
2442
- puts '사진넣는위치 => '+i.to_s
2404
+ puts '사진넣는위치 => ' + i.to_s
2405
+
2406
+ # 링크가 있을 경우 링크 포함
2443
2407
  if @data['포스트설정']['내용사진링크'].checked?
2444
- image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
2445
- content5.insert(i, '**image**')
2408
+ image_memory << "<a href='" + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') + "'><img src='" + image_url + "' alt='" + keyword.force_encoding('utf-8') + "'></a>"
2409
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2446
2410
  else
2447
- image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
2448
- content5.insert(i, '**image**')
2411
+ image_memory << "<img src='" + image_url + "' alt='" + keyword + "' class='aligncenter size-full'>"
2412
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2449
2413
  end
2450
2414
  end
2451
-
2452
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2453
- content = content5.join("\n")+'(자동생성글)'+content55
2454
- # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
2455
- # content = iconv.iconv(content)
2456
- # content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
2457
- puts content
2458
- image_url = image_url22
2459
-
2460
- # if @data['포스트설정']['자동글 수식에 입력'].checked?
2461
-
2462
- # else
2463
- # if @data['포스트설정']['내용사진링크'].checked?
2464
- # content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2465
- # else
2466
- # content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2467
- # end
2468
- # end
2415
+
2416
+ # 자동 생성된 내용과 합치기
2417
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2418
+ content = content5.join("\n") + '(자동생성글)' + content55
2469
2419
  else
2470
2420
  content = content5.join("\n")
2471
2421
  end
2422
+
2423
+ puts content
2472
2424
  end
2473
2425
  end
2474
2426
 
@@ -2619,7 +2571,7 @@ class Wordpress
2619
2571
  # content = content
2620
2572
  # soosick_1 = content_end
2621
2573
  #else
2622
- if @data['포스트설정']['gpt'].checked?
2574
+ if @data['포스트설정']['gpt키워드'].checked?
2623
2575
  if @data['포스트설정']['gpt상단'].checked?
2624
2576
  content = content_end+"\n"+content+"\n"
2625
2577
  else
@@ -2688,27 +2640,27 @@ class Wordpress
2688
2640
 
2689
2641
 
2690
2642
  if @data['포스트설정']['전체공개'].checked?
2691
- option['전체공개'] = 'false'
2692
- else
2693
2643
  option['전체공개'] = 'true'
2644
+ else
2645
+ option['전체공개'] = 'false'
2694
2646
  end
2695
2647
 
2696
2648
  if @data['포스트설정']['비공개'].checked?
2697
- option['비공개'] = 'false'
2698
- else
2699
2649
  option['비공개'] = 'true'
2650
+ else
2651
+ option['비공개'] = 'false'
2700
2652
  end
2701
2653
 
2702
2654
  if @data['포스트설정']['댓글허용'].checked?
2703
- option['댓글허용'] = 'false'
2704
- else
2705
2655
  option['댓글허용'] = 'true'
2656
+ else
2657
+ option['댓글허용'] = 'false'
2706
2658
  end
2707
2659
 
2708
2660
  if @data['포스트설정']['댓글 비 허용'].checked?
2709
- option['댓글 비 허용'] = 'false'
2710
- else
2711
2661
  option['댓글 비 허용'] = 'true'
2662
+ else
2663
+ option['댓글 비 허용'] = 'false'
2712
2664
  end
2713
2665
 
2714
2666
 
@@ -2717,40 +2669,55 @@ class Wordpress
2717
2669
  end
2718
2670
 
2719
2671
  if @data['포스트설정']['중앙정렬'].checked?
2720
- option['중앙정렬'] = 'false'
2721
- else
2722
2672
  option['중앙정렬'] = 'true'
2673
+ else
2674
+ option['중앙정렬'] = 'false'
2723
2675
  end
2724
2676
 
2725
2677
  if @data['포스트설정']['우측정렬'].checked?
2726
- option['우측정렬'] = 'false'
2727
- else
2728
2678
  option['우측정렬'] = 'true'
2679
+ else
2680
+ option['우측정렬'] = 'false'
2729
2681
  end
2730
2682
 
2731
2683
  if @data['포스트설정']['좌측정렬'].checked?
2684
+ option['좌측정렬'] = 'true'
2685
+ else
2732
2686
  option['좌측정렬'] = 'false'
2687
+ end
2688
+
2689
+ if @data['포스트설정']['글발생하기'].checked?
2690
+ option['글발생하기'] = 'true'
2733
2691
  else
2734
- option['좌측정렬'] = 'true'
2692
+ option['글발생하기'] = 'false'
2693
+ end
2694
+
2695
+ if @data['포스트설정']['글임시저장'].checked?
2696
+ option['글임시저장'] = 'true'
2697
+ else
2698
+ option['글임시저장'] = 'false'
2735
2699
  end
2736
2700
 
2701
+
2737
2702
  @data['table'][index][-1] = 90
2738
2703
  @data['table'] << []
2739
2704
  @data['table'].pop
2740
2705
 
2741
2706
  p option
2742
2707
 
2743
- dd_time = @data['table'][index][9].to_s.force_encoding('utf-8').to_i
2708
+ #dd_time = @data['table'][index][8].to_s.force_encoding('utf-8').to_i
2744
2709
  url = @data['table'][index][3].to_s.force_encoding('utf-8')
2745
-
2710
+ captcha_api_key = @data['포스트설정']['captcha_api_key'].text.to_s.force_encoding('utf-8')
2711
+
2712
+
2746
2713
  puts 'start...'
2747
- naver.update(title,content,option, dd_time, url, keyword)
2714
+ naver.update(title,content,option, url, keyword, captcha_api_key)#dd_time
2748
2715
 
2749
- @data['table'][index][10] = @data['table'][index][10].to_i + 1
2716
+ @data['table'][index][8] = @data['table'][index][8].to_i + 1
2750
2717
  @data['table'][index][-1] = 100
2751
2718
  @data['table'] << []
2752
2719
  @data['table'].pop
2753
- sleep(@data['table'][index][8].to_i)
2720
+ sleep(@data['table'][index][7].to_i)
2754
2721
  end
2755
2722
  rescue => e
2756
2723
  puts e
@@ -3094,13 +3061,11 @@ class Wordpress
3094
3061
  horizontal_box{
3095
3062
  stretchy false
3096
3063
  horizontal_box{
3097
- @data['captcha_key'] = entry{
3098
- text 'captcha_api_key 입력'
3099
- }
3064
+
3100
3065
  button('등록'){
3101
3066
  on_clicked {
3102
- @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['게시판url'].text,@data['category'].text, @data['proxy'].text,@data['captcha_key'].text, 1, 1, 1, 0,0]
3103
- @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['게시판url'].text,@data['category'].text, @data['proxy'].text,@data['captcha_key'].text, 1, 1, 1, 0,0]
3067
+ @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['게시판url'].text,@data['category'].text, @data['proxy'].text, 1, 1, 0,0]
3068
+ @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['게시판url'].text,@data['category'].text, @data['proxy'].text, 1, 1, 0,0]
3104
3069
  @data['table'].pop
3105
3070
  }
3106
3071
  }
@@ -3112,8 +3077,8 @@ class Wordpress
3112
3077
  file_data.split("\n").each do |i|
3113
3078
  i3 = i.to_s.force_encoding('utf-8').to_s
3114
3079
  i2 = i3.split(',')
3115
- @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,i2[4].to_s,i2[5].to_s,1,1,1,0,0]
3116
- @data['table'] << [false, i2[0].to_s, i2[1].to_s,1,1,1,0,0]
3080
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,i2[4].to_s,1,1,0,0]
3081
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,1,1,0,0]
3117
3082
  @data['table'].pop
3118
3083
  end
3119
3084
  end
@@ -3168,19 +3133,16 @@ class Wordpress
3168
3133
  text_column('프록시'){
3169
3134
  editable true
3170
3135
  }
3171
- text_column('캡차api'){
3172
- editable true
3173
- }
3174
-
3136
+
3175
3137
  text_column('수량'){
3176
3138
  editable true
3177
3139
  }
3178
3140
  text_column('다음 작업 딜레이'){
3179
3141
  editable true
3180
3142
  }
3181
- text_column('등록 버튼 딜레이'){
3182
- editable true
3183
- }
3143
+ # text_column('등록 버튼 딜레이'){
3144
+ # editable true
3145
+ # }
3184
3146
  text_column('시도 횟수'){
3185
3147
 
3186
3148
  }
@@ -3192,27 +3154,28 @@ class Wordpress
3192
3154
 
3193
3155
  horizontal_box{
3194
3156
  stretchy false
3195
-
3196
- @data['captcha_key1'] = entry{
3197
- text 'captcha_api_key 입력'
3157
+
3158
+ @data['포스트설정']['captcha_api_key'] = entry(){
3159
+ text 'captcha_api_key 입력'
3198
3160
  }
3161
+
3199
3162
  @data['table_counter_input'] = entry{
3200
3163
  text '수량 ex) 3'
3201
3164
  }
3202
3165
  @data['table_delay_input'] = entry{
3203
3166
  text '딜레이 ex) 3'
3204
3167
  }
3205
- @data['table_delay_input2'] = entry{
3206
- text '등록전딜레이'
3207
- }
3168
+ #@data['table_delay_input2'] = entry{
3169
+ # text '등록전딜레이'
3170
+ #}
3208
3171
 
3209
3172
  button('전체설정'){
3210
3173
  on_clicked{
3211
3174
  for n in 0..@data['table'].length-1
3212
- @data['table'][n][6] = @data['captcha_key1'].text.to_s
3213
- @data['table'][n][7] = @data['table_counter_input'].text.to_i
3214
- @data['table'][n][8] = @data['table_delay_input'].text.to_i
3215
- @data['table'][n][9] = @data['table_delay_input2'].text.to_i
3175
+
3176
+ @data['table'][n][6] = @data['table_counter_input'].text.to_i
3177
+ @data['table'][n][7] = @data['table_delay_input'].text.to_i
3178
+ #@data['table'][n][8] = @data['table_delay_input2'].text.to_i
3216
3179
  @data['table'] << []
3217
3180
  @data['table'].pop
3218
3181
  end
@@ -3248,7 +3211,10 @@ class Wordpress
3248
3211
  }
3249
3212
  horizontal_box{
3250
3213
  stretchy false
3214
+ grid{
3251
3215
  button('전체선택'){
3216
+ top 1
3217
+ left 1
3252
3218
  on_clicked{
3253
3219
  for n in 0..@data['키워드설정']['키워드'].length-1
3254
3220
  @data['키워드설정']['키워드'][n][0] = true
@@ -3257,7 +3223,20 @@ class Wordpress
3257
3223
  end
3258
3224
  }
3259
3225
  }
3260
- button('키워드삭제'){
3226
+ button('선택해제'){
3227
+ top 1
3228
+ left 2
3229
+ on_clicked{
3230
+ for n in 0..@data['키워드설정']['키워드'].length-1
3231
+ @data['키워드설정']['키워드'][n][0] = false
3232
+ @data['키워드설정']['키워드'] << []
3233
+ @data['키워드설정']['키워드'].pop
3234
+ end
3235
+ }
3236
+ }
3237
+ button('삭제하기'){
3238
+ top 1
3239
+ left 3
3261
3240
  on_clicked{
3262
3241
  m = Array.new
3263
3242
  for n in 0..@data['키워드설정']['키워드'].length-1
@@ -3265,13 +3244,15 @@ class Wordpress
3265
3244
  m << n
3266
3245
  end
3267
3246
  end
3268
-
3247
+
3269
3248
  m.reverse.each do |i|
3270
3249
  @data['키워드설정']['키워드'].delete_at(i)
3271
3250
  end
3272
3251
  @data['키워드설정']['키워드'].delete(nil)
3273
3252
  }
3274
3253
  }
3254
+ }
3255
+
3275
3256
  @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3276
3257
  stretchy false
3277
3258
  on_toggled{ |c|
@@ -3289,6 +3270,58 @@ class Wordpress
3289
3270
  }
3290
3271
  }
3291
3272
  }
3273
+ vertical_separator{
3274
+ stretchy false
3275
+ }
3276
+ horizontal_box{
3277
+ stretchy false
3278
+ grid{
3279
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3280
+ top 1
3281
+ left 0
3282
+ #enabled false # 기본적으로 비활성화
3283
+ on_toggled {
3284
+ if @data['포스트설정']['gpt키워드'].checked?
3285
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3286
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3287
+ else
3288
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3289
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3290
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3291
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3292
+ end
3293
+ }
3294
+
3295
+ }
3296
+
3297
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3298
+ top 1
3299
+ left 1
3300
+ enabled false # 기본적으로 비활성화
3301
+ on_toggled{
3302
+ if @data['포스트설정']['gpt상단'].checked?
3303
+ @data['포스트설정']['gpt하단'].checked = false
3304
+ end
3305
+ }
3306
+ }
3307
+
3308
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3309
+ top 1
3310
+ left 2
3311
+ enabled false # 기본적으로 비활성화
3312
+ on_toggled{
3313
+ if @data['포스트설정']['gpt하단'].checked?
3314
+ @data['포스트설정']['gpt상단'].checked = false
3315
+ end
3316
+ }
3317
+ }
3318
+ } }
3319
+ horizontal_box{
3320
+ stretchy false
3321
+ grid{
3322
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3323
+ } } }
3324
+
3292
3325
  table{
3293
3326
  checkbox_column('선택'){
3294
3327
  editable true
@@ -3307,68 +3340,100 @@ class Wordpress
3307
3340
  vertical_box{
3308
3341
  horizontal_box{
3309
3342
  stretchy false
3310
- button('제목불러오기'){
3311
- on_clicked{
3312
- file = open_file
3313
- if file != nil
3314
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3315
- file_data.split("\n").each do |title|
3316
- if title.split(" ").join('').length < 2
3317
-
3318
- else
3319
- @data['제목설정']['제목'] << [false, title]
3320
- @data['제목설정']['제목'] << [false, title]
3321
- @data['제목설정']['제목'].pop
3322
- end
3323
- end
3324
- end
3325
- }
3326
- }
3343
+ button('제목불러오기'){
3344
+ on_clicked{
3345
+ file = open_file
3346
+ if file != nil
3347
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3348
+ file_data.split("\n").each do |title|
3349
+ if title.split(" ").join('').length < 2
3327
3350
 
3328
- }
3329
- horizontal_box{
3330
- stretchy false
3331
- button('전체선택'){
3332
- on_clicked{
3333
- for n in 0..@data['제목설정']['제목'].length-1
3334
- @data['제목설정']['제목'][n][0] = true
3335
- @data['제목설정']['제목'] << []
3351
+ else
3352
+ @data['제목설정']['제목'] << [false, title]
3353
+ @data['제목설정']['제목'] << [false, title]
3336
3354
  @data['제목설정']['제목'].pop
3337
3355
  end
3338
- }
3339
- }
3340
- button('제목삭제'){
3341
- on_clicked{
3342
- m = Array.new
3343
- for n in 0..@data['제목설정']['제목'].length-1
3344
- if @data['제목설정']['제목'][n][0] == true
3345
- m << n
3346
- end
3347
- end
3356
+ end
3357
+ end
3358
+ }
3359
+ }
3348
3360
 
3349
- m.reverse.each do |i|
3350
- @data['제목설정']['제목'].delete_at(i)
3351
- end
3352
- @data['제목설정']['제목'].delete(nil)
3353
- }
3354
- }
3355
- @data['제목설정']['순서사용'] = checkbox('순서사용'){
3356
- stretchy false
3357
- on_toggled{ |c|
3358
- if c.checked?
3359
- @data['제목설정']['랜덤사용'].checked = false
3360
- end
3361
- }
3362
- }
3363
- @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3364
- stretchy false
3365
- on_toggled{ |c|
3366
- if c.checked?
3367
- @data['제목설정']['순서사용'].checked = false
3368
- end
3369
- }
3370
- }
3361
+ }
3362
+ horizontal_box{
3363
+ stretchy false
3364
+ grid{
3365
+ button('전체선택'){
3366
+ top 1
3367
+ left 1
3368
+ on_clicked{
3369
+ for n in 0..@data['제목설정']['제목'].length-1
3370
+ @data['제목설정']['제목'][n][0] = true
3371
+ @data['제목설정']['제목'] << []
3372
+ @data['제목설정']['제목'].pop
3373
+ end
3374
+ }
3375
+ }
3376
+ button('선택해제'){
3377
+ top 1
3378
+ left 2
3379
+ on_clicked{
3380
+ for n in 0..@data['제목설정']['제목'].length-1
3381
+ @data['제목설정']['제목'][n][0] = false
3382
+ @data['제목설정']['제목'] << []
3383
+ @data['제목설정']['제목'].pop
3384
+ end
3385
+ }
3386
+ }
3387
+ button('삭제하기'){
3388
+ top 1
3389
+ left 3
3390
+ on_clicked{
3391
+ m = Array.new
3392
+ for n in 0..@data['제목설정']['제목'].length-1
3393
+ if @data['제목설정']['제목'][n][0] == true
3394
+ m << n
3395
+ end
3396
+ end
3397
+
3398
+ m.reverse.each do |i|
3399
+ @data['제목설정']['제목'].delete_at(i)
3400
+ end
3401
+ @data['제목설정']['제목'].delete(nil)
3402
+ }
3403
+ }
3404
+ }
3405
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
3406
+ stretchy false
3407
+ on_toggled{ |c|
3408
+ if c.checked?
3409
+ @data['제목설정']['랜덤사용'].checked = false
3410
+ end
3411
+ }
3412
+ }
3413
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3414
+ stretchy false
3415
+ on_toggled{ |c|
3416
+ if c.checked?
3417
+ @data['제목설정']['순서사용'].checked = false
3418
+ end
3371
3419
  }
3420
+ }
3421
+ }
3422
+ vertical_separator{
3423
+ stretchy false
3424
+ }
3425
+ horizontal_box{
3426
+ stretchy false
3427
+ grid{
3428
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3429
+
3430
+
3431
+ }}}
3432
+ horizontal_box{
3433
+ stretchy false
3434
+ grid{
3435
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3436
+ } } }
3372
3437
  table{
3373
3438
  checkbox_column('선택'){
3374
3439
  editable true
@@ -3402,11 +3467,14 @@ class Wordpress
3402
3467
  end
3403
3468
  }
3404
3469
  }
3405
-
3470
+
3406
3471
  }
3407
3472
  horizontal_box{
3408
3473
  stretchy false
3474
+ grid{
3409
3475
  button('전체선택'){
3476
+ top 1
3477
+ left 1
3410
3478
  on_clicked{
3411
3479
  for n in 0..@data['내용설정']['내용'].length-1
3412
3480
  @data['내용설정']['내용'][n][0] = true
@@ -3415,7 +3483,20 @@ class Wordpress
3415
3483
  end
3416
3484
  }
3417
3485
  }
3418
- button('내용삭제'){
3486
+ button('선택해제'){
3487
+ top 1
3488
+ left 2
3489
+ on_clicked{
3490
+ for n in 0..@data['내용설정']['내용'].length-1
3491
+ @data['내용설정']['내용'][n][0] = false
3492
+ @data['내용설정']['내용'] << []
3493
+ @data['내용설정']['내용'].pop
3494
+ end
3495
+ }
3496
+ }
3497
+ button('삭제하기'){
3498
+ top 1
3499
+ left 3
3419
3500
  on_clicked{
3420
3501
  m = Array.new
3421
3502
  for n in 0..@data['내용설정']['내용'].length-1
@@ -3423,13 +3504,14 @@ class Wordpress
3423
3504
  m << n
3424
3505
  end
3425
3506
  end
3426
-
3507
+
3427
3508
  m.reverse.each do |i|
3428
3509
  @data['내용설정']['내용'].delete_at(i)
3429
3510
  end
3430
3511
  @data['내용설정']['내용'].delete(nil)
3431
3512
  }
3432
3513
  }
3514
+ }
3433
3515
  @data['내용설정']['순서사용'] = checkbox('순서사용'){
3434
3516
  stretchy false
3435
3517
  on_toggled{ |c|
@@ -3447,6 +3529,21 @@ class Wordpress
3447
3529
  }
3448
3530
  }
3449
3531
  }
3532
+ vertical_separator{
3533
+ stretchy false
3534
+ }
3535
+ horizontal_box{
3536
+ stretchy false
3537
+ grid{
3538
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
3539
+
3540
+
3541
+ }}}
3542
+ horizontal_box{
3543
+ stretchy false
3544
+ grid{
3545
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3546
+ } } }
3450
3547
  table{
3451
3548
  checkbox_column('선택'){
3452
3549
  editable true
@@ -3777,248 +3874,297 @@ class Wordpress
3777
3874
  }
3778
3875
 
3779
3876
  tab_item('포스트설정1'){
3780
- horizontal_box{
3781
- vertical_box{
3782
- stretchy false
3783
- grid{
3784
- stretchy false
3785
- @data['포스트설정']['제목키워드변경'] = checkbox('제목에 특정 단어를 내용에 사용할 키워드로 변경'){
3786
- top 0
3787
- left 0
3788
-
3789
- }
3790
- @data['포스트설정']['제목키워드변경단어'] = entry{
3791
- top 0
3792
- left 1
3793
- text '특정단어'
3794
- }
3795
-
3796
- # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
3797
- # top 1
3798
- # left 0
3799
- # }
3800
- # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
3801
- # top 1
3802
- # left 1
3803
- # on_clicked{
3804
- # file = open_file
3805
- # if file != nil
3806
- # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3807
- # file_data.split("\n").each do |i|
3808
- # i2 = i.split('>')
3809
- # text_key = i2[0].to_s
3810
- # text_val = i2[1].to_s.split(',')
3811
- # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
3812
- # end
3813
- # end
3814
- # }
3815
- # }
3816
- @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
3817
- top 2
3818
- left 0
3819
- }
3820
- @data['포스트설정']['제목에키워드삽입숫자1'] = entry(){
3821
- top 2
3822
- left 1
3823
- text '최소수량'
3824
- }
3825
- label('~'){
3826
- top 2
3827
- left 2
3828
- }
3829
- @data['포스트설정']['제목에키워드삽입숫자2'] = entry(){
3830
- top 2
3831
- left 3
3832
- text '최대수량'
3833
- }
3834
- label('ㄴ'){
3835
- top 3
3836
- left 2
3837
- }
3838
- @data['포스트설정']['제목앞'] = checkbox('제목에 키워드 삽입 제목 앞'){
3839
- top 3
3840
- left 3
3841
- on_toggled{
3842
- if @data['포스트설정']['제목앞'].checked? == true
3843
- if @data['포스트설정']['제목뒤'].checked?
3844
- @data['포스트설정']['제목뒤'].checked = false
3845
- end
3846
- end
3847
- }
3848
- }
3849
- label('ㄴ'){
3850
- top 4
3851
- left 2
3852
- }
3853
- @data['포스트설정']['제목뒤'] = checkbox('제목에 키워드 삽입 제목 뒤'){
3854
- top 4
3855
- left 3
3856
- on_toggled{
3857
- if @data['포스트설정']['제목뒤'].checked? == true
3858
- if @data['포스트설정']['제목앞'].checked?
3859
- @data['포스트설정']['제목앞'].checked = false
3860
- end
3861
- end
3862
- }
3863
- }
3864
- @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
3865
- top 4
3866
- left 0
3867
- }
3868
-
3869
- @data['포스트설정']['특수문자'] = checkbox('제목에 키워드 삽입 시 특수문자 삽입'){
3870
- top 5
3871
- left 0
3872
- }
3873
- @data['포스트설정']['제목을랜덤'] = checkbox('제목을 랜덤 단어 조합으로 자동 입력'){
3874
- top 6
3875
- left 0
3876
- }
3877
- @data['포스트설정']['내용키워드삽입'] = checkbox('내용 키워드 삽입'){
3878
- top 7
3879
- left 0
3880
- }
3881
- @data['포스트설정']['키워드삽입시작숫자'] = entry(){
3882
- top 7
3883
- left 1
3884
- text '최소수량'
3885
- }
3886
- label('~'){
3887
- top 7
3888
- left 2
3889
- }
3890
- @data['포스트설정']['키워드삽입끝숫자'] = entry(){
3891
- top 7
3892
- left 3
3893
- text '최대수량'
3894
- }
3895
- @data['포스트설정']['키워드삽입'] = checkbox('내용 키워드 삽입시 링크 삽입'){
3896
- top 8
3897
- left 0
3898
- }
3899
- @data['포스트설정']['키워드삽입시링크'] = entry(){
3900
- top 8
3901
- left 1
3902
- text 'URL'
3903
- }
3904
- @data['포스트설정']['내용을자동생성'] = checkbox('내용을 키워드 기반으로 자동 생성해서 포스팅'){
3905
- top 9
3906
- left 0
3907
- on_toggled{
3908
- if @data['포스트설정']['내용을자동생성'].checked?
3909
- if @data['포스트설정']['내용과자동생성'].checked?
3910
- @data['포스트설정']['내용과자동생성'].checked = false
3911
- end
3912
- end
3913
- }
3914
- }
3915
-
3916
- @data['포스트설정']['gpt'] = checkbox('내용을 키워드 기반의 GPT로 생성해서 포스팅'){
3917
- top 10
3918
- left 0
3919
- }
3920
-
3921
- @data['포스트설정']['api_key'] = entry(){
3922
- top 10
3923
- left 1
3924
- text 'api key'
3925
- }
3877
+ horizontal_box{
3878
+ vertical_box{
3879
+ stretchy false
3880
+ grid{
3881
+ stretchy false
3882
+ @data['포스트설정']['제목키워드변경'] = checkbox('제목에 특정 단어를 내용에 사용할 키워드로 변경'){
3883
+ top 0
3884
+ left 0
3926
3885
 
3927
- @data['포스트설정']['gpt상단'] = checkbox('원고내용 위에 넣기'){
3928
- top 10
3929
- left 3
3930
- on_toggled{
3931
- if @data['포스트설정']['gpt상단'].checked? == true
3932
- if @data['포스트설정']['gpt하단'].checked?
3933
- @data['포스트설정']['gpt하단'].checked = false
3934
- end
3935
- end
3936
- }
3937
- }
3886
+ }
3887
+ @data['포스트설정']['제목키워드변경단어'] = entry{
3888
+ top 0
3889
+ left 1
3890
+ text '특정단어'
3891
+ }
3938
3892
 
3939
- @data['포스트설정']['gpt하단'] = checkbox('원고내용 아래에 넣기'){
3940
- top 11
3941
- left 3
3942
- on_toggled{
3943
- if @data['포스트설정']['gpt하단'].checked? == true
3944
- if @data['포스트설정']['gpt상단'].checked?
3945
- @data['포스트설정']['gpt상단'].checked = false
3946
- end
3947
- end
3948
- }
3949
- }
3893
+ # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
3894
+ # top 1
3895
+ # left 0
3896
+ # }
3897
+ # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
3898
+ # top 1
3899
+ # left 1
3900
+ # on_clicked{
3901
+ # file = open_file
3902
+ # if file != nil
3903
+ # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3904
+ # file_data.split("\n").each do |i|
3905
+ # i2 = i.split('>')
3906
+ # text_key = i2[0].to_s
3907
+ # text_val = i2[1].to_s.split(',')
3908
+ # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
3909
+ # end
3910
+ # end
3911
+ # }
3912
+ # }
3913
+ @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
3914
+ top 2
3915
+ left 0
3916
+ #enabled false # 기본적으로 비활성화
3917
+ on_toggled {
3918
+ if @data['포스트설정']['제목에키워드삽입'].checked?
3919
+ @data['포스트설정']['제목앞'].enabled = true # '내용투명' 활성화
3920
+ @data['포스트설정']['제목뒤'].enabled = true # '내용투명' 활성화
3921
+ else
3922
+ @data['포스트설정']['제목앞'].checked = false # 체크 해제
3923
+ @data['포스트설정']['제목앞'].enabled = false # 비활성화
3924
+ @data['포스트설정']['제목뒤'].checked = false # 체크 해제
3925
+ @data['포스트설정']['제목뒤'].enabled = false # 비활성화
3926
+ end
3927
+ }
3928
+
3929
+ }
3930
+ @data['포스트설정']['제목에키워드삽입숫자1'] = entry(){
3931
+ top 2
3932
+ left 1
3933
+ text '최소수량'
3934
+ }
3935
+ label('~'){
3936
+ top 2
3937
+ left 2
3938
+ }
3939
+ @data['포스트설정']['제목에키워드삽입숫자2'] = entry(){
3940
+ top 2
3941
+ left 3
3942
+ text '최대수량'
3943
+ }
3944
+ label('ㄴ'){
3945
+ top 3
3946
+ left 2
3947
+ }
3948
+ @data['포스트설정']['제목앞'] = checkbox('제목에 키워드 삽입 제목 앞'){
3949
+ top 3
3950
+ left 3
3951
+ enabled false # 기본적으로 비활성화
3952
+ on_toggled{
3953
+ if @data['포스트설정']['제목앞'].checked? == true
3954
+ if @data['포스트설정']['제목뒤'].checked?
3955
+ @data['포스트설정']['제목뒤'].checked = false
3956
+ end
3957
+ end
3958
+ }
3959
+ }
3960
+ label('ㄴ'){
3961
+ top 4
3962
+ left 2
3963
+ }
3964
+ @data['포스트설정']['제목뒤'] = checkbox('제목에 키워드 삽입 제목 뒤'){
3965
+ top 4
3966
+ left 3
3967
+ enabled false # 기본적으로 비활성화
3968
+ on_toggled{
3969
+ if @data['포스트설정']['제목뒤'].checked? == true
3970
+ if @data['포스트설정']['제목앞'].checked?
3971
+ @data['포스트설정']['제목앞'].checked = false
3972
+ end
3973
+ end
3974
+ }
3975
+ }
3976
+
3977
+ @data['포스트설정']['특수문자'] = checkbox('제목에 키워드 삽입 시 특수문자 삽입'){
3978
+ top 4
3979
+ left 0
3980
+ }
3981
+ @data['포스트설정']['제목을랜덤'] = checkbox('제목을 랜덤 단어 조합으로 자동 입력'){
3982
+ top 5
3983
+ left 0
3984
+ on_toggled{
3985
+ if @data['포스트설정']['제목을랜덤'].checked? == true
3986
+ if @data['포스트설정']['제목내용설정'].checked?
3987
+ @data['포스트설정']['제목내용설정'].checked = false
3988
+ end
3989
+ end
3990
+ }
3991
+ }
3992
+ @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
3993
+ top 6
3994
+ left 0
3995
+ on_toggled{
3996
+ if @data['포스트설정']['제목내용설정'].checked? == true
3997
+ if @data['포스트설정']['제목을랜덤'].checked?
3998
+ @data['포스트설정']['제목을랜덤'].checked = false
3999
+ end
4000
+ end
4001
+ }
4002
+ }
4003
+ @data['포스트설정']['내용키워드삽입'] = checkbox('내용 키워드 삽입'){
4004
+ top 7
4005
+ left 0
4006
+ on_toggled {
4007
+ if @data['포스트설정']['내용키워드삽입'].checked?
4008
+ @data['포스트설정']['키워드삽입'].enabled = true # '내용투명' 활성화
4009
+ @data['포스트설정']['키워드삽입시링크'].enabled = true # '내용투명' 활성화
4010
+ else
4011
+ @data['포스트설정']['키워드삽입'].checked = false # 체크 해제
4012
+ @data['포스트설정']['키워드삽입'].enabled = false # 비활성화
4013
+ @data['포스트설정']['키워드삽입시링크'].text = 'URL' # 기본 텍스트 설정
4014
+ @data['포스트설정']['키워드삽입시링크'].enabled = false # 비활성화
4015
+ end
4016
+ }
4017
+ }
4018
+ @data['포스트설정']['키워드삽입시작숫자'] = entry(){
4019
+ top 7
4020
+ left 1
4021
+
4022
+ text '최소수량'
4023
+ }
4024
+ label('~'){
4025
+ top 7
4026
+ left 2
4027
+ }
4028
+ @data['포스트설정']['키워드삽입끝숫자'] = entry(){
4029
+ top 7
4030
+ left 3
4031
+ text '최대수량'
4032
+ }
4033
+ @data['포스트설정']['키워드삽입'] = checkbox('내용 키워드 삽입시 링크 삽입'){
4034
+ enabled false # 기본적으로 비활성화
4035
+ top 8
4036
+ left 0
4037
+
4038
+ }
4039
+ @data['포스트설정']['키워드삽입시링크'] = entry(){
4040
+ enabled false # 기본적으로 비활성화
4041
+ top 8
4042
+ left 1
4043
+ text 'URL'
4044
+ }
4045
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 생성으로만 등록(GPT 미 사용시 자체 생성)'){
4046
+ top 9
4047
+ left 0
4048
+ on_toggled {
4049
+ if @data['포스트설정']['내용을자동생성'].checked?
4050
+ @data['포스트설정']['내용과자동생성'].checked = false
4051
+ @data['포스트설정']['내용투명'].checked = false
4052
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4053
+
4054
+ end
4055
+ }
4056
+ }
3950
4057
 
3951
- aa1 = 2
3952
- @data['포스트설정']['내용과자동생성'] = checkbox('내용을 내용 파일 + 자동 생성 조합으로 포스팅'){
3953
- top 10 + aa1
3954
- left 0
3955
- on_toggled{
3956
- if @data['포스트설정']['내용과자동생성'].checked?
3957
- if @data['포스트설정']['내용을자동생성'].checked?
3958
- @data['포스트설정']['내용을자동생성'].checked = false
3959
- end
3960
- end
3961
- }
3962
- }
3963
- @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리'){
3964
- top 11+ aa1
3965
- left 0
3966
- }
3967
- @data['포스트설정']['내용자동변경'] = checkbox('내용에 단어들을 자동 변경'){
3968
- top 12+ aa1
3969
- left 0
3970
- }
3971
- button('설정 파일 불러오기'){
3972
- top 12+ aa1
3973
- left 1
3974
- on_clicked{
3975
- file = open_file
3976
- if file != nil
3977
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3978
- file_data.split("\n").each do |i|
3979
- key = i.split('>')[0]
3980
- v = i.split('>')[1].to_s.split(',')
3981
- @data['포스트설정']['내용자동변경값'][key] = v
3982
- end
3983
- end
3984
- }
3985
- }
3986
- @data['포스트설정']['제목에도적용'] = checkbox('제목에도 적용'){
3987
- top 12+ aa1
3988
- left 3
3989
- }
4058
+
4059
+ aa1 = 2
4060
+ @data['포스트설정']['내용과자동생성'] = checkbox('내용파일+키워드기반 생성 등록(GPT 미 사용시 자체 생성)') {
4061
+ top 10 + aa1
4062
+ left 0
4063
+ on_toggled {
4064
+ if @data['포스트설정']['내용과자동생성'].checked?
4065
+ @data['포스트설정']['내용을자동생성'].checked = false
4066
+ @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4067
+
4068
+ else
4069
+ @data['포스트설정']['내용투명'].checked = false # 체크 해제
4070
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4071
+
4072
+ end
4073
+ }
4074
+ }
4075
+
4076
+ @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4077
+ top 11 + aa1
4078
+ left 0
4079
+ enabled false # 기본적으로 비활성화
4080
+ on_toggled {
4081
+ if @data['포스트설정']['내용투명'].checked?
4082
+ @data['포스트설정']['내용을자동생성'].checked = false
4083
+
4084
+ end
4085
+ }
4086
+ }
4087
+ @data['포스트설정']['내용자동변경'] = checkbox('내용에 단어들을 자동 변경'){
4088
+ top 12+ aa1
4089
+ left 0
4090
+ }
4091
+ button('설정 파일 불러오기'){
4092
+ top 12+ aa1
4093
+ left 1
4094
+ on_clicked{
4095
+ file = open_file
4096
+ if file != nil
4097
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4098
+ file_data.split("\n").each do |i|
4099
+ key = i.split('>')[0]
4100
+ v = i.split('>')[1].to_s.split(',')
4101
+ @data['포스트설정']['내용자동변경값'][key] = v
4102
+ end
4103
+ end
4104
+ }
4105
+ }
4106
+ @data['포스트설정']['제목에도적용'] = checkbox('제목에도 적용'){
4107
+ top 12+ aa1
4108
+ left 3
4109
+ }
3990
4110
 
3991
- @data['포스트설정']['내용사진자동삽입'] = checkbox('내용 사진 자동 삽입'){
3992
- top 13+ aa1
3993
- left 0
3994
- }
3995
- @data['포스트설정']['내용사진자동삽입시작숫자'] = entry(){
3996
- top 13+ aa1
3997
- left 1
3998
- text '최소수량'
3999
- }
4000
- label('~'){
4001
- top 13+ aa1
4002
- left 2
4003
- }
4004
- @data['포스트설정']['내용사진자동삽입끝숫자'] = entry(){
4005
- top 13+ aa1
4006
- left 3
4007
- text '최대수량'
4008
- }
4111
+ @data['포스트설정']['내용사진자동삽입'] = checkbox('내용 사진 자동 삽입'){
4112
+ top 13+ aa1
4113
+ left 0
4114
+ #enabled false # 기본적으로 비활성화
4115
+ on_toggled {
4116
+ if @data['포스트설정']['내용사진자동삽입'].checked?
4117
+ @data['포스트설정']['내용사진링크'].enabled = true # '내용투명' 활성화
4118
+ @data['포스트설정']['내용사진링크값'].enabled = true # '내용투명' 활성화
4119
+ else
4120
+ @data['포스트설정']['내용사진링크'].checked = false # 체크 해제
4121
+ @data['포스트설정']['내용사진링크'].enabled = false # 비활성화
4122
+ @data['포스트설정']['내용사진링크값'].text = 'URL' # 기본 텍스트 설정
4123
+ @data['포스트설정']['내용사진링크값'].enabled = false # 비활성화
4124
+ end
4125
+ }
4126
+ }
4127
+ @data['포스트설정']['내용사진자동삽입시작숫자'] = entry(){
4128
+ top 13+ aa1
4129
+ left 1
4130
+ text '최소수량'
4131
+ }
4132
+ label('~'){
4133
+ top 13+ aa1
4134
+ left 2
4135
+ }
4136
+ @data['포스트설정']['내용사진자동삽입끝숫자'] = entry(){
4137
+ top 13+ aa1
4138
+ left 3
4139
+ text '최대수량'
4140
+ }
4009
4141
 
4010
- @data['포스트설정']['내용사진링크'] = checkbox('내용 사진 자동 삽입시 링크 삽입'){
4011
- top 14+ aa1
4012
- left 0
4013
- }
4142
+ @data['포스트설정']['내용사진링크'] = checkbox('내용 사진 자동 삽입시 링크 삽입'){
4143
+ enabled false # 기본적으로 비활성화
4144
+ top 14+ aa1
4145
+ left 0
4146
+ }
4014
4147
 
4015
- @data['포스트설정']['내용사진링크값'] = entry(){
4016
- top 14+ aa1
4017
- left 1
4018
- text 'URL'
4019
- }
4020
- }
4148
+ @data['포스트설정']['내용사진링크값'] = entry(){
4149
+ enabled false # 기본적으로 비활성화
4150
+ top 14+ aa1
4151
+ left 1
4152
+ text 'URL'
4021
4153
  }
4154
+
4155
+ @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4156
+ top 15+ aa1
4157
+ left 0
4158
+ }
4159
+
4160
+ @data['포스트설정']['api_key'] = entry(){
4161
+ top 15+ aa1
4162
+ left 1
4163
+ text 'api key 입력 필수!!'
4164
+ }
4165
+
4166
+ }
4167
+ }
4022
4168
 
4023
4169
  vertical_separator{
4024
4170
  stretchy false
@@ -4230,6 +4376,20 @@ class Wordpress
4230
4376
  @data['포스트설정']['막글삽입'] = checkbox('내용 하단에 막글 삽입'){
4231
4377
  top 6
4232
4378
  left 0
4379
+ on_toggled {
4380
+ if @data['포스트설정']['막글삽입'].checked?
4381
+ @data['포스트설정']['막글투명'].enabled = true # '내용투명' 활성화
4382
+ @data['포스트설정']['막글그대로'].enabled = true # '내용투명' 활성화
4383
+
4384
+
4385
+ else
4386
+ @data['포스트설정']['막글투명'].checked = false # 체크 해제
4387
+ @data['포스트설정']['막글투명'].enabled = false # 비활성화
4388
+ @data['포스트설정']['막글그대로'].checked = false # 체크 해제
4389
+ @data['포스트설정']['막글그대로'].enabled = false # 비활성화
4390
+
4391
+ end
4392
+ }
4233
4393
  }
4234
4394
  @data['포스트설정']['막글삽입시작숫자'] = entry{
4235
4395
  top 6
@@ -4259,10 +4419,12 @@ class Wordpress
4259
4419
  @data['포스트설정']['막글투명'] = checkbox('막글 안보이게 처리'){
4260
4420
  top 7
4261
4421
  left 0
4422
+ enabled false
4262
4423
  }
4263
4424
  @data['포스트설정']['막글그대로'] = checkbox('막글 그대로 입력'){
4264
4425
  top 7
4265
4426
  left 1
4427
+ enabled false
4266
4428
  }
4267
4429
 
4268
4430
  @data['포스트설정']['태그삽입1'] = checkbox('태그삽입'){
@@ -4390,6 +4552,31 @@ class Wordpress
4390
4552
  @data['무한반복'] = checkbox('무한반복'){
4391
4553
  stretchy false
4392
4554
  }
4555
+
4556
+
4557
+
4558
+ @data['포스트설정']['글발생하기'] = checkbox('글 발행하기'){
4559
+ stretchy false
4560
+ on_toggled{
4561
+ if @data['포스트설정']['글발생하기'].checked? == true
4562
+ if @data['포스트설정']['글임시저장'].checked?
4563
+ @data['포스트설정']['글임시저장'].checked = false
4564
+ end
4565
+ end
4566
+ }
4567
+ }
4568
+ @data['포스트설정']['글임시저장'] = checkbox('글 임시저장'){
4569
+ stretchy false
4570
+ on_toggled{
4571
+ if @data['포스트설정']['글임시저장'].checked? == true
4572
+ if @data['포스트설정']['글발생하기'].checked?
4573
+ @data['포스트설정']['글발생하기'].checked = false
4574
+ end
4575
+ end
4576
+ }
4577
+ }
4578
+
4579
+
4393
4580
  button('작업시작'){
4394
4581
  on_clicked{
4395
4582
  if @user_login_ok == "0"
@@ -4430,7 +4617,7 @@ class Wordpress
4430
4617
  @data['포스트설정']['중앙정렬'].checked = true
4431
4618
  @data['포스트설정']['전체공개'].checked = true
4432
4619
  @data['포스트설정']['댓글허용'].checked = true
4433
-
4620
+ @data['포스트설정']['글발생하기'].checked = true
4434
4621
 
4435
4622
  }.show
4436
4623
  end