cafe_basics_duo 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_basics_duo.rb +528 -375
  3. metadata +2 -2
@@ -17,27 +17,29 @@ require 'cgi'
17
17
  require 'digest'
18
18
  require 'auto_click'
19
19
  require 'rainbow/refinement'
20
- require 'watir'
21
20
  include AutoClickMethods
22
21
  using Rainbow
23
-
22
+ include Glimmer
24
23
 
25
24
  class Chat
25
+
26
26
  def initialize(api_key)
27
27
  @api_key = api_key
28
28
  end
29
29
 
30
30
  def message2(keyword)
31
+ puts'[GPT] 키워드 기반 글을 생성 중입니다.......'.yellow
31
32
  url = 'https://api.openai.com/v1/chat/completions'
32
33
  h = {
33
34
  'Content-Type' => 'application/json',
34
35
  'Authorization' => 'Bearer ' + @api_key
35
36
  }
36
37
  d = {
37
- 'model' => 'gpt-3.5-turbo',
38
+ #'model' => 'gpt-3.5-turbo',
39
+ 'model' => 'gpt-4',
38
40
  'messages' => [{
39
41
  "role" => "assistant",
40
- "content" => keyword.to_s+" 소개하는 글만들어줘"
42
+ "content" => keyword.to_s+" 소개하는 글을 1500자에서 2500자 사이로 만들어줘"
41
43
  }]
42
44
  }
43
45
  answer = ''
@@ -68,10 +70,11 @@ class Chat
68
70
  'Authorization' => 'Bearer ' + @api_key
69
71
  }
70
72
  d = {
71
- 'model' => 'gpt-3.5-turbo',
73
+ #'model' => 'gpt-3.5-turbo',
74
+ 'model' => 'gpt-4',
72
75
  'messages' => [{
73
76
  "role" => "assistant",
74
- "content" => keyword.to_s+" 소개하는 글만들어줘"
77
+ "content" => keyword.to_s+" 관련된 글을 1500자에서 2500자 사이로 만들어줘"
75
78
  }]
76
79
  }
77
80
  answer = ''
@@ -102,23 +105,137 @@ class Chat
102
105
  end
103
106
  end
104
107
 
108
+ class Chat_title
109
+
110
+ def initialize(api_key)
111
+ @api_key = api_key
112
+ end
113
+
114
+ def message(title)
115
+ puts'[GPT] 유사 제목을 생성 중입니다.......'.yellow
116
+ url = 'https://api.openai.com/v1/chat/completions'
117
+ headers = {
118
+ 'Content-Type' => 'application/json',
119
+ 'Authorization' => 'Bearer ' + @api_key
120
+ }
121
+ data = {
122
+ 'model' => 'gpt-4',
123
+ 'messages' => [{
124
+ "role" => "system",
125
+ "content" => "너는 매우 친절하고 성의 있게 답변하는 AI 어시스턴트야."
126
+ },
127
+ {
128
+ "role" => "user",
129
+ "content" => "#{title}\n위 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘."
130
+ }]
131
+ }
132
+
133
+ begin
134
+ req = HTTP.headers(headers).post(url, json: data)
135
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
136
+ response = JSON.parse(req.body.to_s)
137
+ puts "API Response: #{response}" # 전체 응답 출력
138
+
139
+ if req.status == 429
140
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
141
+ end
142
+
143
+ # 응답 데이터에서 안전하게 값 추출
144
+ answer = response.dig('choices', 0, 'message', 'content')
145
+ answer ||= (title) # 응답이 없을 경우 기본 메시지 설정
146
+ rescue => e
147
+ puts "Error: #{e.message}"
148
+ answer = "오류가 발생했습니다."
149
+ end
150
+
151
+ puts 'API return ==> '
152
+ puts answer
153
+ answer
154
+ end
155
+ end
156
+
157
+ class Chat_content
158
+
159
+ def initialize(api_key)
160
+ @api_key = api_key
161
+ end
162
+
163
+ def message(content)
164
+ puts'[GPT] 유사 내용을 생성 중입니다! 조금만 기다려주세요.......'.yellow
165
+ url = 'https://api.openai.com/v1/chat/completions'
166
+ headers = {
167
+ 'Content-Type' => 'application/json',
168
+ 'Authorization' => 'Bearer ' + @api_key
169
+ }
170
+ data = {
171
+ 'model' => 'gpt-4',
172
+ 'messages' => [{
173
+ "role" => "system",
174
+ "content" => "너는 매우 친절하고 성의 있게 답변하는 AI 어시스턴트야."
175
+ },
176
+ {
177
+ "role" => "user",
178
+ "content" => "#{content}\nChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해"
179
+ }]
180
+ }
181
+
182
+ begin
183
+ req = HTTP.headers(headers).post(url, json: data)
184
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
185
+ response = JSON.parse(req.body.to_s)
186
+ puts "API Response: #{response}" # 전체 응답 출력
187
+
188
+ if req.status == 429
189
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
190
+ end
191
+
192
+ # 응답 데이터에서 안전하게 값 추출
193
+ answer = response.dig('choices', 0, 'message', 'content')
194
+ answer ||= (content) # 응답이 없을 경우 기본 메시지 설정
195
+ rescue => e
196
+ puts "Error: #{e.message}"
197
+ answer = "오류가 발생했습니다."
198
+ end
199
+
200
+ puts 'API return ==> '
201
+ puts answer
202
+ answer
203
+ end
204
+ end
205
+
206
+
207
+ #############################################gpt############################################
208
+
105
209
  class Naver
106
210
  def initialize
107
211
  @seed = 1
108
- @cookie = ''
109
212
  end
213
+ def chrome_setup(user_id)
214
+ naver_cookie_dir = "C:/naver_cookie"
215
+ FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
216
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
110
217
 
111
- def chrome_start(proxy)
218
+ end
219
+ def chrome_start(proxy, user_id)
220
+ naver_cookie_dir = "C:/naver_cookie"
221
+ FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
112
222
  if proxy == ''
113
223
  begin
114
224
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
115
- @driver = Selenium::WebDriver.for :chrome
225
+ options = Selenium::WebDriver::Chrome::Options.new
226
+ options.page_load_strategy = :normal
227
+ options.timeouts = {page_load: 20_000}
228
+ options.page_load_strategy = 'none'
229
+ options.add_argument('--remote-debugging-port=9222')
230
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
231
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
116
232
  rescue
117
- @driver = Selenium::WebDriver.for :chrome
233
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
118
234
  end
119
235
  else
120
236
  begin
121
237
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
238
+ options = Selenium::WebDriver::Chrome::Options.new
122
239
  # profile = Selenium::WebDriver::Chrome::Profile.new
123
240
  # profile['network.proxy.type'] = 1
124
241
  # profile['network.proxy.http'] = proxy.split(':')[0]
@@ -127,177 +244,114 @@ class Naver
127
244
  # options.profile = profile
128
245
  options = Selenium::WebDriver::Chrome::Options.new
129
246
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
130
- @driver = Selenium::WebDriver.for(:chrome, options: options)
247
+ options.page_load_strategy = :normal
248
+ options.timeouts = {page_load: 20_000}
249
+ options.page_load_strategy = 'none'
250
+ options.add_argument('--remote-debugging-port=9222')
251
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
252
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
131
253
  rescue => e
132
254
  puts e
133
255
  puts 'proxy error...'
134
256
  begin
135
257
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
136
- @driver = Selenium::WebDriver.for :chrome
258
+ options = Selenium::WebDriver::Chrome::Options.new
259
+ options.page_load_strategy = :normal
260
+ options.timeouts = {page_load: 20_000}
261
+ options.page_load_strategy = 'none'
262
+ options.add_argument('--remote-debugging-port=9222')
263
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
264
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
137
265
  rescue
138
- @driver = Selenium::WebDriver.for :chrome
266
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
139
267
  end
140
268
  end
141
269
  end
142
270
  end
143
271
 
272
+
273
+
144
274
  def login(user_id, user_pw, proxy)
145
275
  @user_id = user_id
146
276
  @user_id11 = user_id
147
- chrome_start(proxy)
148
- @driver.get('https://www.naver.com')
149
- sleep(1)
150
- user_cookie_file = Array.new
151
- begin
152
- Dir.entries('./cookie').each do |i|
153
- if i == '.' or i == '..'
277
+ current_dir = File.dirname(__FILE__)
278
+ naver_cookie_dir = "C:/naver_cookie"
279
+ FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
154
280
 
155
- else
156
- user_cookie_file << i
157
- end
281
+
282
+
283
+ unless File.exist?("C:/naver_cookie/" + user_id)
284
+ driverfile_src = File.join(current_dir, 'driverfile')
285
+ if Dir.exist?(driverfile_src)
286
+ FileUtils.cp_r(driverfile_src, "C:/naver_cookie/" + user_id)
287
+
158
288
  end
159
- rescue
289
+ end
160
290
 
161
- end
291
+ # 새로운 스레드 생성 및 실행
292
+ Thread.new { chrome_setup(user_id) }
293
+ sleep(3)
162
294
 
163
- @cookie4 = Hash.new
164
- if user_cookie_file.include?(user_id+'.txt')
165
- f = File.open('./cookie/'+user_id+'.txt', 'r')
166
- @cookie4 = JSON.parse(f.read())
167
- f.close
168
- end
169
295
 
170
- begin
171
- @cookie4.each do |i|
172
- p i
173
- @driver.manage.add_cookie(name: i['name'], value: i['value'], same_site: i['same_site'], domain: i['domain'], path: i['path'])
174
- end
175
- rescue
296
+ chrome_start(proxy, user_id)
297
+ @driver.get('https://www.naver.com')
298
+ puts'[Step.01] 계정 로그인 및 세션 확인.......'.yellow
299
+
176
300
 
177
- end
178
301
  sleep(1)
179
- @driver.get('https://www.naver.com')
302
+
180
303
  begin
181
- # begin
182
- # @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="minime"]'))
183
- # rescue
184
-
185
- # end
186
- @driver.find_element(:xpath, '//*[@id="account"]/div/a').click
304
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
305
+ #요소가 나타날 때까지 3초 동안 기다립니다.
306
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
307
+ sleep(1.5)
308
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
187
309
  check_cookie_login = 0
310
+ sleep(1)
188
311
  rescue
189
312
  check_cookie_login = 1
313
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
314
+ sleep(2.5)
190
315
  end
191
316
 
192
317
  if check_cookie_login == 0
318
+ puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
193
319
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
194
320
  sleep(3)
195
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[2]/span/label').click
196
- sleep(2)
321
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
322
+ #요소가 나타날 때까지 3초 동안 기다립니다.
323
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
324
+ sleep(1.5)
325
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
326
+ sleep(1.5)
197
327
  @driver.find_element(:xpath, '//*[@id="id"]').click
198
328
  Clipboard.copy(user_id)
199
329
  @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
200
- sleep(3)
330
+ sleep(1.5)
201
331
  @driver.find_element(:xpath, '//*[@id="pw"]').click
202
332
  Clipboard.copy(user_pw)
203
333
  @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
204
- sleep(3)
334
+ sleep(1.5)
205
335
  @driver.find_element(:xpath, '//*[@id="log.login"]').click
206
- sleep(3)
336
+ sleep(2.5)
337
+
207
338
  else
208
339
  # @driver.switch_to.default_content
209
340
  end
210
341
 
211
- @cookie = ''
212
- cookie2 = Array.new
213
- @driver.manage.all_cookies.each do |i|
214
- puts i
215
- @cookie += i[:name]+'='+i[:value]+'; '
216
- cookie2 << i
217
- end
218
-
219
- File.open('./cookie/'+user_id+'.txt', 'w') do |ff|
220
- ff.write(cookie2.to_json)
221
- end
222
-
223
-
224
-
225
- sleep(2)
226
342
  begin
227
- @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="my-iframe"]'))
228
- puts @driver.find_element(:xpath, '/html/body/div/div/div[1]/div[1]/a[1]').text
229
- @driver.find_element(:xpath, '//*[@id="account"]/div[2]/div/div/ul/li[3]/a/span').click
230
- return 1
343
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
344
+ #요소가 나타날 때까지 3초 동안 기다립니다.
345
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
346
+
231
347
  rescue => e
348
+ puts '-[√] 로그인 실패!!.......'.red
232
349
  puts e
233
- return 1
234
- end
235
- # if @driver.current_url.include?('viewPhoneInfo')
236
- # #@driver.get('https://blog.naver.com/'+user_id)
237
- # #@driver.get('https://blog.naver.com/MyBlog.naver')
238
- # sleep(1)
239
- # @driver.find_element(:xpath, '//*[@id="account"]/div[2]/div/div/ul/li[3]/a').click
240
- # sleep(1)
241
- # @driver.find_element(:xpath, '//*[@id="account"]/div[3]/div[2]/div[1]/a[2]').click
242
- # sleep(1)
243
- # @driver.switch_to.window(@driver.window_handles[1])
244
- # @user_id = @driver.current_url.split('/')[-1]
245
- # @url = 'https://blog.naver.com/'+@user_id
246
- # @driver.close
247
- # @driver.switch_to.window(@driver.window_handles[0])
248
- # return 1
249
- # else
250
- # begin
251
- # sleep(2)
252
- # # @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="my-iframe"]'))
253
- # # puts @driver.find_element(:xpath, '/html/body/div/div/div[1]/div[1]/a[1]').text
254
- # # @driver.find_element(:xpath, '//*[@id="account"]/div[2]/div/div/ul/li[3]/a/span').click
255
- # # sleep(1)
256
- # # @driver.find_element(:xpath, '//*[@id="account"]/div[2]/div/div/ul/li[3]/a/span')
257
- # #@driver.get('https://blog.naver.com/'+user_id)
258
- # # @driver.get('https://blog.naver.com/MyBlog.naver')
259
- # @driver.find_element(:xpath, '//*[@id="account"]/div[2]/div/div/ul/li[3]/a').click
260
- # sleep(1)
261
- # @driver.find_element(:xpath, '//*[@id="account"]/div[3]/div[2]/div[1]/a[2]').click
262
- # sleep(1)
263
- # sleep(1)
264
- # @driver.switch_to.window(@driver.window_handles[1])
265
- # @user_id = @driver.current_url.split('/')[-1]
266
- # @url = 'https://blog.naver.com/'+@user_id
267
- # @driver.close
268
- # @driver.switch_to.window(@driver.window_handles[0])
269
- # return 1
270
- # rescue => e
271
- # puts e
272
- # @driver.close
273
- # return 0
274
- # end
275
- # end
276
- end
277
-
278
- def driver_close
279
- begin
280
350
  @driver.close
281
- rescue
282
-
351
+ return 0
283
352
  end
284
353
  end
285
354
 
286
- def title_action(text)
287
- @driver.find_element(:xpath, '/html/body/div[1]/div/div[3]/div/div/div[1]/div/div[1]/div[2]/section/article/div[1]/div[1]/div').click
288
- Clipboard.copy(text)
289
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
290
- end
291
-
292
- def update_test
293
- @driver.get('https://blog.naver.com/'+@user_id+'?Redirect=Write')
294
- sleep(1)
295
- @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]'))
296
-
297
- title_action('제목 test')
298
-
299
- end
300
-
301
355
  def create_id
302
356
  @seed += 1
303
357
  hash = Digest::SHA256.hexdigest((Time.now.to_i+@seed).to_s).to_s
@@ -623,52 +677,10 @@ class Naver
623
677
  noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
624
678
  toomung = 0
625
679
  h = Hash.new
626
- # h[:authority] = 'blog.naver.com'
627
- # h[:method] = 'POST'
628
- # h[:path] = '/RabbitWrite.naver'
629
- # h[:scheme] = 'https'
630
- # h['accept'] = 'application/json, text/plain, */*'
631
- # h['accept-encoding'] = 'gzip, deflate, br'
632
- # h['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
633
- # h['content-type'] = 'application/x-www-form-urlencoded'
634
- # h['cookie'] = @cookie
635
- # h['origin'] = 'https://blog.naver.com'
636
- # h['referer'] = 'https://blog.naver.com/'+@user_id+'/postwrite?categoryNo=1'
637
- # h['sec-ch-ua'] = '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"'
638
- # h['sec-ch-ua-mobile'] = '?0'
639
- # h['sec-ch-ua-platform'] = '"Windows"'
640
- # h['sec-fetch-dest'] = 'empty'
641
- # h['sec-fetch-mode'] = 'cors'
642
- # h['sec-fetch-site'] = 'same-origin'
643
- # 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'
680
+
644
681
 
645
682
  data = Hash.new
646
- # data['blogId'] = @user_id
647
- # data['documentModel'] = Hash.new
648
- # data['documentModel']['documentId'] = ''
649
- # data['documentModel']['document'] = Hash.new
650
- # data['documentModel']['document']['version'] = '2.6.0'
651
- # data['documentModel']['document']['theme'] = 'default'
652
- # data['documentModel']['document']['language'] = 'ko-KR'
653
- # data['documentModel']['document']['components'] = Array.new
654
- # data['documentModel']['document']['components'][0] = {
655
- # 'id' => create_id(),
656
- # 'layout' => 'default',
657
- # 'title' => [
658
- # {
659
- # 'id' => create_id(),
660
- # 'nodes' => [{
661
- # 'id' => create_id(),
662
- # 'value' => title,
663
- # '@ctype' => 'textNode'
664
- # }],
665
- # '@ctype' => 'paragraph'
666
- # }
667
- # ],
668
- # 'subTitle' => nil,
669
- # 'align' => 'left',
670
- # '@ctype' => 'documentTitle'
671
- # }
683
+
672
684
 
673
685
  check_position = 1
674
686
  noko.css('p').each do |i|
@@ -718,21 +730,7 @@ class Naver
718
730
  sleep(3)
719
731
  key_stroke('enter')
720
732
  sleep(3)
721
- # @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
722
- # puts path = CGI.unescape(path)
723
- # image_data = image_update(path)
724
- # components_value = Hash.new
725
- # components_value['id'] = create_id()
726
- # components_value['layout'] = 'default'
727
- # begin
728
- # if i.to_s.split('text-align: ')[1].split(';')[0] == 'center'
729
- # components_value['align'] = 'center'
730
- # elsif i.to_s.split('text-align: ')[1].split(';')[0] == 'right'
731
- # components_value['align'] = 'right'
732
- # else
733
-
734
- # end
735
- # rescue
733
+
736
734
 
737
735
  if i2.to_s.split('href="')[1] != nil
738
736
  href2 = i2.to_s.split('href="')[1].split('"')[0]
@@ -748,30 +746,7 @@ class Naver
748
746
  #key_stroke('enter')
749
747
  sleep(1)
750
748
  end
751
- # end
752
- # components_value['src'] = 'https://blogfiles.pstatic.net'+image_data['item']['url']+'?type=w1'
753
- # components_value['internalResource'] = true
754
- # components_value['represent'] = true
755
- # components_value['path'] = image_data['item']['url']
756
- # components_value['domain'] = "https://blogfiles.pstatic.net"
757
- # components_value['fileSize'] = image_data['item']['fileSize'].to_i
758
- # components_value['width'] = image_data['item']['width'].to_i
759
- # components_value['widthPercentage'] = 0
760
- # components_value['height'] = image_data['item']['height'].to_i
761
- # components_value['fileName'] = image_data['item']['fileName'].to_i
762
- # components_value['caption'] = nil
763
- # if i2.to_s.split('href="')[1] != nil
764
- # components_value['link'] = CGI.unescape(i2.to_s.split('href="')[1].split('"')[0])
765
- # end
766
- # components_value['format'] = 'normal'
767
- # components_value['displayFormat'] = 'normal'
768
- # components_value['imageLoaded'] = true
769
- # components_value['contentMode'] = 'fit'
770
- # components_value['origin'] = {
771
- # 'srcFrom' => 'local',
772
- # '@ctype' => 'imageOrigin'
773
- # }
774
- # components_value['@ctype'] = 'image'
749
+
775
750
  elsif i2.to_s.include?('<video')
776
751
  path = i2.to_s.split('src="')[1].split('"')[0]
777
752
  path = URI.decode_www_form(path)[0][0]
@@ -1706,107 +1681,19 @@ class Wordpress
1706
1681
 
1707
1682
 
1708
1683
 
1709
- def chrome_start(url, user_id, user_pw)
1710
- @url = url
1711
- @user_id = user_id
1712
- @user_pw = user_pw
1713
- begin
1714
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1715
- @driver = Selenium::WebDriver.for :chrome
1716
- rescue
1717
- @driver = Selenium::WebDriver.for :chrome
1718
- end
1719
- end
1720
-
1721
- def login
1722
- @driver.get(@url+'/wp-admin')
1723
- @driver.find_element(:xpath , '//*[@id="user_login"]').send_keys(@user_id)
1724
- @driver.find_element(:xpath , '//*[@id="user_pass"]').send_keys(@user_pw)
1725
- @driver.find_element(:xpath , '//*[@id="wp-submit"]').click
1726
- @cookie = Hash.new
1727
- @driver.manage.all_cookies.each do |i|
1728
- @cookie[i[:name]] = i[:value]
1729
- end
1730
- sleep(2)
1731
- begin
1732
- puts @driver.find_element(:xpath , '/html/body/div/div/div[1]/div[1]/div/div[1]/a[1]/span').text
1733
- @driver.close
1734
- return 1
1735
- rescue => e
1736
- puts e
1737
- @driver.close
1738
- return 0
1739
- end
1740
- end
1684
+ #def chrome_start(url, user_id, user_pw)
1685
+ # @url = url
1686
+ # @user_id = user_id
1687
+ # @user_pw = user_pw
1688
+ # begin
1689
+ # Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1690
+ # @driver = Selenium::WebDriver.for :chrome
1691
+ # rescue
1692
+ # @driver = Selenium::WebDriver.for :chrome
1693
+ # end
1694
+ #end
1741
1695
 
1742
- def update
1743
- http = HTTP.cookies(@cookie).get(@url+'/wp-admin/post-new.php')
1744
- noko = Nokogiri::HTML(http.to_s)
1745
- @wpnonce = http.to_s.split('_wpnonce":"')[1].split('"')[0]
1746
- @data2 = Hash.new
1747
- @data2['_wpnonce'] = noko.xpath('//*[@id="_wpnonce"]')[0]['value']
1748
- @data2['_wp_http_referer'] = '/wp-admin/post-new.php'
1749
- @data2['user_ID'] = '1'
1750
- @data2['action'] = 'editpost'
1751
- @data2['originalaction'] = 'editpost'
1752
- @data2['post_author'] = '1'
1753
- @data2['post_type'] = 'post'
1754
- @data2['original_post_status'] = 'auto-draft'
1755
- @data2['referredby'] = @url+'/wp-admin/update-core.php'
1756
- @data2['_wp_original_http_referer'] = @url+'/wp-admin/update-core.php'
1757
- @data2['auto_draft'] = nil
1758
- @data2['post_ID'] = noko.xpath('//*[@id="post_ID"]')[0]['value']
1759
- @data2['meta-box-order-nonce'] = noko.xpath('//*[@id="meta-box-order-nonce"]')[0]['value']
1760
- @data2['closedpostboxesnonce'] = noko.xpath('//*[@id="closedpostboxesnonce"]')[0]['value']
1761
- @data2['post_title'] = 'title3'
1762
- @data2['samplepermalinknonce'] = noko.xpath('//*[@id="samplepermalinknonce"]')[0]['value']
1763
- @data2['content'] = 'content3'
1764
- @data2['wp-preview'] = nil
1765
- @data2['hidden_post_status'] = 'draft'
1766
- @data2['post_status'] = 'draft'
1767
- @data2['hidden_post_password'] = nil
1768
- @data2['hidden_post_visibility'] = 'public'
1769
- @data2['visibility'] = 'post'
1770
- @data2['post_password'] = nil
1771
- @data2['mm'] = '10'
1772
- @data2['jj'] = '24'
1773
- @data2['aa'] = '2022'
1774
- @data2['hh'] = '02'
1775
- @data2['mn'] = '41'
1776
- @data2['ss'] = '32'
1777
- @data2['hidden_mm'] = '10'
1778
- @data2['cur_mm'] = '10'
1779
- @data2['hidden_jj'] = '24'
1780
- @data2['cur_jj'] = '24'
1781
- @data2['hidden_aa'] = '2022'
1782
- @data2['cur_aa'] = '2022'
1783
- @data2['hidden_hh'] = '02'
1784
- @data2['cur_hh'] = '02'
1785
- @data2['hidden_mn'] = '41'
1786
- @data2['cur_mn'] = '41'
1787
- @data2['original_publish'] = '공개'
1788
- @data2['publish'] = '공개'
1789
- @data2['post_format'] = '0'
1790
- @data2['post_category[]'] = '0'
1791
- @data2['newcategory'] = '새 카테고리 이름'
1792
- @data2['newcategory_parent'] = -1
1793
- @data2['_ajax_nonce-add-category'] = noko.xpath('//*[@id="_ajax_nonce-add-category"]')[0]['value']
1794
- @data2['tax_input[post_tag]'] = nil
1795
- @data2['newtag[post_tag]'] = nil
1796
- @data2['_thumbnail_id'] = -1
1797
- @data2['excerpt'] = nil
1798
- @data2['trackback_url'] = nil
1799
- @data2['metakeyinput'] = nil
1800
- @data2['metavalue'] = nil
1801
- @data2['_ajax_nonce-add-meta'] = noko.xpath('//*[@id="_ajax_nonce-add-meta"]')[0]['value']
1802
- @data2['advanced_view'] = '1'
1803
- @data2['comment_status'] = 'open'
1804
- @data2['ping_status'] = 'open'
1805
- @data2['post_name'] = nil
1806
- @data2['post_author_override'] = '1'
1807
- #result_http = HTTP.cookies(@cookie).post(@url+'/wp-admin/post.php', :form => @data)
1808
- return @data2
1809
- end
1696
+
1810
1697
 
1811
1698
  def auto_image
1812
1699
  begin
@@ -2035,8 +1922,7 @@ class Wordpress
2035
1922
  @inumber2 = 0
2036
1923
  @video = Array.new
2037
1924
 
2038
- price_hash = Hash.new
2039
-
1925
+
2040
1926
  while true
2041
1927
  for n in 0..@data['table'].length-1
2042
1928
  @data['table'][n][10] = 0
@@ -2129,6 +2015,13 @@ class Wordpress
2129
2015
  end
2130
2016
  end
2131
2017
  end
2018
+
2019
+ if @data['포스트설정']['gpt제목'].checked?
2020
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2021
+ gpt_text1 = chat.message(title)
2022
+ title = gpt_text1.to_s
2023
+ end
2024
+
2132
2025
  @data['table'][index][-1] = 5
2133
2026
  @data['table'] << []
2134
2027
  @data['table'].pop
@@ -2166,6 +2059,25 @@ class Wordpress
2166
2059
  end
2167
2060
  end
2168
2061
  end
2062
+
2063
+
2064
+ if @data['포스트설정']['gpt내용'].checked?
2065
+ api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2066
+ #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
2067
+ #imotcon_change = @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8')
2068
+ #template_change = @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8')
2069
+ #ttdanar_change = @data['포스트설정']['단어링크적용단어'].text.to_s.force_encoding('utf-8')
2070
+ #sajine_change = @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8')
2071
+ #mov_change = @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8')
2072
+ #map_change = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8')
2073
+ #inyong9_change = @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8')
2074
+
2075
+
2076
+ chat = Chat_content.new(api_key)
2077
+ gpt_text3 = chat.message(content)
2078
+ content = gpt_text3.to_s
2079
+ end
2080
+
2169
2081
  content_tag = content.split('@##@')[1]
2170
2082
  content = content.split('@##@')[0]
2171
2083
  @data['table'][index][-1] = 15
@@ -2364,7 +2276,7 @@ class Wordpress
2364
2276
  @data['table'][index][-1] = 50
2365
2277
  @data['table'] << []
2366
2278
  @data['table'].pop
2367
- if @data['포스트설정']['gpt'].checked?
2279
+ if @data['포스트설정']['gpt키워드'].checked?
2368
2280
  chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2369
2281
  gpt_text = chat.message(keyword)
2370
2282
  content = content + "\n(자동생성글)\n" + gpt_text
@@ -2385,7 +2297,7 @@ class Wordpress
2385
2297
  joongbok_check = 0
2386
2298
  counter10 = 0
2387
2299
  while joongbok_check == 0
2388
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2300
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2389
2301
  content22 = content.split("(자동생성글)")[1].split("\n")
2390
2302
  else
2391
2303
  content22 = content.split("\n")
@@ -2409,12 +2321,12 @@ class Wordpress
2409
2321
  content2 = content.split("\n")
2410
2322
  end
2411
2323
 
2412
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2324
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2413
2325
  content2 = content.split("(자동생성글)")[1].split("\n")
2414
2326
  position.pop
2415
2327
  end
2416
2328
 
2417
- if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt'].checked? == false
2329
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2418
2330
  content2 = content.split("\n")
2419
2331
  end
2420
2332
 
@@ -2460,7 +2372,7 @@ class Wordpress
2460
2372
  content = content3.join("\n")
2461
2373
  end
2462
2374
 
2463
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2375
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2464
2376
  content2.each_with_index do |con, index|
2465
2377
  if position.include?(index)
2466
2378
  insert_keyword_text = keyword.to_s
@@ -2490,7 +2402,7 @@ class Wordpress
2490
2402
  end
2491
2403
  end
2492
2404
 
2493
- if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt'].checked? == false
2405
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2494
2406
  begin
2495
2407
  content2.each_with_index do |con, index|
2496
2408
  if position.include?(index)
@@ -2585,7 +2497,7 @@ class Wordpress
2585
2497
  end
2586
2498
  end
2587
2499
 
2588
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2500
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2589
2501
  if @data['포스트설정']['자동글 수식에 입력'].checked?
2590
2502
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2591
2503
  content55 = content.split("(자동생성글)")[1].to_s
@@ -2617,7 +2529,7 @@ class Wordpress
2617
2529
 
2618
2530
  position = position.sort
2619
2531
  ##여기서부터 이미지 순서대로 안되서 변경####-------------------------------------------------------------------------------
2620
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2532
+ # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2621
2533
  # image_url22 = get_image_file().force_encoding('utf-8')
2622
2534
  # end
2623
2535
 
@@ -2635,7 +2547,7 @@ class Wordpress
2635
2547
  # end
2636
2548
  # end
2637
2549
 
2638
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2550
+ # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2639
2551
  # content = content5.join("\n")+'(자동생성글)'+content55
2640
2552
  # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
2641
2553
  # content = iconv.iconv(content)
@@ -2655,7 +2567,7 @@ class Wordpress
2655
2567
  ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
2656
2568
 
2657
2569
  ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
2658
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2570
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2659
2571
  sleep(2)
2660
2572
  puts '이미지 자동 세탁 중 · · · '
2661
2573
  end
@@ -2674,7 +2586,7 @@ class Wordpress
2674
2586
  end
2675
2587
  sleep(2)
2676
2588
  puts '이미지 자동 세탁 완료 · · · '
2677
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2589
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2678
2590
  content = content5.join("\n")+'(자동생성글)'+content55
2679
2591
  puts content
2680
2592
  ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
@@ -2819,7 +2731,7 @@ class Wordpress
2819
2731
  content = content
2820
2732
  soosick_1 = content_end
2821
2733
  else
2822
- if @data['포스트설정']['gpt'].checked?
2734
+ if @data['포스트설정']['gpt키워드'].checked?
2823
2735
  if @data['포스트설정']['gpt상단'].checked?
2824
2736
  content = content_end+"\n"+content+"\n"
2825
2737
  else
@@ -3489,7 +3401,10 @@ class Wordpress
3489
3401
  }
3490
3402
  horizontal_box{
3491
3403
  stretchy false
3404
+ grid{
3492
3405
  button('전체선택'){
3406
+ top 1
3407
+ left 1
3493
3408
  on_clicked{
3494
3409
  for n in 0..@data['키워드설정']['키워드'].length-1
3495
3410
  @data['키워드설정']['키워드'][n][0] = true
@@ -3498,7 +3413,20 @@ class Wordpress
3498
3413
  end
3499
3414
  }
3500
3415
  }
3501
- button('키워드삭제'){
3416
+ button('선택해제'){
3417
+ top 1
3418
+ left 2
3419
+ on_clicked{
3420
+ for n in 0..@data['키워드설정']['키워드'].length-1
3421
+ @data['키워드설정']['키워드'][n][0] = false
3422
+ @data['키워드설정']['키워드'] << []
3423
+ @data['키워드설정']['키워드'].pop
3424
+ end
3425
+ }
3426
+ }
3427
+ button('삭제하기'){
3428
+ top 1
3429
+ left 3
3502
3430
  on_clicked{
3503
3431
  m = Array.new
3504
3432
  for n in 0..@data['키워드설정']['키워드'].length-1
@@ -3513,6 +3441,8 @@ class Wordpress
3513
3441
  @data['키워드설정']['키워드'].delete(nil)
3514
3442
  }
3515
3443
  }
3444
+ }
3445
+
3516
3446
  @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3517
3447
  stretchy false
3518
3448
  on_toggled{ |c|
@@ -3530,6 +3460,59 @@ class Wordpress
3530
3460
  }
3531
3461
  }
3532
3462
  }
3463
+ vertical_separator{
3464
+ stretchy false
3465
+ }
3466
+ horizontal_box{
3467
+ stretchy false
3468
+ grid{
3469
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3470
+ top 1
3471
+ left 0
3472
+ #enabled false # 기본적으로 비활성화
3473
+ on_toggled {
3474
+ if @data['포스트설정']['gpt키워드'].checked?
3475
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3476
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3477
+ else
3478
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3479
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3480
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3481
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3482
+ end
3483
+ }
3484
+
3485
+ }
3486
+
3487
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3488
+ top 1
3489
+ left 1
3490
+ enabled false # 기본적으로 비활성화
3491
+ on_toggled{
3492
+ if @data['포스트설정']['gpt상단'].checked?
3493
+ @data['포스트설정']['gpt하단'].checked = false
3494
+ end
3495
+ }
3496
+ }
3497
+
3498
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3499
+ top 1
3500
+ left 2
3501
+ enabled false # 기본적으로 비활성화
3502
+ on_toggled{
3503
+ if @data['포스트설정']['gpt하단'].checked?
3504
+ @data['포스트설정']['gpt상단'].checked = false
3505
+ end
3506
+ }
3507
+ }
3508
+ } }
3509
+ horizontal_box{
3510
+ stretchy false
3511
+ grid{
3512
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3513
+ } } }
3514
+
3515
+
3533
3516
  table{
3534
3517
  checkbox_column('선택'){
3535
3518
  editable true
@@ -3540,7 +3523,9 @@ class Wordpress
3540
3523
 
3541
3524
  cell_rows @data['키워드설정']['키워드']
3542
3525
  }
3543
-
3526
+
3527
+
3528
+
3544
3529
  }
3545
3530
  vertical_separator{
3546
3531
  stretchy false
@@ -3569,7 +3554,10 @@ class Wordpress
3569
3554
  }
3570
3555
  horizontal_box{
3571
3556
  stretchy false
3557
+ grid{
3572
3558
  button('전체선택'){
3559
+ top 1
3560
+ left 1
3573
3561
  on_clicked{
3574
3562
  for n in 0..@data['제목설정']['제목'].length-1
3575
3563
  @data['제목설정']['제목'][n][0] = true
@@ -3578,7 +3566,20 @@ class Wordpress
3578
3566
  end
3579
3567
  }
3580
3568
  }
3581
- button('제목삭제'){
3569
+ button('선택해제'){
3570
+ top 1
3571
+ left 2
3572
+ on_clicked{
3573
+ for n in 0..@data['제목설정']['제목'].length-1
3574
+ @data['제목설정']['제목'][n][0] = false
3575
+ @data['제목설정']['제목'] << []
3576
+ @data['제목설정']['제목'].pop
3577
+ end
3578
+ }
3579
+ }
3580
+ button('삭제하기'){
3581
+ top 1
3582
+ left 3
3582
3583
  on_clicked{
3583
3584
  m = Array.new
3584
3585
  for n in 0..@data['제목설정']['제목'].length-1
@@ -3593,6 +3594,7 @@ class Wordpress
3593
3594
  @data['제목설정']['제목'].delete(nil)
3594
3595
  }
3595
3596
  }
3597
+ }
3596
3598
  @data['제목설정']['순서사용'] = checkbox('순서사용'){
3597
3599
  stretchy false
3598
3600
  on_toggled{ |c|
@@ -3610,6 +3612,23 @@ class Wordpress
3610
3612
  }
3611
3613
  }
3612
3614
  }
3615
+ vertical_separator{
3616
+ stretchy false
3617
+ }
3618
+ horizontal_box{
3619
+ stretchy false
3620
+ grid{
3621
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3622
+
3623
+
3624
+ }}}
3625
+ horizontal_box{
3626
+ stretchy false
3627
+ grid{
3628
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3629
+ } } }
3630
+
3631
+
3613
3632
  table{
3614
3633
  checkbox_column('선택'){
3615
3634
  editable true
@@ -3620,6 +3639,7 @@ class Wordpress
3620
3639
 
3621
3640
  cell_rows @data['제목설정']['제목']
3622
3641
  }
3642
+
3623
3643
 
3624
3644
  }
3625
3645
  vertical_separator{
@@ -3647,7 +3667,10 @@ class Wordpress
3647
3667
  }
3648
3668
  horizontal_box{
3649
3669
  stretchy false
3670
+ grid{
3650
3671
  button('전체선택'){
3672
+ top 1
3673
+ left 1
3651
3674
  on_clicked{
3652
3675
  for n in 0..@data['내용설정']['내용'].length-1
3653
3676
  @data['내용설정']['내용'][n][0] = true
@@ -3656,7 +3679,20 @@ class Wordpress
3656
3679
  end
3657
3680
  }
3658
3681
  }
3659
- button('내용삭제'){
3682
+ button('선택해제'){
3683
+ top 1
3684
+ left 2
3685
+ on_clicked{
3686
+ for n in 0..@data['내용설정']['내용'].length-1
3687
+ @data['내용설정']['내용'][n][0] = false
3688
+ @data['내용설정']['내용'] << []
3689
+ @data['내용설정']['내용'].pop
3690
+ end
3691
+ }
3692
+ }
3693
+ button('삭제하기'){
3694
+ top 1
3695
+ left 3
3660
3696
  on_clicked{
3661
3697
  m = Array.new
3662
3698
  for n in 0..@data['내용설정']['내용'].length-1
@@ -3671,6 +3707,7 @@ class Wordpress
3671
3707
  @data['내용설정']['내용'].delete(nil)
3672
3708
  }
3673
3709
  }
3710
+ }
3674
3711
  @data['내용설정']['순서사용'] = checkbox('순서사용'){
3675
3712
  stretchy false
3676
3713
  on_toggled{ |c|
@@ -3688,6 +3725,22 @@ class Wordpress
3688
3725
  }
3689
3726
  }
3690
3727
  }
3728
+ vertical_separator{
3729
+ stretchy false
3730
+ }
3731
+ horizontal_box{
3732
+ stretchy false
3733
+ grid{
3734
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
3735
+
3736
+
3737
+ }}}
3738
+ horizontal_box{
3739
+ stretchy false
3740
+ grid{
3741
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3742
+ } } }
3743
+
3691
3744
  table{
3692
3745
  checkbox_column('선택'){
3693
3746
  editable true
@@ -3705,8 +3758,8 @@ class Wordpress
3705
3758
  stretchy false
3706
3759
  text "내용폴더경로 ex)C:\\내용\\폴더1"
3707
3760
  }
3708
- button('폴더째로불러오기'){
3709
- stretchy false
3761
+ button('폴더째로 불러오기'){
3762
+
3710
3763
  on_clicked{
3711
3764
  path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3712
3765
  Dir.entries(@data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')).each do |file|
@@ -3804,7 +3857,7 @@ class Wordpress
3804
3857
  text "사진폴더경로 ex)C:\\사진\\폴더2"
3805
3858
  }
3806
3859
  button('폴더째로불러오기'){
3807
- stretchy false
3860
+
3808
3861
  on_clicked{
3809
3862
  path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3810
3863
  Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
@@ -4057,6 +4110,18 @@ class Wordpress
4057
4110
  @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
4058
4111
  top 2
4059
4112
  left 0
4113
+ #enabled false # 기본적으로 비활성화
4114
+ on_toggled {
4115
+ if @data['포스트설정']['제목에키워드삽입'].checked?
4116
+ @data['포스트설정']['제목앞'].enabled = true # '내용투명' 활성화
4117
+ @data['포스트설정']['제목뒤'].enabled = true # '내용투명' 활성화
4118
+ else
4119
+ @data['포스트설정']['제목앞'].checked = false # 체크 해제
4120
+ @data['포스트설정']['제목앞'].enabled = false # 비활성화
4121
+ @data['포스트설정']['제목뒤'].checked = false # 체크 해제
4122
+ @data['포스트설정']['제목뒤'].enabled = false # 비활성화
4123
+ end
4124
+ }
4060
4125
  }
4061
4126
  @data['포스트설정']['제목에키워드삽입숫자1'] = entry(){
4062
4127
  top 2
@@ -4079,6 +4144,7 @@ class Wordpress
4079
4144
  @data['포스트설정']['제목앞'] = checkbox('제목에 키워드 삽입 제목 앞'){
4080
4145
  top 3
4081
4146
  left 3
4147
+ enabled false # 기본적으로 비활성화
4082
4148
  on_toggled{
4083
4149
  if @data['포스트설정']['제목앞'].checked? == true
4084
4150
  if @data['포스트설정']['제목뒤'].checked?
@@ -4094,6 +4160,7 @@ class Wordpress
4094
4160
  @data['포스트설정']['제목뒤'] = checkbox('제목에 키워드 삽입 제목 뒤'){
4095
4161
  top 4
4096
4162
  left 3
4163
+ enabled false # 기본적으로 비활성화
4097
4164
  on_toggled{
4098
4165
  if @data['포스트설정']['제목뒤'].checked? == true
4099
4166
  if @data['포스트설정']['제목앞'].checked?
@@ -4102,26 +4169,51 @@ class Wordpress
4102
4169
  end
4103
4170
  }
4104
4171
  }
4105
- @data['포스트설정']['제목내용설정'] = checkbox('내용의 문장을 제목으로 설정'){
4172
+ @data['포스트설정']['특수문자'] = checkbox('제목에 키워드 삽입 특수문자 삽입'){
4106
4173
  top 4
4107
4174
  left 0
4108
4175
  }
4109
-
4110
- @data['포스트설정']['특수문자'] = checkbox('제목에 키워드 삽입 시 특수문자 삽입'){
4176
+ @data['포스트설정']['제목을랜덤'] = checkbox('제목을 랜덤 단어 조합으로 자동 입력'){
4111
4177
  top 5
4112
4178
  left 0
4179
+ on_toggled{
4180
+ if @data['포스트설정']['제목을랜덤'].checked? == true
4181
+ if @data['포스트설정']['제목내용설정'].checked?
4182
+ @data['포스트설정']['제목내용설정'].checked = false
4183
+ end
4184
+ end
4185
+ }
4113
4186
  }
4114
- @data['포스트설정']['제목을랜덤'] = checkbox('제목을 랜덤 단어 조합으로 자동 입력'){
4187
+ @data['포스트설정']['제목내용설정'] = checkbox('내용의 문장을 제목으로 설정'){
4115
4188
  top 6
4116
4189
  left 0
4190
+ on_toggled{
4191
+ if @data['포스트설정']['제목내용설정'].checked? == true
4192
+ if @data['포스트설정']['제목을랜덤'].checked?
4193
+ @data['포스트설정']['제목을랜덤'].checked = false
4194
+ end
4195
+ end
4196
+ }
4117
4197
  }
4118
4198
  @data['포스트설정']['내용키워드삽입'] = checkbox('내용 키워드 삽입'){
4119
4199
  top 7
4120
4200
  left 0
4201
+ on_toggled {
4202
+ if @data['포스트설정']['내용키워드삽입'].checked?
4203
+ @data['포스트설정']['키워드삽입'].enabled = true # '내용투명' 활성화
4204
+ @data['포스트설정']['키워드삽입시링크'].enabled = true # '내용투명' 활성화
4205
+ else
4206
+ @data['포스트설정']['키워드삽입'].checked = false # 체크 해제
4207
+ @data['포스트설정']['키워드삽입'].enabled = false # 비활성화
4208
+ @data['포스트설정']['키워드삽입시링크'].text = 'URL' # 기본 텍스트 설정
4209
+ @data['포스트설정']['키워드삽입시링크'].enabled = false # 비활성화
4210
+ end
4211
+ }
4121
4212
  }
4122
4213
  @data['포스트설정']['키워드삽입시작숫자'] = entry(){
4123
4214
  top 7
4124
4215
  left 1
4216
+
4125
4217
  text '최소수량'
4126
4218
  }
4127
4219
  label('~'){
@@ -4134,63 +4226,61 @@ class Wordpress
4134
4226
  text '최대수량'
4135
4227
  }
4136
4228
  @data['포스트설정']['키워드삽입'] = checkbox('내용 키워드 삽입시 링크 삽입'){
4229
+ enabled false # 기본적으로 비활성화
4137
4230
  top 8
4138
4231
  left 0
4139
4232
  }
4140
4233
  @data['포스트설정']['키워드삽입시링크'] = entry(){
4234
+ enabled false # 기본적으로 비활성화
4141
4235
  top 8
4142
4236
  left 1
4143
4237
  text 'URL'
4144
4238
  }
4145
- @data['포스트설정']['내용을자동생성'] = checkbox('내용을 키워드 기반으로 자동 생성해서 포스팅'){
4239
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 생성으로만 등록(GPT 사용시 자체 생성)'){
4146
4240
  top 9
4147
4241
  left 0
4148
4242
  on_toggled{
4149
4243
  if @data['포스트설정']['내용을자동생성'].checked?
4150
- if @data['포스트설정']['내용과자동생성'].checked?
4151
- @data['포스트설정']['내용과자동생성'].checked = false
4152
- end
4244
+ @data['포스트설정']['내용과자동생성'].checked = false
4245
+ @data['포스트설정']['내용투명'].checked = false
4246
+ @data['포스트설정']['자동글 수식에 입력'].checked = false
4247
+
4153
4248
  end
4154
4249
  }
4155
4250
  }
4156
4251
 
4157
- @data['포스트설정']['gpt'] = checkbox('내용을 키워드 기반의 GPT로 생성해서 포스팅'){
4158
- top 10
4159
- left 0
4160
- }
4161
4252
 
4162
- @data['포스트설정']['api_key'] = entry(){
4163
- top 10
4164
- left 1
4165
- text 'api key'
4166
- }
4167
-
4168
- @data['포스트설정']['gpt상단'] = checkbox('원고내용 위에 넣기'){
4169
- top 10
4170
- left 3
4171
- }
4172
-
4173
- @data['포스트설정']['gpt하단'] = checkbox('원고내용 아래에 넣기'){
4174
- top 11
4175
- left 3
4176
- }
4253
+
4177
4254
 
4178
4255
  aa1 = 2
4179
- @data['포스트설정']['내용과자동생성'] = checkbox('내용을 내용 파일 + 자동 생성 조합으로 포스팅'){
4256
+ @data['포스트설정']['내용과자동생성'] = checkbox('내용파일+키워드기반 생성 등록(GPT 사용시 자체 생성)') {
4180
4257
  top 10 + aa1
4181
4258
  left 0
4182
- on_toggled{
4183
- if @data['포스트설정']['내용과자동생성'].checked?
4184
- if @data['포스트설정']['내용을자동생성'].checked?
4185
- @data['포스트설정']['내용을자동생성'].checked = false
4186
- end
4187
- end
4259
+ on_toggled {
4260
+ if @data['포스트설정']['내용과자동생성'].checked?
4261
+ @data['포스트설정']['내용을자동생성'].checked = false
4262
+ @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4263
+ @data['포스트설정']['자동글 수식에 입력'].enabled = true # '내용투명' 활성화
4264
+ else
4265
+ @data['포스트설정']['내용투명'].checked = false # 체크 해제
4266
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4267
+ @data['포스트설정']['자동글 수식에 입력'].checked = false # 체크 해제
4268
+ @data['포스트설정']['자동글 수식에 입력'].enabled = false # 비활성화
4269
+ end
4188
4270
  }
4189
- }
4190
- @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리'){
4191
- top 11+ aa1
4271
+ }
4272
+
4273
+ @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4274
+ top 11 + aa1
4192
4275
  left 0
4193
- }
4276
+ enabled false # 기본적으로 비활성화
4277
+ on_toggled {
4278
+ if @data['포스트설정']['내용투명'].checked?
4279
+ @data['포스트설정']['내용을자동생성'].checked = false
4280
+ @data['포스트설정']['자동글 수식에 입력'].checked = false
4281
+ end
4282
+ }
4283
+ }
4194
4284
  @data['포스트설정']['내용자동변경'] = checkbox('내용에 단어들을 자동 변경'){
4195
4285
  top 12+ aa1
4196
4286
  left 0
@@ -4218,6 +4308,18 @@ class Wordpress
4218
4308
  @data['포스트설정']['내용사진자동삽입'] = checkbox('내용 사진 자동 삽입'){
4219
4309
  top 13+ aa1
4220
4310
  left 0
4311
+ #enabled false # 기본적으로 비활성화
4312
+ on_toggled {
4313
+ if @data['포스트설정']['내용사진자동삽입'].checked?
4314
+ @data['포스트설정']['내용사진링크'].enabled = true # '내용투명' 활성화
4315
+ @data['포스트설정']['내용사진링크값'].enabled = true # '내용투명' 활성화
4316
+ else
4317
+ @data['포스트설정']['내용사진링크'].checked = false # 체크 해제
4318
+ @data['포스트설정']['내용사진링크'].enabled = false # 비활성화
4319
+ @data['포스트설정']['내용사진링크값'].text = 'URL' # 기본 텍스트 설정
4320
+ @data['포스트설정']['내용사진링크값'].enabled = false # 비활성화
4321
+ end
4322
+ }
4221
4323
  }
4222
4324
  @data['포스트설정']['내용사진자동삽입시작숫자'] = entry(){
4223
4325
  top 13+ aa1
@@ -4235,15 +4337,28 @@ class Wordpress
4235
4337
  }
4236
4338
 
4237
4339
  @data['포스트설정']['내용사진링크'] = checkbox('내용 사진 자동 삽입시 링크 삽입'){
4340
+ enabled false # 기본적으로 비활성화
4238
4341
  top 14+ aa1
4239
4342
  left 0
4240
4343
  }
4241
4344
 
4242
4345
  @data['포스트설정']['내용사진링크값'] = entry(){
4346
+ enabled false # 기본적으로 비활성화
4243
4347
  top 14+ aa1
4244
4348
  left 1
4245
4349
  text 'URL'
4246
4350
  }
4351
+
4352
+ @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4353
+ top 15+ aa1
4354
+ left 0
4355
+ }
4356
+
4357
+ @data['포스트설정']['api_key'] = entry(){
4358
+ top 15+ aa1
4359
+ left 1
4360
+ text 'api key 입력 필수!!'
4361
+ }
4247
4362
  }
4248
4363
  }
4249
4364
 
@@ -4434,6 +4549,22 @@ class Wordpress
4434
4549
  @data['포스트설정']['막글삽입'] = checkbox('내용 하단에 막글 삽입'){
4435
4550
  top 6
4436
4551
  left 0
4552
+ #enabled false # 기본적으로 비활성화
4553
+ on_toggled {
4554
+ if @data['포스트설정']['막글삽입'].checked?
4555
+ @data['포스트설정']['막글투명'].enabled = true # '내용투명' 활성화
4556
+ @data['포스트설정']['막글그대로'].enabled = true # '내용투명' 활성화
4557
+ @data['포스트설정']['막글 수식에 입력'].enabled = true # '내용투명' 활성화
4558
+
4559
+ else
4560
+ @data['포스트설정']['막글투명'].checked = false # 체크 해제
4561
+ @data['포스트설정']['막글투명'].enabled = false # 비활성화
4562
+ @data['포스트설정']['막글그대로'].checked = false # 체크 해제
4563
+ @data['포스트설정']['막글그대로'].enabled = false # 비활성화
4564
+ @data['포스트설정']['막글 수식에 입력'].checked = false # 체크 해제
4565
+ @data['포스트설정']['막글 수식에 입력'].enabled = false # 비활성화
4566
+ end
4567
+ }
4437
4568
  }
4438
4569
  @data['포스트설정']['막글삽입시작숫자'] = entry{
4439
4570
  top 6
@@ -4463,10 +4594,12 @@ class Wordpress
4463
4594
  @data['포스트설정']['막글투명'] = checkbox('막글 안보이게 처리'){
4464
4595
  top 7
4465
4596
  left 0
4597
+ enabled false # 기본적으로 비활성화
4466
4598
  }
4467
4599
  @data['포스트설정']['막글그대로'] = checkbox('막글 그대로 입력'){
4468
4600
  top 7
4469
4601
  left 1
4602
+ enabled false # 기본적으로 비활성화
4470
4603
  }
4471
4604
 
4472
4605
  @data['포스트설정']['태그삽입1'] = checkbox('태그삽입'){
@@ -4491,11 +4624,19 @@ class Wordpress
4491
4624
  @data['포스트설정']['자동글 수식에 입력'] = checkbox('자동글 수식에 입력'){
4492
4625
  top 9
4493
4626
  left 0
4627
+ enabled false # 기본적으로 비활성화
4628
+ on_toggled {
4629
+ if @data['포스트설정']['자동글 수식에 입력'].checked?
4630
+ @data['포스트설정']['내용을자동생성'].checked = false
4631
+ @data['포스트설정']['내용투명'].checked = false
4632
+ end
4633
+ }
4494
4634
  }
4495
4635
 
4496
4636
  @data['포스트설정']['막글 수식에 입력'] = checkbox('막글 수식에 입력'){
4497
4637
  top 9
4498
4638
  left 1
4639
+ enabled false # 기본적으로 비활성화
4499
4640
  }
4500
4641
 
4501
4642
 
@@ -4578,10 +4719,22 @@ class Wordpress
4578
4719
  @data['포스트설정']['테더링'] = checkbox('테더링 IP 사용'){
4579
4720
  top 15
4580
4721
  left 0
4722
+ on_toggled{
4723
+ if @data['포스트설정']['테더링'].checked?
4724
+ @data['포스트설정']['프록시'].checked = false
4725
+
4726
+ end
4727
+ }
4581
4728
  }
4582
4729
  @data['포스트설정']['프록시'] = checkbox('프록시 IP 사용'){
4583
4730
  top 15
4584
4731
  left 1
4732
+ on_toggled{
4733
+ if @data['포스트설정']['프록시'].checked?
4734
+ @data['포스트설정']['테더링'].checked = false
4735
+
4736
+ end
4737
+ }
4585
4738
  }
4586
4739
  button('프록시 IP 파일 불러오기'){
4587
4740
  top 15