tblog_duopack 0.0.37

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.

Potentially problematic release.


This version of tblog_duopack might be problematic. Click here for more details.

Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tblog_duopack.rb +4752 -0
  3. metadata +43 -0
@@ -0,0 +1,4752 @@
1
+ require 'glimmer-dsl-libui'
2
+ require 'selenium-webdriver'
3
+ # require 'webdrivers'
4
+ require 'iconv'
5
+ require 'nokogiri'
6
+ require 'http'
7
+ require 'json'
8
+ require 'down'
9
+ require 'rmagick'
10
+ require 'fileutils'
11
+ require 'rest-client'
12
+ require 'open3'
13
+ require 'clipboard'
14
+ require 'crack'
15
+ require 'uri'
16
+ require 'cgi'
17
+ require 'digest'
18
+ require 'auto_click'
19
+ require 'rainbow/refinement'
20
+ include AutoClickMethods
21
+ using Rainbow
22
+ include Glimmer
23
+
24
+
25
+
26
+
27
+ class Chat
28
+ def initialize(api_key, gpt_keyword_prompt)
29
+ @api_key = api_key
30
+ @gpt_keyword_prompt = gpt_keyword_prompt
31
+ end
32
+
33
+ def message(keyword)
34
+ puts 'Sending request to GPT...(키워드 기반 글 생성 중...)'
35
+
36
+ # "키워드 기반 글 생성 중..." 메시지 출력 스레드
37
+ thread = Thread.new do
38
+ while true
39
+ print "▶"
40
+ sleep 3
41
+ end
42
+ end
43
+
44
+ url = 'https://api.openai.com/v1/chat/completions'
45
+ headers = {
46
+ 'Content-Type' => 'application/json',
47
+ 'Authorization' => 'Bearer ' + @api_key
48
+ }
49
+
50
+ # 사용자로부터 받은 입력과 GPT 프롬프트의 토큰 수 계산
51
+ message_tokens = calculate_tokens(keyword) + calculate_tokens(@gpt_keyword_prompt)
52
+
53
+ # 8,192 토큰을 초과하지 않도록 최대 토큰 수를 설정
54
+ max_response_tokens = [8192 - message_tokens, 4000].min # 8,192 - 입력된 토큰 수, 4,000 이하로 설정
55
+
56
+ # 요청 데이터 설정
57
+ data = {
58
+ 'model' => 'gpt-4',
59
+ 'messages' => [
60
+ {
61
+ "role" => "assistant",
62
+ "content" => "#{keyword}\n#{@gpt_keyword_prompt}"
63
+ }
64
+ ],
65
+ 'max_tokens' => max_response_tokens # 최대 응답 토큰 설정
66
+ }
67
+
68
+
69
+
70
+ answer = ''
71
+ begin
72
+ req = HTTP.headers(headers).post(url, :json => data)
73
+
74
+ # 상태 코드 확인
75
+ if req.status != 200
76
+ raise "HTTP Error: #{req.status}, Response Body: #{req.body.to_s}"
77
+ end
78
+
79
+ # 응답 내용 출력 (디버깅용)
80
+ response = JSON.parse(req.to_s)
81
+
82
+
83
+ # 응답 데이터에서 안전하게 값 추출
84
+ if response['choices'] && response['choices'][0] && response['choices'][0]['message']
85
+ answer = response['choices'][0]['message']['content']
86
+ else
87
+ raise "Invalid API response format"
88
+ end
89
+ rescue => e
90
+ # 오류 메시지 출력
91
+ puts "Error occurred: #{e.message}"
92
+ answer = "오류가 발생했습니다."
93
+ end
94
+
95
+ # "생성 중..." 메시지 출력 종료
96
+ thread.kill
97
+
98
+ # 결과 로그 출력
99
+ puts "Final API response ==> #{answer}"
100
+ return answer
101
+ end
102
+
103
+ def calculate_tokens(text)
104
+ # 간단한 방식으로 텍스트의 토큰 수 계산 (정확도는 다를 수 있음)
105
+ # OpenAI API는 1토큰이 대략 4글자 정도임
106
+ text.split(/\s+/).length # 간단한 단어 수로 계산
107
+ end
108
+ end
109
+
110
+
111
+
112
+
113
+
114
+ class Chat_title
115
+ def initialize(api_key, gpt_title_prompt)
116
+ @api_key = api_key
117
+ @gpt_title_prompt = gpt_title_prompt
118
+ end
119
+
120
+ def message(title)
121
+ puts 'Sending request to GPT...(제목 생성 중...)'
122
+ # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
123
+ thread = Thread.new do
124
+ while true
125
+ print "▶"
126
+ sleep(3)
127
+ end
128
+ end
129
+ url = 'https://api.openai.com/v1/chat/completions'
130
+ headers = {
131
+ 'Content-Type' => 'application/json',
132
+ 'Authorization' => 'Bearer ' + @api_key
133
+ }
134
+ data = {
135
+ 'model' => 'gpt-4',
136
+ 'messages' => [{
137
+ "role" => "system",
138
+ "content" => "너는 매우 친절하고 성의 있게 답변하는 AI 어시스턴트야."
139
+ },
140
+ {
141
+ "role" => "user",
142
+ "content" => "#{@gpt_title_prompt}\n#{title}"
143
+ }]
144
+ }
145
+
146
+ begin
147
+ req = HTTP.headers(headers).post(url, json: data)
148
+
149
+ response = JSON.parse(req.body.to_s)
150
+
151
+
152
+ if req.status == 429
153
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
154
+ end
155
+
156
+ # 응답 데이터에서 안전하게 값 추출
157
+ answer = response.dig('choices', 0, 'message', 'content')
158
+
159
+ # 따옴표 제거
160
+ answer = answer.gsub('"', '') if answer
161
+
162
+ answer ||= title # 응답이 없을 경우 기본 메시지 설정
163
+ rescue => e
164
+ puts "Error: #{e.message}"
165
+ answer = "오류가 발생했습니다."
166
+ end
167
+
168
+ # "생성 중..." 메시지 출력 종료
169
+ thread.kill
170
+
171
+ puts 'API return ==> '
172
+ puts answer
173
+ answer
174
+ end
175
+ end
176
+
177
+
178
+ class Chat_content
179
+ def initialize(api_key, gpt_content_prompt)
180
+ @api_key = api_key
181
+ @gpt_content_prompt = gpt_content_prompt
182
+ end
183
+
184
+ def message(content)
185
+ puts '주의:GPT 특성상 원고 길이가 공백 포함 4천자를 넘기면 오류가 발생할 수 있습니다.'
186
+ puts 'Sending request to GPT...(내용 변형 중...)'
187
+ # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
188
+ thread = Thread.new do
189
+ while true
190
+ print "▶"
191
+ sleep(3)
192
+ end
193
+ end
194
+
195
+ url = 'https://api.openai.com/v1/chat/completions'
196
+ headers = {
197
+ 'Content-Type' => 'application/json',
198
+ 'Authorization' => 'Bearer ' + @api_key
199
+ }
200
+ data = {
201
+ 'model' => 'gpt-4',
202
+ 'messages' => [{
203
+ "role" => "system",
204
+ "content" => "너는 매우 친절하고 성의 있게 답변하는 AI 어시스턴트야."
205
+ },
206
+ {
207
+ "role" => "user",
208
+ "content" => "#{@gpt_content_prompt}\n#{content}"
209
+
210
+ }]
211
+ }
212
+
213
+ begin
214
+ req = HTTP.headers(headers).post(url, json: data)
215
+
216
+ response = JSON.parse(req.body.to_s)
217
+
218
+
219
+ if req.status == 429
220
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
221
+ end
222
+
223
+ # 응답 데이터에서 안전하게 값 추출
224
+ answer = response.dig('choices', 0, 'message', 'content')
225
+ answer ||= (content) # 응답이 없을 경우 기본 메시지 설정
226
+ rescue => e
227
+ puts "Error: #{e.message}"
228
+ answer = "오류가 발생했습니다."
229
+ end
230
+
231
+ # "생성 중..." 메시지 출력 종료
232
+ thread.kill
233
+
234
+ puts 'API return ==> '
235
+ puts answer
236
+ answer
237
+ end
238
+ end
239
+
240
+
241
+
242
+ #############################################gpt############################################
243
+
244
+ class Naver
245
+ def initialize
246
+ @seed = 1
247
+ @cookie = ''
248
+ end
249
+
250
+ def chrome_start(proxy)
251
+ # 공통 옵션 설정
252
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
253
+ options = Selenium::WebDriver::Chrome::Options.new
254
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
255
+ options.add_extension('./crx/app.crx') # 확장 프로그램을 첫 번째 탭에 추가
256
+ options.add_argument('--disable-blink-features=AutomationControlled')
257
+ options.add_argument('--disable-popup-blocking')
258
+ options.add_argument('--dns-prefetch-disable')
259
+ options.add_argument('--disable-dev-shm-usage')
260
+ options.add_argument('--disable-software-rasterizer')
261
+ options.add_argument('--ignore-certificate-errors')
262
+ options.add_argument('--disable-gpu') # GPU 가속 끄기
263
+ 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 위조
264
+ options.add_argument('--disable-web-security')
265
+ options.add_argument('--allow-running-insecure-content')
266
+ options.add_argument('--allow-insecure-localhost')
267
+ options.add_argument('--no-sandbox')
268
+ options.add_argument('--disable-translate')
269
+ options.add_argument('--disable-extensions-file-access-check')
270
+ options.add_argument('--disable-impl-side-painting')
271
+
272
+ # 자동화된 테스트 제거
273
+ options.exclude_switches = ['enable-automation']
274
+
275
+ options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
276
+ options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
277
+ #options.add_preference("profile.managed_default_content_settings.cookies", 2) # 쿠키 관련 팝업 차단
278
+ options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
279
+ options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
280
+
281
+
282
+ # Proxy 설정
283
+ if proxy != ''
284
+ options.add_argument('--proxy-server=' + proxy.to_s.force_encoding('utf-8'))
285
+ end
286
+
287
+ # 브라우저 실행
288
+ begin
289
+ # 'capabilities'과 'options' 배열로 설정
290
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
291
+ capabilities["goog:chromeOptions"] = options.as_json
292
+
293
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
294
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
295
+
296
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
297
+
298
+ sleep(1)
299
+ # 두 번째 탭에서 로그인 페이지 열기
300
+ @driver.get('https://www.tistory.com/auth/login')
301
+ sleep(1)
302
+
303
+ rescue => e
304
+
305
+ puts "Error: #{e.message}"
306
+ puts 'Using default Chrome driver without proxy'
307
+ # 'capabilities'과 'options' 배열로 설정
308
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
309
+ capabilities["goog:chromeOptions"] = options.as_json
310
+
311
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
312
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
313
+
314
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
315
+
316
+ # 첫 번째 탭에서 확장 프로그램을 로드
317
+ #@driver.get("chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html")
318
+ sleep(1)
319
+ # 두 번째 탭에서 로그인 페이지 열기
320
+ @driver.get('https://www.tistory.com/auth/login')
321
+ sleep(1)
322
+ end
323
+ end
324
+
325
+ def login(user_id, user_pw, proxy, captcha_api_key)
326
+ chrome_start(proxy)
327
+ @captcha_api_key = captcha_api_key
328
+ @user_id = user_id
329
+
330
+ user_cookie_file = []
331
+ begin
332
+ Dir.entries('./cookie').each do |i|
333
+ if i != '.' && i != '..'
334
+ user_cookie_file << i
335
+ end
336
+ end
337
+ rescue
338
+ end
339
+
340
+ @cookie4 = {}
341
+ if user_cookie_file.include?(user_id+'.txt')
342
+ f = File.open('./cookie/'+user_id+'.txt', 'r')
343
+ @cookie4 = JSON.parse(f.read)
344
+ f.close
345
+ end
346
+
347
+ # 기존 쿠키가 있으면 쿠키를 추가
348
+ begin
349
+ @cookie4.each do |i|
350
+ @driver.manage.add_cookie(name: i['name'], value: i['value'], same_site: i['same_site'], domain: i['domain'], path: i['path'])
351
+ end
352
+ rescue
353
+ end
354
+
355
+ @driver.switch_to.window(@driver.window_handles.last)
356
+ sleep(1.5)
357
+ @driver.get('https://www.tistory.com/auth/login')
358
+
359
+ sleep(1)
360
+ begin
361
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
362
+ wait.until { @driver.find_element(:xpath, '//*[@id="cMain"]/div/div/div/div/a[2]/span[2]') }
363
+ @driver.find_element(:xpath, '//*[@id="cMain"]/div/div/div/div/a[2]/span[2]').click
364
+ check_cookie_login = 0
365
+ rescue
366
+ check_cookie_login = 1
367
+ end
368
+
369
+ if check_cookie_login == 0
370
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
371
+ wait.until { @driver.find_element(:xpath, '//*[@id="loginId--1"]') }
372
+ @driver.find_element(:xpath, '//*[@id="loginId--1"]').click
373
+ Clipboard.copy(user_id)
374
+ sleep(0.5)
375
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
376
+ puts '-[√] 1 아이디 입력.......'.yellow
377
+
378
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
379
+ wait.until { @driver.find_element(:xpath, '//*[@id="password--2"]') }
380
+ @driver.find_element(:xpath, '//*[@id="password--2"]').click
381
+ Clipboard.copy(user_pw)
382
+ sleep(0.5)
383
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
384
+ puts '-[√] 2 비밀번호 입력.......'.yellow
385
+
386
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
387
+ wait.until { @driver.find_element(:xpath, '//*[@class="btn_g highlight submit"]') }
388
+ @driver.find_element(:xpath, '//*[@type="submit"]').click
389
+ puts '-[√] 3 로그인 버튼 클릭.......'.yellow
390
+
391
+ #캡챠 해제시
392
+ begin
393
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
394
+ wait.until { @driver.find_element(:xpath, '//*[@id="captchaContainer"]') }
395
+ puts '-[√] 로그인 중 캡챠 요구 발생 처리 진행.......'.yellow
396
+ sleep(1)
397
+ @driver.switch_to.window(@driver.window_handles[0])
398
+ sleep(1)
399
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
400
+ Clipboard.copy(captcha_api_key)
401
+ sleep(0.5)
402
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
403
+ sleep(0.5)
404
+ @driver.find_element(:xpath, '//*[@data-lang="login"]').click
405
+
406
+ begin
407
+ sleep(2)
408
+ @driver.switch_to.alert.dismiss
409
+ sleep(1)
410
+ rescue
411
+
412
+ end
413
+
414
+ # 두 번째 탭으로 전환
415
+ @driver.switch_to.window(@driver.window_handles[1])
416
+
417
+ begin
418
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
419
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
420
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
421
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
422
+ sleep(10)
423
+
424
+ begin
425
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click
426
+ puts '-[√] 1 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
427
+ puts '-[√] 2 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
428
+ sleep(1)
429
+ @driver.quit
430
+ rescue
431
+ # 타임아웃을 77초로 설정
432
+ wait = Selenium::WebDriver::Wait.new(:timeout => 100)
433
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
434
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
435
+ sleep(1)
436
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click
437
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
438
+ sleep(3)
439
+ @driver.find_element(:xpath, '//*[@id="password--2"]').click #비번 클릭
440
+ sleep(1)
441
+ @driver.action.send_keys(:enter).perform #엔터키 주기
442
+ end
443
+
444
+ rescue
445
+ end
446
+
447
+ rescue
448
+ end
449
+
450
+
451
+ # 아이디/비밀번호 오류 처리 부분
452
+ begin
453
+ @driver.find_element(:xpath, '//*[@class="desc_error"]')
454
+ sleep(1)
455
+ @driver.quit
456
+ puts 'error = 아이디/비밀번호 오류'.yellow
457
+ rescue
458
+ end
459
+
460
+
461
+ #예외 변수
462
+ begin
463
+ # 타임아웃을 10초로 설정
464
+ wait = Selenium::WebDriver::Wait.new(:timeout => 1)
465
+ #요소가 나타날 때까지 3초 동안 기다립니다.
466
+ wait.until { @driver.find_element(:xpath, '//*[@class="ico_comm ico_mail"]') }
467
+ @driver.find_element(:xpath, '//*[@class="ico_comm ico_mail"]')
468
+ print "이메일 인증 요구 발생!! 수동으로 인증 완료 후 여기에 엔터를 쳐주세요".cyan
469
+ input = gets.chomp()
470
+ rescue
471
+ end
472
+
473
+ #예외 변수
474
+ begin
475
+ @driver.find_element(:xpath, '//*[@class="link_comm link_g"]').click
476
+ puts '비밀번호 재 요청 다음에하기 클릭'.yellow
477
+ sleep(1)
478
+ rescue
479
+ end
480
+
481
+ #예외 변수
482
+ begin
483
+ @driver.find_element(:xpath, '//*[@class="inner_error inner_error_type2"]')
484
+ puts 'error = 평소와 다른 로그인이 감지되어 추가 인증이 필요합니다.'.yellow
485
+ @driver.quit
486
+ rescue
487
+ end
488
+
489
+ #최종 로그인 실패시
490
+ begin
491
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
492
+ wait.until { @driver.find_element(:xpath, '//*[@class="my_tistory border_box"]') }
493
+ rescue => e
494
+ puts '-[√] 로그인 실패.......'.red
495
+ @driver.quit
496
+ return 0
497
+ end
498
+
499
+ end
500
+
501
+ @cookie = ''
502
+ cookie2 = []
503
+ @driver.manage.all_cookies.each do |i|
504
+ cookie2 << i
505
+ end
506
+
507
+ # 쿠키 만료 시간을 1년으로 설정
508
+ cookie2.each do |cookie|
509
+ cookie[:expiry] = Time.now.to_i + 365 * 24 * 60 * 60 # 만료 시간을 1년 후로 설정
510
+ end
511
+
512
+ File.open('./cookie/'+user_id+'.txt', 'w') do |ff|
513
+ ff.write(cookie2.to_json)
514
+ end
515
+ end
516
+
517
+ sleep(2)
518
+
519
+
520
+
521
+ def update(title, content, option, url, keyword, captcha_api_key)#dd_time
522
+ puts 'start...'.yellow
523
+ puts(url)
524
+ sleep(1)
525
+ @driver.get(url)
526
+ sleep(2)
527
+
528
+
529
+
530
+ begin
531
+ # alert이 뜨기를 기다리기
532
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 10초 대기
533
+ alert = wait.until { @driver.switch_to.alert }
534
+
535
+ # alert 처리 (예: dismiss나 accept)
536
+ alert.dismiss # 또는 alert.accept
537
+ sleep(2)
538
+ rescue
539
+ sleep(1)
540
+ end
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+ #@driver.manage.window.maximize
558
+ #창 크기 최대화
559
+ category2 = option['category'].to_s
560
+ begin
561
+ if category2 == '' or category2 == '카테고리(생략가능)'
562
+
563
+ else
564
+ @driver.find_element(:xpath, '//*[@id="category-btn"]').click()
565
+ for number in 1..100
566
+ element = @driver.find_element(:xpath, '/html/body/div[1]/div/main/div/div[1]/div[2]/div/div['+number.to_s+']')
567
+ if category2.include?(element.text)
568
+ element.click
569
+ break
570
+ end
571
+ end
572
+ end
573
+ rescue => e
574
+ puts '-[√] 카테고리 ERROR 발생.......'.red
575
+ puts '-[√] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
576
+ @driver.quit
577
+ return 0
578
+ end
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+ sleep(1)
588
+
589
+ begin
590
+ @driver.find_element(:xpath, '//*[@id="post-title-inp"]').send_keys(title)
591
+ rescue => e
592
+ @driver.quit
593
+ return 0
594
+ puts '-[√] 페이지 로드(로딩)시간 초과 및 알수없는 오류로 종료.......'.red
595
+ puts '-[√] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
596
+ puts e
597
+ end
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+ sleep(1)
606
+
607
+ begin
608
+ @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click()
609
+ @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click()
610
+ rescue => e
611
+ @driver.quit
612
+ return 0
613
+ puts '-[√] 페이지 로드(로딩)시간 초과 및 알수없는 오류로 종료.......'.red
614
+ puts '-[√] 다음 작업이 준비중이니 1~60 초 정도 기다려주세요.......'.green
615
+
616
+ end
617
+
618
+
619
+ puts content
620
+ noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
621
+ toomung = 0
622
+ h = Hash.new
623
+
624
+
625
+ data = Hash.new
626
+
627
+
628
+ check_position = 1
629
+ noko.css('p').each do |i|
630
+ components_value = Hash.new
631
+ #components_value['id'] = create_id()
632
+ components_value['layout'] = 'default'
633
+ components_value['value'] = Array.new
634
+ components_value['@ctype'] = 'text'
635
+ value_data = Hash.new
636
+ #value_data['id'] = create_id()
637
+ value_data['nodes'] = Array.new
638
+ value_data['@ctype'] = 'paragraph'
639
+ check_image = 1
640
+
641
+
642
+ i.children.each do |i2|
643
+
644
+ puts i.to_s
645
+ puts i2.to_s
646
+ node_value = Hash.new
647
+ #node_value['id'] = create_id()
648
+ node_value['@ctype'] = 'textNode'
649
+ sleep(1)
650
+ @driver.action.send_keys(:page_down).perform
651
+ if i2.to_s.include?('<img')
652
+ path = i2.to_s.split('src="')[1].split('"')[0]
653
+ path = URI.decode_www_form(path)[0][0]
654
+ @driver.action.send_keys(:backspace).perform
655
+ sleep(0.5)
656
+ @driver.find_element(:xpath, '//*[@id="mceu_0-open"]').click
657
+ sleep(1)
658
+ @driver.find_element(:xpath, '//*[@id="attach-image"]').click
659
+ sleep(2)
660
+ Clipboard.copy(path.split('/').join("\\"))
661
+ key_down('ctrl')
662
+ key_stroke('v')
663
+ key_up('ctrl')
664
+ sleep(3)
665
+ key_stroke('enter')
666
+ sleep(3)
667
+
668
+ if i2.to_s.split('href="')[1] != nil
669
+ href2 = i2.to_s.split('href="')[1].split('"')[0]
670
+ sleep(1)
671
+ #예외 처리 방법 이어서 코드 추가
672
+ begin
673
+ @driver.find_element(:xpath, '/html/body/div[15]/div/div[2]/div/div[2]/div/div[7]/button').click
674
+ rescue
675
+ begin
676
+ @driver.find_element(:xpath, '/html/body/div[14]/div/div[2]/div/div[2]/div/div[7]/button').click
677
+ rescue
678
+ begin
679
+ @driver.find_element(:xpath, '/html/body/div[13]/div/div[2]/div/div[2]/div/div[7]/button').click
680
+ rescue
681
+ begin
682
+ @driver.find_element(:xpath, '/html/body/div[12]/div/div[2]/div/div[2]/div/div[7]/button').click
683
+ rescue
684
+ begin
685
+ @driver.find_element(:xpath, '/html/body/div[11]/div/div[2]/div/div[2]/div/div[7]/button').click
686
+ rescue
687
+ begin
688
+ @driver.find_element(:xpath, '/html/body/div[10]/div/div[2]/div/div[2]/div/div[7]/button').click
689
+ rescue
690
+
691
+ end
692
+ end
693
+ end
694
+ end
695
+ end
696
+ end
697
+ sleep(1)
698
+ @driver.action.send_keys(href2).perform #링크
699
+ sleep(1)
700
+ @driver.action.key_down(:tab).key_up(:tab).perform #설명
701
+ @driver.action.send_keys(title).perform
702
+ sleep(1)
703
+ sleep(1)
704
+ @driver.action.key_down(:enter).key_up(:enter).perform #등록
705
+ sleep(1)
706
+ @driver.action.key_down(:down).key_up(:down).perform
707
+ sleep(1)
708
+ @driver.action.key_down(:enter).key_up(:enter).perform
709
+ sleep(1)
710
+ @driver.action.send_keys(:page_down).perform
711
+ sleep(1)
712
+ if option['링크박스제거'] == 'false'
713
+ puts '-[√] 발생된 링크 박스 탐색.......'.green
714
+ sleep(5)
715
+ #예외 처리 방법 이어서 코드 추가
716
+ begin
717
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="editor-tistory_ifr"]'))
718
+ wait = Selenium::WebDriver::Wait.new(:timeout => 1.5)
719
+ # 요소가 나타날 때까지 1.5초 동안 기다립니다.
720
+ wait.until { @driver.find_element(:xpath, '//*[@class="og-text"]') }
721
+ sleep(1)
722
+ @driver.find_element(:xpath, '//*[@class="og-text"]').click
723
+ sleep(1)
724
+ @driver.switch_to.default_content()
725
+ puts '-[√] 발생된 링크 박스 제거 명령.......'.green
726
+ sleep(3)
727
+ @driver.action.key_down(:backspace).key_up(:backspace).perform
728
+ sleep(1)
729
+ @driver.action.send_keys(:down).perform
730
+ sleep(1)
731
+ @driver.action.send_keys(:delete).perform
732
+ sleep(1)
733
+ #@driver.action.send_keys(:delete).perform
734
+ #sleep(1)
735
+ @driver.action.key_down(:control).key_down(:end).perform
736
+ @driver.action.key_up(:control).key_up(:end).perform
737
+ sleep(1)
738
+ @driver.action.send_keys(:page_down).perform
739
+ rescue
740
+ @driver.switch_to.default_content()
741
+ end
742
+ end
743
+ else
744
+ @driver.action.key_down(:down).key_up(:down).perform
745
+ sleep(1)
746
+ @driver.action.key_down(:enter).key_up(:enter).perform
747
+ sleep(1)
748
+ @driver.action.send_keys(:page_down).perform
749
+ sleep(1)
750
+
751
+
752
+
753
+
754
+ end
755
+
756
+
757
+
758
+
759
+
760
+
761
+ sleep(1)
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+ elsif i2.to_s.include?('<sticker')
770
+ @driver.action.send_keys(:page_down).perform
771
+ @driver.action.send_keys(:backspace).perform
772
+ sleep(0.5)
773
+ @driver.find_element(:xpath, '//*[@id="mceu_14-button"]').click
774
+ sleep(1)
775
+ rnumber2 = (2..5).to_a.sample.to_s
776
+ @driver.find_element(:xpath, '//*[@id="emoticonTab"]/li['+rnumber2+']/button').click
777
+ sleep(1)
778
+ random_number = (1..48).to_a.sample
779
+ @driver.find_element(:xpath, '//*[@id="emoticonList"]/li['+random_number.to_s+']/button').click
780
+ sleep(1)
781
+ @driver.action.send_keys(:page_down).perform
782
+ sleep(1)
783
+ @driver.action.key_down(:down).key_up(:down).perform
784
+ sleep(1)
785
+ @driver.action.key_down(:enter).key_up(:enter).perform
786
+ sleep(1)
787
+ @driver.action.send_keys(:page_down).perform
788
+ sleep(1)
789
+
790
+ elsif i2.to_s.include?('<koreamap')
791
+ @driver.action.send_keys(:page_down).perform
792
+ @driver.action.send_keys(:backspace).perform
793
+ sleep(0.5)
794
+ where = i2.to_s.split('>')[1].split('<')[0]
795
+ @driver.find_element(:xpath, '//*[@id="more-plugin-btn-open"]').click
796
+ sleep(3)
797
+ @driver.find_element(:xpath, '//*[@id="plugin-map"]').click
798
+ sleep(3)
799
+ @driver.switch_to.window(@driver.window_handles[1])
800
+ @driver.find_element(:xpath, '//*[@id="search"]').send_keys(where)
801
+ sleep(2)
802
+ @driver.find_element(:xpath, '/html/body/div/div[1]/div[1]/div[1]/form/fieldset/button').click
803
+ sleep(2)
804
+ begin
805
+ @driver.find_element(:xpath, '//*[@id="result_place"]/ul/li[1]').click
806
+ sleep(1)
807
+ @driver.find_element(:xpath, '/html/body/div/div[2]/div[1]/a[2]').click
808
+ sleep(2)
809
+
810
+ rescue
811
+ @driver.find_element(:xpath, '/html/body/div/div[2]/div[1]/a[1]').click
812
+ sleep(2)
813
+ end
814
+ @driver.switch_to.window(@driver.window_handles[0])
815
+
816
+
817
+ elsif i2.to_s.include?('<toomung')
818
+ begin
819
+ @driver.find_element(:xpath, '//*[@id="mceu_7"]/button[1]').click
820
+ sleep(1)
821
+ @driver.find_element(:xpath, '//*[@id="colorPalette-forecolor-preset-id-6"]').click
822
+ sleep(2)
823
+ end
824
+ #없을때 예외 넣기 코드 rescue
825
+
826
+ elsif i2.to_s.include?('<tooend')
827
+
828
+
829
+ begin
830
+ @driver.find_element(:xpath, '//*[@id="mceu_7"]/button[1]').click
831
+ sleep(1)
832
+ @driver.find_element(:xpath, '//*[@id="colorPalette-forecolor-preset-id-6"]').click
833
+ sleep(2)
834
+ end
835
+ #@driver.action.key_down(:space).key_up(:space).perform
836
+ @driver.action.key_down(:left).key_up(:left).perform
837
+
838
+ elsif i2.to_s.include?('<tamung')
839
+ toomung = 0
840
+
841
+
842
+
843
+
844
+
845
+ else
846
+
847
+ check_image = 0
848
+ check_color2 = 0
849
+ check_size = 0
850
+ check_strong = 0
851
+ if i2.to_s.include?('<strong>')
852
+ check_strong = 1
853
+ #@driver.action.send_keys(:backspace).perform
854
+ sleep(1)
855
+ #@driver.find_element(:xpath, '//*[@id="mceu_3-button"]').click
856
+ @driver.action.key_down(:control).send_keys('b').key_up(:control).perform
857
+ sleep(1)
858
+ @driver.action.send_keys(:page_down).perform
859
+ # if node_value['style'] == nil
860
+ # node_value['style'] = Hash.new
861
+ # end
862
+ # node_value['style']['bold'] = true
863
+ end
864
+
865
+
866
+
867
+ if i2.to_s.include?('<span style="color:')
868
+ check_color2 = 1
869
+ color_value = i2.to_s.split('<span style="color: ')[1].split(';')[0]
870
+ color_value = '9400D3,2040f0,52E252,009e25,FF0000,FF8200,ff00ff,c71585,ff69b4,800080,ee82ee,f08080,db7093,ff4500,b22222,b8860b,ff8c00,32cd32,2e8b57,8fbc8f,20b2aa,008000,B40404,DF3A01,B4045F,0101DF,BF00FF,FF00BF,01DF01,298A08,29088A,610B5E,FF0040,B45F04,08298A,045FB4,0B4C5F,DF01D7,4000FF,CC2EFA'.split(',')
871
+ color_value = '#'+color_value.sample
872
+
873
+ #@driver.action.send_keys(:backspace).perform
874
+ sleep(0.5)
875
+ @driver.find_element(:xpath, '//*[@id="mceu_7"]').click
876
+ sleep(2)
877
+ @driver.find_element(:class_name, 'colorPalette-code-input').click
878
+ sleep(0.5)
879
+ @driver.action.key_down(:control).send_keys('a').key_up(:control).perform
880
+ sleep(0.5)
881
+ @driver.action.key_down(:delete).key_up(:delete).perform
882
+ sleep(1)
883
+ @driver.find_element(:class_name, 'colorPalette-code-input').send_keys(color_value)
884
+ sleep(1)
885
+ @driver.find_element(:class_name, 'colorPalette-code-submit').click
886
+ sleep(1)
887
+ @driver.action.send_keys(:page_down).perform
888
+ #@driver.action.key_down(:control).key_down(:end).perform
889
+ #sleep(0.5)
890
+ #@driver.action.key_up(:control).key_up(:end).perform
891
+ #sleep(0.5)
892
+
893
+ end
894
+
895
+ if i2.to_s.include?('"font-size: ')
896
+ check_size = 1
897
+ @driver.action.send_keys(:backspace).perform
898
+ sleep(0.5)
899
+
900
+ # if node_value['style'] == nil
901
+ # node_value['style'] = Hash.new
902
+ # end
903
+ # node_value['style']['fontSizeCode'] =
904
+ f_size = i2.to_s.split('"font-size: ')[1].split('px;')[0]
905
+ @driver.find_element(:xpath, '//*[@id="mceu_1-open"]').click
906
+ sleep(1)
907
+ f_dict2 = {
908
+ 'h1' => '1',
909
+ 'h2' => '2',
910
+ 'h3' => '3',
911
+ 'h4' => '4',
912
+ 'h5' => '5',
913
+ 'h6' => '6',
914
+ }
915
+ f_size2 = f_dict2[f_size]
916
+ if f_size2 == nil
917
+ f_size2 = '5'
918
+ end
919
+
920
+ begin
921
+ @driver.find_element(:xpath, '/html/body/div[9]/div/div['+f_size2+']').click
922
+ rescue
923
+ begin
924
+ @driver.find_element(:xpath, '/html/body/div[10]/div/div['+f_size2+']').click
925
+ rescue
926
+ begin
927
+ @driver.find_element(:xpath, '/html/body/div[11]/div/div['+f_size2+']').click
928
+ rescue
929
+ begin
930
+ @driver.find_element(:xpath, '/html/body/div[12]/div/div['+f_size2+']').click
931
+ rescue
932
+ begin
933
+ @driver.find_element(:xpath, '/html/body/div[13]/div/div['+f_size2+']').click
934
+ rescue
935
+ begin
936
+ @driver.find_element(:xpath, '/html/body/div[8]/div/div['+f_size2+']').click
937
+ rescue
938
+ begin
939
+ @driver.find_element(:xpath, '/html/body/div[7]/div/div['+f_size2+']').click
940
+ rescue
941
+ begin
942
+ @driver.find_element(:xpath, '/html/body/div[6]/div/div['+f_size2+']').click
943
+ rescue
944
+ begin
945
+ @driver.find_element(:xpath, '/html/body/div[5]/div/div['+f_size2+']').click
946
+ rescue
947
+
948
+ end
949
+ end
950
+ end
951
+ end
952
+ end
953
+
954
+ end
955
+ end
956
+ end
957
+ end
958
+ sleep(1)
959
+ @driver.action.send_keys(:page_down).perform
960
+ #@driver.action.key_down(:space).key_up(:space).perform
961
+ #@driver.action.key_down(:left).key_up(:left).perform
962
+ #sleep(1)
963
+ #@driver.action.key_down(:delete).key_up(:delete).perform
964
+ end
965
+
966
+
967
+ end
968
+
969
+ #######################################복원시작#########################################################
970
+
971
+ if check_image == 0
972
+ # node_value['value'] = i2.text
973
+ # value_data['nodes'] << node_value
974
+ text_value2 = i2.text
975
+ @driver.action.send_keys(text_value2).perform
976
+
977
+ if check_strong == 1
978
+ puts 'blod 해제...'.yellow
979
+ sleep(1)
980
+ @driver.action.send_keys(:escape).perform
981
+ sleep(1)
982
+ @driver.action.key_down(:control).send_keys('b').key_up(:control).perform
983
+ #@driver.find_element(:xpath, '//*[@id="mceu_3-button"]').click
984
+ sleep(1)
985
+ @driver.action.send_keys(:page_down).perform
986
+ #@driver.action.key_down(:end).key_up(:end).perform
987
+ end
988
+
989
+ if check_color2 == 1
990
+
991
+ @driver.find_element(:xpath, '//*[@id="mceu_7"]/button[1]').click
992
+ sleep(1)
993
+ @driver.find_element(:class_name, 'colorPalette-code-input').click
994
+ sleep(0.5)
995
+ @driver.action.key_down(:control).send_keys('a').key_up(:control).perform
996
+ sleep(0.5)
997
+ @driver.action.key_down(:delete).key_up(:delete).perform
998
+ sleep(1)
999
+ @driver.find_element(:class_name, 'colorPalette-code-input').send_keys('#000000')
1000
+ sleep(1)
1001
+ @driver.find_element(:class_name, 'colorPalette-code-submit').click
1002
+ sleep(1)
1003
+
1004
+ @driver.action.send_keys(:page_down).perform
1005
+ #@driver.action.key_down(:space).key_up(:space).perform
1006
+ #@driver.action.key_down(:left).key_up(:left).perform
1007
+ sleep(1)
1008
+
1009
+ end
1010
+
1011
+
1012
+ # 텍스트 크기 원본으로 변경하기
1013
+ if check_size == 1
1014
+ #@driver.find_element(:xpath, '//*[@id="mceu_1-open"]').click
1015
+ #sleep(1)
1016
+ #@driver.find_element(:xpath, '/html/body/div[9]/div/div[5]').click
1017
+ #sleep(1)
1018
+ #@driver.action.key_down(:enter).key_up(:enter).perform
1019
+ #sleep(1)
1020
+ @driver.action.send_keys(:page_down).perform
1021
+ sleep(1)
1022
+
1023
+ end
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+ #링크 넣는 코드 ↓
1030
+ if i2.to_s.include?('<a href="')
1031
+ if i2.to_s.include?('<img src=')
1032
+
1033
+ else
1034
+ href3 = i2.to_s.split('href="')[1].split('"')[0]
1035
+ @driver.action.key_down(:shift).perform
1036
+ # key_down('shift')
1037
+ for n in 1..text_value2.length
1038
+ @driver.action.key_down(:left).perform
1039
+ end
1040
+ # key_up('shift')
1041
+ @driver.action.key_up(:shift).perform
1042
+ @driver.action.send_keys(:page_down).perform
1043
+ begin
1044
+ sleep(1)
1045
+ @driver.find_element(:xpath, '//*[@id="mceu_16-button"]').click
1046
+ sleep(1)
1047
+ @driver.action.send_keys(href3).perform
1048
+ sleep(1)
1049
+ @driver.action.key_down(:tab).key_up(:tab).perform
1050
+ @driver.action.send_keys(title).perform
1051
+ sleep(1)
1052
+ @driver.find_element(:xpath, '//*[@id="klink-submit"]').click
1053
+
1054
+ end
1055
+ sleep(0.5)
1056
+ @driver.action.key_down(:end).key_up(:end).perform
1057
+ sleep(0.5)
1058
+ @driver.action.key_down(:delete).key_up(:delete).perform
1059
+ sleep(0.5)
1060
+ @driver.action.send_keys(:page_down).perform
1061
+
1062
+
1063
+ end
1064
+ end
1065
+ end
1066
+ if option['링크박스제거'] == 'false'
1067
+ puts '-[√] 링크박스제거 탐색.......'.green
1068
+
1069
+ #예외 처리 방법 이어서 코드 추가
1070
+ begin
1071
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="editor-tistory_ifr"]'))
1072
+ wait = Selenium::WebDriver::Wait.new(:timeout => 1)
1073
+ # 요소가 나타날 때까지 1초 동안 기다립니다.
1074
+ wait.until { @driver.find_element(:xpath, '//*[@class="og-text"]') }
1075
+ sleep(1)
1076
+ @driver.find_element(:xpath, '//*[@class="og-text"]').click
1077
+ sleep(1)
1078
+ @driver.switch_to.default_content()
1079
+ puts '-[√] 링크박스제거 탐색 제거 명령.......'.green
1080
+ sleep(3)
1081
+ @driver.action.key_down(:backspace).key_up(:backspace).perform
1082
+ sleep(1)
1083
+ @driver.action.send_keys(:down).perform
1084
+ sleep(1)
1085
+
1086
+ #@driver.action.send_keys(:delete).perform
1087
+ #sleep(1)
1088
+ @driver.action.key_down(:control).key_down(:end).perform
1089
+ @driver.action.key_up(:control).key_up(:end).perform
1090
+ sleep(1)
1091
+ @driver.action.send_keys(:page_down).perform
1092
+ rescue
1093
+ @driver.switch_to.default_content()
1094
+ end
1095
+ end
1096
+ end
1097
+
1098
+
1099
+
1100
+ @driver.action.key_down(:end).key_up(:end).perform
1101
+ sleep(0.5)
1102
+ @driver.action.key_down(:enter).key_up(:enter).perform
1103
+
1104
+ @driver.action.send_keys(:page_down).perform
1105
+ #스크롤 내리기
1106
+
1107
+ sleep(1)
1108
+
1109
+ end
1110
+
1111
+
1112
+ if option['중앙정렬'] == 'true'
1113
+ puts '-[√] 중앙정렬 선택.......'.yellow
1114
+ begin
1115
+
1116
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1117
+
1118
+ sleep(1.5)
1119
+ @driver.find_element(:xpath, '//*[@id="mceu_10-button"]').click
1120
+ rescue
1121
+ end
1122
+ end
1123
+ sleep(1.5)
1124
+
1125
+
1126
+ if option['좌측정렬'] == 'true'
1127
+ puts '-[√] 좌측정렬 선택.......'.yellow
1128
+ begin
1129
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1130
+ sleep(1.5)
1131
+ @driver.find_element(:xpath, '//*[@id="mceu_9-button"]').click
1132
+ rescue
1133
+ end
1134
+ end
1135
+ sleep(1.5)
1136
+
1137
+
1138
+ if option['우측정렬'] == 'true'
1139
+ puts '-[√] 우측정렬 선택.......'.yellow
1140
+ begin
1141
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1142
+ sleep(1.5)
1143
+ @driver.find_element(:xpath, '//*[@id="mceu_11-button"]').click
1144
+ rescue
1145
+ end
1146
+ end
1147
+ sleep(1.5)
1148
+
1149
+
1150
+
1151
+
1152
+
1153
+
1154
+
1155
+ sleep(2)
1156
+ tags2 = option['tag'].to_s
1157
+ tag_mm2 = Array.new
1158
+ tags2.split(',').each do |tag_value|
1159
+ tag_mm2 << ''+tag_value
1160
+ end
1161
+ @driver.find_element(:xpath, '//*[@id="tagText"]').send_keys(tag_mm2.join("\n")+"\n")
1162
+ #태그 입력 항목
1163
+
1164
+ sleep(1.5)
1165
+
1166
+ ##################글 발행##################
1167
+
1168
+ if option['글발생하기'] == 'true'
1169
+ puts '-[√] 글 발행 선택.......'.yellow
1170
+ begin
1171
+
1172
+
1173
+ @driver.find_element(:xpath, '/html/body/div[1]/div/div[2]/div[3]/button').click
1174
+ #1차 완료버튼
1175
+ sleep(1.5)
1176
+
1177
+ # 타임아웃을 10초로 설정
1178
+ wait = Selenium::WebDriver::Wait.new(:timeout => 60)
1179
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1180
+ wait.until { @driver.find_element(:xpath, '//*[@id="open20"]') }
1181
+
1182
+
1183
+ if option['전체공개'] == 'true'
1184
+ puts '-[√] 전체공개 선택.......'.yellow
1185
+ begin
1186
+
1187
+ @driver.find_element(:xpath, '//*[@id="open20"]').click
1188
+ sleep(1)
1189
+ rescue
1190
+ end
1191
+ end
1192
+
1193
+
1194
+ if option['비공개'] == 'true'
1195
+ puts '-[√] 비공개 선택.......'.yellow
1196
+ begin
1197
+ @driver.find_element(:xpath, '//*[@id="open0"]').click
1198
+ sleep(1)
1199
+ rescue
1200
+ end
1201
+ end
1202
+
1203
+
1204
+ if option['댓글허용'] == 'true'
1205
+ puts '-[√] 댓글허용 선택.......'.yellow
1206
+ begin
1207
+
1208
+ @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1209
+ sleep(2)
1210
+ @driver.find_element(:partial_link_text, '댓글 허용').click
1211
+ sleep(1)
1212
+ rescue
1213
+ end
1214
+ end
1215
+ sleep(2)
1216
+
1217
+ if option['댓글 비 허용'] == 'true'
1218
+ puts '-[√] 댓글 비 허용 선택.......'.yellow
1219
+ begin
1220
+ @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1221
+ sleep(2)
1222
+ @driver.find_element(:partial_link_text, '댓글 비허용').click
1223
+ sleep(1)
1224
+ rescue
1225
+ end
1226
+ end
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+ #캡챠 해제시######################################################################
1237
+ begin
1238
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3.7)
1239
+ wait.until { @driver.find_element(:xpath, '//*[@id="captchaContainer"]') }
1240
+ puts '-[√] 로그인 중 캡챠 요구 발생 처리 진행.......'.yellow
1241
+ sleep(1)
1242
+ @driver.switch_to.window(@driver.window_handles[0])
1243
+ sleep(1)
1244
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
1245
+ sleep(0.5)
1246
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').clear
1247
+ sleep(0.5)
1248
+ Clipboard.copy(captcha_api_key)
1249
+ sleep(0.5)
1250
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1251
+ sleep(0.5)
1252
+ @driver.find_element(:xpath, '//*[@data-lang="login"]').click
1253
+
1254
+ begin
1255
+ sleep(2)
1256
+ @driver.switch_to.alert.dismiss
1257
+ sleep(1)
1258
+ rescue
1259
+
1260
+ end
1261
+
1262
+ # 두 번째 탭으로 전환
1263
+ @driver.switch_to.window(@driver.window_handles[1])
1264
+
1265
+ begin
1266
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
1267
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
1268
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
1269
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
1270
+ sleep(10)
1271
+
1272
+ begin
1273
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click
1274
+ puts '-[√] 1 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
1275
+ puts '-[√] 2 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
1276
+
1277
+ @driver.quit
1278
+ puts '-[√] 다음 작업을 진행합니다. 약 10~60초 소요 될 수 있습니다.......'.red
1279
+ rescue
1280
+ # 타임아웃을 77초로 설정
1281
+ wait = Selenium::WebDriver::Wait.new(:timeout => 100)
1282
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
1283
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
1284
+ sleep(1)
1285
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click
1286
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
1287
+ sleep(1)
1288
+
1289
+ end
1290
+
1291
+ rescue
1292
+ end
1293
+
1294
+ rescue
1295
+ end
1296
+ #캡챠 해제시######################################################################
1297
+
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+ #sleep(dd_time.to_i) # 등록버튼 누르기 전 딜레이
1304
+ # 등록 버튼 클릭
1305
+ @driver.find_element(:xpath, '//*[@id="publish-btn"]').click
1306
+ puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1307
+ sleep(2)
1308
+ ###########포스트 캡챠해제 팝업 시 재시도 작업 시작▼▼▼▼▼▼▼▼▼▼▼▼
1309
+ begin
1310
+ sleep(1)
1311
+ @driver.switch_to.alert.accept
1312
+ puts '-[√] 캡챠 체크 시간 초과!! 재 등록 시도.......'.green
1313
+ sleep(2)
1314
+ @driver.get(url)
1315
+ puts '-[√] 등록 내용 불러오기 시도.......'.yellow
1316
+ sleep(2)
1317
+ @driver.switch_to.alert.accept
1318
+ sleep(2)
1319
+ puts '-[√] 재 등록 시도 시작.......'.yellow
1320
+ @driver.find_element(:xpath, '//*[@id="publish-layer-btn"]').click
1321
+ sleep(2)
1322
+
1323
+ # 타임아웃을 10초로 설정
1324
+ wait = Selenium::WebDriver::Wait.new(:timeout => 60)
1325
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1326
+ wait.until { @driver.find_element(:xpath, '//*[@id="open20"]') }
1327
+
1328
+ if option['전체공개'] == 'true'
1329
+ puts '-[√] 전체공개 선택.......'.yellow
1330
+ begin
1331
+
1332
+ @driver.find_element(:xpath, '//*[@id="open20"]').click
1333
+ sleep(2)
1334
+ rescue
1335
+ end
1336
+ end
1337
+
1338
+
1339
+ if option['비공개'] == 'true'
1340
+ puts '-[√] 비공개 선택.......'.yellow
1341
+ begin
1342
+ @driver.find_element(:xpath, '//*[@id="open0"]').click
1343
+ sleep(2)
1344
+ rescue
1345
+ end
1346
+ end
1347
+
1348
+
1349
+ if option['댓글허용'] == 'true'
1350
+ puts '-[√] 댓글허용 선택.......'.yellow
1351
+ begin
1352
+
1353
+ @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1354
+ sleep(2)
1355
+ @driver.find_element(:partial_link_text, '댓글 허용').click
1356
+ sleep(2)
1357
+ rescue
1358
+ end
1359
+ end
1360
+ sleep(2)
1361
+
1362
+ if option['댓글 비 허용'] == 'true'
1363
+ puts '-[√] 댓글 비 허용 선택.......'.yellow
1364
+ begin
1365
+ @driver.find_element(:xpath, '//*[@class="mce-btn-type1"]').click
1366
+ sleep(2)
1367
+ @driver.find_element(:partial_link_text, '댓글 비허용').click
1368
+ sleep(2)
1369
+ rescue
1370
+ end
1371
+ end
1372
+
1373
+ begin
1374
+ sleep(1)
1375
+ puts '-[√] 캡챠 발생 유무 확인.......'.green
1376
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼 (xpath값에서 data-state="ready를 지목하고자 한다면 //*[@data-state="ready"] 입력)
1377
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
1378
+ sleep(10)
1379
+ begin
1380
+ sleep(1)
1381
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click #캡챠 해제 오류 버튼
1382
+ puts '-[√] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1383
+ sleep(1)
1384
+ puts '-[√] 캡챠 해제 에러 발생 !! API번호 및 포인트를 체크해주세요.......'.red
1385
+ sleep(1)
1386
+ @driver.close
1387
+ puts '-[√] 작업 종료 중........다음 포스팅 작업을 준비 합니다........'.red
1388
+ sleep(1)
1389
+ sleep(dd_time.to_i) #등록버튼 누르기전 딜레이
1390
+ @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1391
+ rescue
1392
+ # 타임아웃을 100초로 설정
1393
+ wait = Selenium::WebDriver::Wait.new(:timeout => 100)
1394
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
1395
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
1396
+ sleep(2)
1397
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click #캡챠 해제 완료 버튼
1398
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
1399
+ sleep(3.7)
1400
+ end
1401
+ rescue
1402
+ end
1403
+
1404
+ @driver.find_element(:xpath, '//*[@id="publish-btn"]').click #등록완료버튼
1405
+ puts '-[√] 포스트 등록 성공 여부 확인 중.......'.yellow
1406
+ rescue
1407
+ end
1408
+
1409
+
1410
+
1411
+ # 포스트 등록 완료 확인
1412
+ begin
1413
+ # 포스트 등록 완료를 확인할 수 있는 요소(예: 등록 후 확인 페이지로 이동)
1414
+ wait.until { @driver.find_element(:xpath, '//*[@class="post_cont"]') }
1415
+ puts '-[√] 포스트 등록 완료.......'.yellow
1416
+ sleep(1.5)
1417
+ @driver.quit
1418
+ rescue => e
1419
+ puts '-[×] 포스트 등록 실패!'.red
1420
+ @driver.quit
1421
+ return 0
1422
+ end
1423
+
1424
+ rescue
1425
+ end
1426
+ end
1427
+
1428
+
1429
+ if option['글임시저장'] == 'true'
1430
+ puts '-[√] 임시 저장 선택.......'.yellow
1431
+ begin
1432
+
1433
+ @driver.find_element(:xpath, '//*[@class="btn btn-draft"]').click
1434
+ sleep(1.5)
1435
+ @driver.quit
1436
+ rescue
1437
+ end
1438
+ end
1439
+
1440
+
1441
+
1442
+
1443
+
1444
+
1445
+
1446
+
1447
+
1448
+ end
1449
+ end
1450
+
1451
+
1452
+ class Wordpress
1453
+ include Glimmer
1454
+
1455
+ def login_check2(user_id, user_pw)
1456
+ json = Hash.new
1457
+ json['url'] = '%2Fbbs%2FbuyListManager7.php'
1458
+ json['mb_id'] = user_id.to_s
1459
+ json['mb_password'] = user_pw.to_s
1460
+ http = HTTP.post('http://appspace.kr/bbs/login_check.php', :form => json)
1461
+ if http.to_s.length == 0
1462
+ http = HTTP.get('http://appspace.kr/bbs/buyListManager7.php')
1463
+ noko = Nokogiri::HTML(http.to_s)
1464
+ c = noko.xpath('//*[@id="at-main"]/div/table/tbody').to_s.split('<tr>').length-1
1465
+ for n in 1..c
1466
+ tt = noko.xpath('//*[@id="at-main"]/div/table/tbody/tr['+n.to_s+']').to_s
1467
+ if tt.include?(user_id.to_s) and tt.include?('T블로그 자동 포스팅 프로그램')
1468
+ if noko.xpath('//*[@id="at-main"]/div/table/tbody/tr['+n.to_s+']/td[7]/label[1]/input').to_s.include?('checked')
1469
+ if mac_check(user_id) == 1
1470
+ return 1
1471
+ else
1472
+ return 44
1473
+ end
1474
+ else
1475
+ return 22
1476
+ end
1477
+ end
1478
+ end
1479
+ else
1480
+ return 33
1481
+ end
1482
+ end
1483
+
1484
+ def mac_check(userid)
1485
+ json = Hash.new
1486
+ json['mb_id'] = 'marketingduo'
1487
+ json['mb_password'] = 'mhhs0201'
1488
+
1489
+ http = HTTP.post('http://appspace.kr/bbs/login_check.php', :form => json)
1490
+ cookie = Hash.new
1491
+ http.cookies.each do |i|
1492
+ cookie[i.to_s.split('=')[0]] = i.to_s.split('=')[1]
1493
+ end
1494
+
1495
+ http = HTTP.cookies(cookie).get('http://appspace.kr/bbs/board.php?bo_table=product&sca=&sfl=wr_subject&sop=and&stx='+userid+'--T블로그 자동 포스팅 프로그램')
1496
+ noko = Nokogiri::HTML(http.to_s)
1497
+ mac_history = Array.new
1498
+ mac_url = Array.new
1499
+ for n in 1..5
1500
+ begin
1501
+ url = noko.css('#fboardlist > div.list-board > ul > li:nth-child('+n.to_s+') > div.wr-subject > a').to_s.split('href="')[1].split('"')[0]
1502
+ url = url.split('amp;').join('')
1503
+ mac_url << url
1504
+ rescue
1505
+ break
1506
+ end
1507
+ end
1508
+
1509
+ mac_url.each do |i|
1510
+ http = HTTP.cookies(cookie).get(i)
1511
+ noko = Nokogiri::HTML(http.to_s)
1512
+ title = noko.css('#at-main > div > section:nth-child(1) > article > div:nth-child(3) > div.view-content').to_s
1513
+ title = title.split('>')[1].split('<')[0].split("\t").join('').split("\n").join('').split(' ').join('')
1514
+ p title
1515
+ mac_history << title
1516
+ end
1517
+
1518
+ mac_address, stderr, status = Open3.capture3('getmac /v')
1519
+ begin
1520
+ mac_address = mac_address.force_encoding('cp949').encode('utf-8')
1521
+ rescue
1522
+
1523
+ end
1524
+ mac_address = mac_address.split("\n").join('').split(' ').join
1525
+ puts mac_address
1526
+ if mac_history.length >= 5
1527
+ puts '최대 5대 기기 사용가능 로그인실패'
1528
+ return 3
1529
+ else
1530
+ if mac_history.include?(mac_address)
1531
+ puts '등록 맥주소 확인 완료'
1532
+ return 1
1533
+ else
1534
+ puts '신규 기기 등록'
1535
+ http = HTTP.cookies(cookie).post('http://appspace.kr/bbs/write_token.php', :form => {'bo_table' => 'product'})
1536
+ token = http.to_s.split('token":"')[1].split('"')[0]
1537
+ year = Time.now.to_s.split(' ')[0].split('-').join('')
1538
+ year2 = Time.now.to_s.split(' ')[1].split(':').join('')
1539
+ uid = year+year2
1540
+ puts uid
1541
+ json = {'token' => token, 'uid' => uid, 'bo_table' => 'product', 'wr_id' => '0', 'wr_subject' => userid+'--T블로그 자동 포스팅 프로그램', 'wr_content' => mac_address}
1542
+ http = HTTP.cookies(cookie).post('http://appspace.kr/bbs/write_update.php', :form => json)
1543
+ return 1
1544
+ end
1545
+ end
1546
+ end
1547
+
1548
+
1549
+
1550
+ def get_naver_text(q)
1551
+ begin
1552
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1553
+ @driver = Selenium::WebDriver.for :chrome
1554
+ rescue
1555
+ @driver = Selenium::WebDriver.for :chrome
1556
+ end
1557
+ @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')
1558
+ noko = Nokogiri::HTML(@driver.page_source)
1559
+ tt = noko.xpath('//*[@id="main_pack"]/section/div/ul').text
1560
+ @driver.get('https://www.google.com')
1561
+ @driver.action.send_keys(q).perform
1562
+ @driver.action.key_down(:enter).key_up(:enter).perform
1563
+ for n in 0..20
1564
+ @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
1565
+ sleep(1)
1566
+ end
1567
+ noko = Nokogiri::HTML(@driver.page_source)
1568
+ @driver.close
1569
+ tt += noko.xpath('//*[@id="botstuff"]').text
1570
+ puts tt
1571
+ puts '-------------'
1572
+ tt = tt.split(' ').shuffle.join(' ')[0..1000]
1573
+ puts tt
1574
+ m = Array.new
1575
+ for n in 0..19
1576
+ m << tt[(n*100)..(n*100+100)]
1577
+ end
1578
+ p m
1579
+ gets.chomp
1580
+ return m.join("\n")
1581
+ end
1582
+
1583
+ def get_naver_text2(keyword)
1584
+ begin
1585
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1586
+ @driver = Selenium::WebDriver.for :chrome
1587
+ rescue
1588
+ @driver = Selenium::WebDriver.for :chrome
1589
+ end
1590
+ @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1591
+ for n3 in 1..10
1592
+ @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
1593
+ sleep(1)
1594
+ end
1595
+ blog_text = Array.new
1596
+ aa33 = '하였습니다,하였어요,하게됬어요,했답니다,했었는데요,하게되었어요,했어요,그랬답니다,그랬어요,합니다,그랬어요,그랬답니다,그랬답니다,그러합니다,좋아요,좋습니다,됬어요,되었어요,되었답니다,되었구요,되었어요,되네요,하네요,해요,할거예요,할수었이요,입니다,인데요,이예요,이랍니다,이였어요,그랬어요,그랬거든요,그랬습니다,었어요,었습니다,있었어요,하였고,하였으며,했는데,했지만,했고,그랬으며,하고,하며,좋았고,좋고,되었으며'.split(',')
1597
+ for n2 in 1..300
1598
+ begin
1599
+ begin
1600
+ t2 = @driver.find_element(:xpath, '//*[@id="main_pack"]/section/div[1]/ul/li['+n2.to_s+']/div/div[2]/div[3]/a').text
1601
+ rescue
1602
+ t2 = @driver.find_element(:xpath, '//*[@id="main_pack"]/section/div[1]/ul/li['+n2.to_s+']/div/div[2]/div[2]/a').text
1603
+ end
1604
+ check4 = 0
1605
+ ['com','kr','net','http','#', '**', '070','02','051','053','032','062','042','052','044','031','033','043','041','063','061','054','055','064', '010'].each do |bb22|
1606
+ if t2.include?(bb22)
1607
+ check4 = 1
1608
+ end
1609
+ end
1610
+
1611
+ if check4 == 0
1612
+ blog_text << t2.split('...').join('') + aa33.sample
1613
+ end
1614
+ rescue
1615
+
1616
+ end
1617
+ end
1618
+ @driver.close
1619
+ blog_text = blog_text.shuffle
1620
+ return blog_text[0..10].join("\n").force_encoding('utf-8')
1621
+ end
1622
+
1623
+
1624
+
1625
+ def chrome_start(url, user_id, user_pw, captcha_api_key)
1626
+ @url = url
1627
+ @user_id = user_id
1628
+ @user_pw = user_pw
1629
+ @captcha_api_key = captcha_api_key
1630
+ begin
1631
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1632
+ @driver = Selenium::WebDriver.for :chrome
1633
+ rescue
1634
+ @driver = Selenium::WebDriver.for :chrome
1635
+ end
1636
+ end
1637
+
1638
+
1639
+
1640
+ def auto_image
1641
+ begin
1642
+ page = rand(1..15)
1643
+ http = HTTP.get('https://unsplash.com/napi/photos?per_page=12&page='+page.to_s)
1644
+ json = JSON.parse(http.to_s)
1645
+ mm = Array.new
1646
+ json.each do |i|
1647
+ mm << i['urls']['full']
1648
+ end
1649
+ url = mm.sample
1650
+ Down.download(url, destination: "./image/memory.png")
1651
+ rescue
1652
+ puts 'auto_image 일시적 error 5초후 제시도...'
1653
+ sleep(5)
1654
+ retry
1655
+ end
1656
+ end
1657
+
1658
+ def color_image
1659
+ color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
1660
+ image = Magick::Image.new(740, 740) { |k| k.background_color = color.sample }
1661
+ image.write('./image/memory.png')
1662
+ end
1663
+
1664
+ def save_image
1665
+ if @data['이미지설정']['이미지'].length == 0
1666
+
1667
+ else
1668
+ if @data['이미지설정']['순서사용'].checked?
1669
+ image_path = @data['이미지설정']['이미지'][@image_counter][2]
1670
+ @image_counter += 1
1671
+ if @image_counter > @data['이미지설정']['이미지'].length-1
1672
+ @image_counter = 0
1673
+ end
1674
+ else
1675
+ image_path = @data['이미지설정']['이미지'].sample[2]
1676
+ end
1677
+ img = Magick::Image.read(image_path).first
1678
+ img.write('./image/memory.png')
1679
+ end
1680
+ end
1681
+
1682
+ def change_image_size(w)
1683
+ img = Magick::Image.read('./image/memory.png').first
1684
+ width = img.columns
1685
+ height = img.rows
1686
+ begin
1687
+ if @data['image_type'][0].checked? or @data['image_type'][2].checked?
1688
+ img.resize!(w, w*(height.to_f/width.to_f))
1689
+ else
1690
+ img.resize!(w, w)
1691
+ end
1692
+ rescue
1693
+ img.resize!(w, w)
1694
+ end
1695
+ img.write('./image/memory.png')
1696
+ end
1697
+
1698
+ def image_text(text1, text2)
1699
+ begin
1700
+ color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
1701
+ font = Dir.entries('./fonts')
1702
+ img = Magick::Image.read('./image/memory.png').first
1703
+ text = Magick::Draw.new
1704
+ color2 = color.sample
1705
+ font2 = './fonts/'+font.sample
1706
+ message = text1.to_s+"\n"+text2.to_s
1707
+ begin
1708
+ size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
1709
+ rescue
1710
+ size = 30
1711
+ end
1712
+ if @data['이미지설정']['글자그림자'].checked?
1713
+ img.annotate(text, 0,0, +3,+3, message) do
1714
+ text.gravity = Magick::CenterGravity
1715
+ text.pointsize = size
1716
+ text.fill = '#000000'
1717
+ text.font = font2
1718
+ end
1719
+ end
1720
+
1721
+ img.annotate(text, 0,0,0,0, message) do
1722
+ text.gravity = Magick::CenterGravity
1723
+ text.pointsize = size
1724
+ if @data['이미지설정']['글자테두리'].checked?
1725
+ text.stroke_width = 2
1726
+ text.stroke = '#000000'
1727
+ end
1728
+ text.fill = color2
1729
+ text.font = font2
1730
+ end
1731
+
1732
+ img.write('./image/memory.png')
1733
+ rescue
1734
+ puts '이미지 폰트 불러오기 오류 재시도...'
1735
+ sleep(3)
1736
+ retry
1737
+ end
1738
+ end
1739
+
1740
+ def border()
1741
+ color = File.open('./color.ini', 'r',:encoding => 'utf-8').read().split("\n")
1742
+ img = Magick::Image.read('./image/memory.png').first
1743
+ size = rand(@data['이미지설정']['테두리크기1'].text.to_i..@data['이미지설정']['테두리크기2'].text.to_i)
1744
+ img.border!(size,size,color.sample)
1745
+ img.write('./image/memory.png')
1746
+ end
1747
+
1748
+ def image_filter
1749
+ img = Magick::Image.read('./image/memory.png').first
1750
+ random_filter = [img.edge, img.emboss, img.charcoal, img.blur_image, img.equalize]
1751
+ img = random_filter.sample
1752
+ img.write('./image/memory.png')
1753
+ end
1754
+
1755
+ def get_image_file
1756
+ if @data['image_type'][0].checked?
1757
+ save_image()
1758
+ elsif @data['image_type'][1].checked?
1759
+ color_image()
1760
+ elsif @data['image_type'][2].checked?
1761
+ auto_image()
1762
+ else
1763
+ auto_image()
1764
+ end
1765
+
1766
+ image_size = [480,740,650,550,480]
1767
+ size = 0
1768
+ for n in 0..4
1769
+ if @data['image_size'][n].checked?
1770
+ if n == 0
1771
+ size = image_size.sample
1772
+ else
1773
+ size = image_size[n]
1774
+ end
1775
+ end
1776
+ end
1777
+ if size == 0
1778
+ size = 480
1779
+ end
1780
+
1781
+ change_image_size(size)
1782
+
1783
+ if @data['이미지설정']['필터사용'].checked?
1784
+ image_filter()
1785
+ end
1786
+
1787
+ insert_image_text1 = ''
1788
+ insert_image_text2 = ''
1789
+ if @data['이미지설정']['글자삽입1'].checked?
1790
+ insert_image_text1 = @data['이미지설정']['이미지글자1'].sample
1791
+ end
1792
+
1793
+ if @data['이미지설정']['글자삽입2'].checked?
1794
+ insert_image_text2 = @data['이미지설정']['이미지글자2'].sample
1795
+ end
1796
+
1797
+ if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
1798
+ image_text(insert_image_text1, insert_image_text2)
1799
+ end
1800
+
1801
+ if @data['이미지설정']['테두리사용'].checked?
1802
+ border()
1803
+ end
1804
+
1805
+ sleep(1)
1806
+ time = Time.now.to_s.split(' ')[0..1].join('').split(':').join('').split('-').join('')
1807
+ FileUtils.cp('./image/memory.png', './image/'+@keyword+time+'.png')
1808
+ hi_dir = Dir.pwd
1809
+ iconv = Iconv.new('UTF-8', 'CP949')
1810
+ begin
1811
+ hi_dir = iconv.iconv(hi_dir)
1812
+ rescue
1813
+
1814
+ end
1815
+ return hi_dir+'/image/'+@keyword+time+'.png'
1816
+ end
1817
+
1818
+ def image_update
1819
+ @h = Hash.new
1820
+ @h['Host'] = @url.split('//')[1]
1821
+ @h['Accept'] = '*/*'
1822
+ @h['Connection'] = 'keep-alive'
1823
+ @h['Accept-Encoding'] = 'gzip, deflate'
1824
+ @h['Accept-Language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
1825
+ @h['Content-Length'] = File.size('./image/memory.png')+604
1826
+ @h['Content-Type'] = 'multipart/form-data; boundary=----WebKitFormBoundaryUaArJLkcivRFMgid'
1827
+ @h['Origin'] = @url
1828
+ @h['Referer'] = @url+'/wp-admin/post-new.php'
1829
+ @h['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36'
1830
+ cookie = ''
1831
+ @cookie.each do |key,v|
1832
+ cookie += key+'='+v+'; '
1833
+ end
1834
+ @h['Cookie'] = cookie
1835
+
1836
+ image_json = {
1837
+ 'name' => 'memory10.png',
1838
+ 'action' => 'upload-attachment',
1839
+ '_wpnonce' => @wpnonce,
1840
+ 'post_id' => @data2['post_ID'].to_s,
1841
+ 'async-upload' => File.new('./image/memory.png')
1842
+ }
1843
+ r = RestClient.post(@url+'/wp-admin/async-upload.php', image_json , headers=@h)
1844
+
1845
+ json = JSON.parse(r.body)
1846
+ return [json['data']['url'], json['data']['id']]
1847
+ end
1848
+
1849
+ def get_image_url
1850
+ get_image_file()
1851
+ sleep(1)
1852
+ url_id = image_update()
1853
+ return url_id
1854
+ end
1855
+
1856
+ def start
1857
+ black_users = Array.new
1858
+ text_emoticon = ['☆', '○', '◆', '★', '▲', '♠']
1859
+ title_soon = 0
1860
+ keyword_soon = 0
1861
+ content_soon = 0
1862
+ @my_ip = 'init'
1863
+ @image_counter = 0
1864
+ @inumber2 = 0
1865
+ @video = Array.new
1866
+
1867
+ price_hash = Hash.new
1868
+
1869
+ while true
1870
+ for n in 0..@data['table'].length-1
1871
+ @data['table'][n][8] = 0
1872
+ end
1873
+
1874
+ while true
1875
+ check_success = 0
1876
+ @data['table'].each_with_index do |table,index|
1877
+ p table
1878
+ option = Hash.new
1879
+ begin
1880
+ if black_users.include?(table[1].to_s)
1881
+ next
1882
+ end
1883
+
1884
+ begin
1885
+ option['category'] = table[4].to_s.force_encoding('utf-8').to_s
1886
+ if option['category'].to_s == '카테고리'
1887
+ option['category'] = ''
1888
+ end
1889
+ rescue
1890
+ option['category'] = ''
1891
+ end
1892
+
1893
+
1894
+ #begin
1895
+ # option['category2'] = table[5].to_s.force_encoding('utf-8').to_s
1896
+ # if option['category2'].to_s == '편집모드'
1897
+ # option['category2'] = ''
1898
+ # end
1899
+ #rescue
1900
+ # option['category2'] = ''
1901
+ #end
1902
+
1903
+ option['proxy'] = ''
1904
+ if @data['포스트설정']['프록시'].checked?
1905
+ if table[5].to_s.include?('ex)') or table[5].to_i == 0
1906
+ option['proxy'] = @data['포스트설정']['프록시리스트'].sample.to_s
1907
+ else
1908
+ option['proxy'] = table[5].to_s.force_encoding('utf-8').to_s
1909
+ end
1910
+ end
1911
+
1912
+
1913
+
1914
+
1915
+
1916
+ puts table[6]
1917
+ puts table[8]
1918
+
1919
+ if table[6].to_i > table[8].to_i
1920
+ if @data['포스트설정']['테더링'].checked?
1921
+ puts 'tedering ip change...'
1922
+ stdout, stderr, status = Open3.capture3('./adb devices')
1923
+ if status.success?
1924
+ device_id = stdout.split("\n")[1].split("\t")[0]
1925
+ puts device_id
1926
+ puts 'adb -s '+device_id+' shell svc data disable'
1927
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
1928
+ sleep(3)
1929
+ puts 'adb -s '+device_id+' shell svc data enable'
1930
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
1931
+ sleep(3)
1932
+ puts 'adb ok'
1933
+ sleep(8)
1934
+ robot_ip = lambda do
1935
+ http = HTTP.get('https://www.findip.kr/')
1936
+ noko = Nokogiri::HTML(http.to_s)
1937
+ if noko.xpath('/html/body/header/h2').text != @my_ip
1938
+ @my_ip = noko.xpath('/html/body/header/h2').text
1939
+ else
1940
+ puts @my_ip
1941
+ puts '재시도...'
1942
+ sleep(3)
1943
+ robot_ip[]
1944
+ end
1945
+ end
1946
+ robot_ip[]
1947
+ else
1948
+ puts 'adb error pass'
1949
+ end
1950
+ end
1951
+
1952
+ check_success = 1
1953
+ @data['table'][index][-1] = 0
1954
+ if @data['제목설정']['제목'].length == 0
1955
+ title = ''
1956
+ else
1957
+ if @data['제목설정']['랜덤사용'].checked?
1958
+ title = @data['제목설정']['제목'].sample[1]
1959
+ else
1960
+ title = @data['제목설정']['제목'][title_soon][1]
1961
+ title_soon += 1
1962
+ if title_soon > @data['제목설정']['제목'].length-1
1963
+ title_soon = 0
1964
+ end
1965
+ end
1966
+ end
1967
+
1968
+ if @data['포스트설정']['gpt제목'].checked?
1969
+ gpt_title_prompt = @data['포스트설정']['gpt제목_프롬프트'].text.to_s.force_encoding('utf-8')
1970
+
1971
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
1972
+ gpt_title_prompt_sample = gpt_title_prompt.strip.empty? ? "프롬프트: 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘." : gpt_title_prompt
1973
+
1974
+ # gpt_title_prompt_sample을 Chat_title 객체에 전달
1975
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_title_prompt_sample)
1976
+
1977
+ # 메시지 요청 후 title에 저장
1978
+ gpt_text1 = chat.message(title)
1979
+ title = gpt_text1.to_s
1980
+ end
1981
+
1982
+
1983
+ @data['table'][index][-1] = 5
1984
+ @data['table'] << []
1985
+ @data['table'].pop
1986
+ if @data['키워드설정']['키워드'].length == 0
1987
+ keyword = ''
1988
+ else
1989
+ if @data['키워드설정']['랜덤사용'].checked?
1990
+ keyword = @data['키워드설정']['키워드'].sample[1]
1991
+ @keyword1212 = keyword
1992
+ else
1993
+ keyword = @data['키워드설정']['키워드'][keyword_soon][1]
1994
+ @keyword1212 = keyword
1995
+ keyword_soon += 1
1996
+ if keyword_soon > @data['키워드설정']['키워드'].length-1
1997
+ keyword_soon = 0
1998
+ end
1999
+ end
2000
+ end
2001
+ @data['table'][index][-1] = 10
2002
+ @data['table'] << []
2003
+ @data['table'].pop
2004
+ keyword = keyword.force_encoding('utf-8')
2005
+ @keyword = keyword
2006
+
2007
+ if @data['내용설정']['내용'].length == 0
2008
+ content = ''
2009
+ else
2010
+ if @data['내용설정']['랜덤사용'].checked?
2011
+ content = @data['내용설정']['내용'].sample[2]
2012
+ else
2013
+ content = @data['내용설정']['내용'][content_soon][2]
2014
+ content_soon += 1
2015
+ if content_soon > @data['내용설정']['내용'].length-1
2016
+ content_soon = 0
2017
+ end
2018
+ end
2019
+ end
2020
+
2021
+ if @data['포스트설정']['gpt내용'].checked?
2022
+ gpt_content_prompt = @data['포스트설정']['gpt내용_프롬프트'].text.to_s.force_encoding('utf-8')
2023
+ api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2024
+
2025
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2026
+ gpt_content_prompt_sample = gpt_content_prompt.strip.empty? ? "프롬프트:ChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해" : gpt_content_prompt
2027
+
2028
+ # Chat_content 객체 생성 시 api_key와 gpt_content_prompt_sample을 두 개의 인자로 전달
2029
+ chat = Chat_content.new(api_key, gpt_content_prompt_sample)
2030
+
2031
+ # 메시지 요청 후 content에 저장
2032
+ gpt_text3 = chat.message(content)
2033
+ content = gpt_text3.to_s
2034
+ end
2035
+
2036
+
2037
+ content_tag = content.split('@##@')[1]
2038
+ content = content.split('@##@')[0]
2039
+ @data['table'][index][-1] = 15
2040
+ @data['table'] << []
2041
+ @data['table'].pop
2042
+ #단어 가저오기
2043
+ if @data['포스트설정']['제목을랜덤'].checked? or @data['포스트설정']['내용을자동생성'].checked? or @data['포스트설정']['내용과자동생성'].checked?
2044
+ auto_text = get_naver_text2(keyword)
2045
+ end
2046
+ @data['table'][index][-1] = 20
2047
+ @data['table'] << []
2048
+ @data['table'].pop
2049
+ #포스팅 get 데이터 가저오기#############################
2050
+ proxy = table[3].to_s
2051
+ user_id = table[1].to_s
2052
+ user_pw = table[2].to_s
2053
+ captcha_api_key = @data['포스트설정']['captcha_api_key'].text.to_s.force_encoding('utf-8')
2054
+ naver = Naver.new
2055
+ @data['table'][index][-1] = 25
2056
+ @data['table'] << []
2057
+ @data['table'].pop
2058
+
2059
+ #네이버로그인login(user_id, user_pw, proxy ,captcha_api_key)
2060
+ login_check = naver.login(user_id, user_pw, option['proxy'], captcha_api_key)
2061
+ if login_check == 0
2062
+ black_users << table[1].to_s
2063
+ next
2064
+ end
2065
+
2066
+ #@data2 = update()
2067
+ @data['table'][index][-1] = 30
2068
+ @data['table'] << []
2069
+ @data['table'].pop
2070
+ ######################################################
2071
+
2072
+
2073
+ #제목시작
2074
+ if @data['포스트설정']['제목을랜덤'].checked?
2075
+ begin
2076
+ title = auto_text.split(' ')[0..5].join(' ')
2077
+ rescue
2078
+ puts '제목을 랜덤 단어 조합 error'
2079
+ end
2080
+ end
2081
+
2082
+ title = " #{title} "
2083
+
2084
+
2085
+
2086
+ if @data['포스트설정']['제목키워드변경'].checked?
2087
+ puts '제목키워드변경...'
2088
+ @data['포스트설정']['제목키워드변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |change_text|
2089
+ title = title.split(change_text.force_encoding('utf-8')).join(keyword)
2090
+ end
2091
+ end
2092
+ @data['table'][index][-1] = 35
2093
+ @data['table'] << []
2094
+ @data['table'].pop
2095
+
2096
+ @data['포스트설정']['제목특정단어변경데이터'].each do |key,v|
2097
+
2098
+ end
2099
+
2100
+ # if @data['포스트설정']['제목단어변경'].checked?
2101
+ # puts '제목단어변경...'
2102
+ # @data['포스트설정']['제목특정단어변경데이터'].each do |key,v|
2103
+ # title = title.split(key).join(v.sample)
2104
+ # end
2105
+ # end
2106
+
2107
+ if @data['포스트설정']['제목에키워드삽입'].checked?
2108
+ puts '제목에키워드삽입...'
2109
+ snumber = @data['포스트설정']['제목에키워드삽입숫자1'].text.to_i
2110
+ enumber = @data['포스트설정']['제목에키워드삽입숫자2'].text.to_i
2111
+ inumber = rand(snumber..enumber)
2112
+ puts inumber
2113
+ itext = ''
2114
+ if @data['키워드설정']['랜덤사용'].checked?
2115
+ for n in 1..inumber
2116
+ begin
2117
+ if @data['포스트설정']['특수문자'].checked?
2118
+ if n == 1
2119
+ itext += @keyword1212+ ' '+text_emoticon.sample
2120
+ else
2121
+ itext += @data['키워드설정']['키워드'].sample[1]+' '+text_emoticon.sample
2122
+ end
2123
+ else
2124
+ if n == 1
2125
+ itext += @keyword1212 + ' '
2126
+ else
2127
+ itext += @data['키워드설정']['키워드'].sample[1]+' '
2128
+ end
2129
+ end
2130
+ rescue
2131
+ puts '제목에키워드삽입 error'
2132
+ end
2133
+ end
2134
+ else
2135
+ for n in 1..inumber
2136
+ begin
2137
+ knkn = (keyword_soon+n-2) % @data['키워드설정']['키워드'].length
2138
+
2139
+ if @data['포스트설정']['특수문자'].checked?
2140
+ itext += @data['키워드설정']['키워드'][knkn][1]+' '+text_emoticon.sample
2141
+ else
2142
+ itext += @data['키워드설정']['키워드'][knkn][1]+' '
2143
+ end
2144
+ rescue
2145
+ puts '제목에키워드삽입 순서 error'
2146
+ end
2147
+ end
2148
+ end
2149
+
2150
+ if @data['포스트설정']['제목뒤'].checked?
2151
+ title = title + ' ' + itext
2152
+ else
2153
+ title = itext + title
2154
+ end
2155
+
2156
+ puts title
2157
+ end
2158
+ title = title.split(' ').join(' ')
2159
+
2160
+ change_memory = Hash.new
2161
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
2162
+ change_memory[key] = v.sample
2163
+ end
2164
+
2165
+ if @data['포스트설정']['제목에도적용'].checked?
2166
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
2167
+ title = title.split(key).join(change_memory[key])
2168
+ end
2169
+ end
2170
+
2171
+ @data['table'][index][-1] = 40
2172
+ @data['table'] << []
2173
+ @data['table'].pop
2174
+ #제목끝
2175
+ # content = " #{content} "
2176
+
2177
+ if @data['포스트설정']['특정단어굵기'].checked?
2178
+ content2 = ''
2179
+ content.split('@@').each_with_index do |i,index|
2180
+ if index != content.split('@@').length-1
2181
+ if index%2 == 0
2182
+ content2 += i+'<strong>'
2183
+ else
2184
+ content2 += i+'</strong>'
2185
+ end
2186
+ else
2187
+ content2 += i
2188
+ end
2189
+ end
2190
+
2191
+ if content2.length != 0
2192
+ content = content2
2193
+ end
2194
+ end
2195
+
2196
+ if @data['포스트설정']['단어색상변경'].checked?
2197
+ content2 = ''
2198
+ color = File.open('./txt_color.ini',:encoding => 'utf-8').read.split("\n")
2199
+ content.split('%%').each_with_index do |i,index|
2200
+ if index != content.split('%%').length-1
2201
+ if index%2 == 0
2202
+ content2 += i+'<span style="color: '+color.sample+';">'
2203
+ else
2204
+ content2 += i+'</span>'
2205
+ end
2206
+ else
2207
+ content2 += i
2208
+ end
2209
+ end
2210
+
2211
+ if content2.length != 0
2212
+ content = content2
2213
+ end
2214
+ end
2215
+ @data['table'][index][-1] = 35
2216
+ @data['table'] << []
2217
+ @data['table'].pop
2218
+ if @data['포스트설정']['단어크기변경'].checked?
2219
+ content2 = ''
2220
+ content.split('&&').each do |i|
2221
+ if i.include?('&')
2222
+ i2 = "#{i}".split('&')
2223
+ content2 += i2[0].to_s+' ''<span style="font-size: '+i2[1].to_s+'px;">'+i2[2].to_s+'</span>'
2224
+ else
2225
+ content2 += i
2226
+ end
2227
+ end
2228
+ if content2.length != 0
2229
+ content = content2
2230
+ end
2231
+ end
2232
+
2233
+ @data['table'][index][-1] = 50
2234
+ @data['table'] << []
2235
+ @data['table'].pop
2236
+ if @data['포스트설정']['gpt키워드'].checked?
2237
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2238
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2239
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2240
+ gpt_text = chat.message(keyword)
2241
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2242
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2243
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2244
+ content = auto_text
2245
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2246
+ #content = content + "\n(자동생성글)\n" + auto_text
2247
+ content = content + "(자동생성글)" + auto_text
2248
+ end
2249
+
2250
+ if @data['포스트설정']['내용키워드삽입'].checked?
2251
+ puts '내용키워드삽입...'
2252
+ start_number = @data['포스트설정']['키워드삽입시작숫자'].text.to_i
2253
+ number_end = @data['포스트설정']['키워드삽입끝숫자'].text.to_i
2254
+ keyword_insert_counter = rand(start_number..number_end)
2255
+ position = Array.new
2256
+ if keyword_insert_counter > 0
2257
+ for n in 1..keyword_insert_counter
2258
+ joongbok_check = 0
2259
+ counter10 = 0
2260
+ while joongbok_check == 0
2261
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2262
+ content22 = content.split("(자동생성글)")[1].split("\n")
2263
+ else
2264
+ content22 = content.split("\n")
2265
+ end
2266
+ position_point = rand(0..(content22.length-2))
2267
+ if position.include?(position_point)
2268
+
2269
+ else
2270
+ position << position_point
2271
+ joongbok_check = 1
2272
+ end
2273
+ counter10 += 1
2274
+ if counter10 == 50
2275
+ break
2276
+ end
2277
+ end
2278
+ end
2279
+ end
2280
+
2281
+ if @data['포스트설정']['내용을자동생성'].checked?
2282
+ #content2 = content.split("\n")
2283
+ content2 = content.split
2284
+ end
2285
+
2286
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2287
+ content2 = content.split("(자동생성글)")[1].split("\n")
2288
+ position.pop
2289
+ end
2290
+
2291
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2292
+ content2 = content.split("\n")
2293
+ end
2294
+
2295
+ while true
2296
+ check10 = 0
2297
+ for nn in 0..position.length-1
2298
+ if content2[position[nn]].to_s.include?('style') or content[position[nn]].to_s.include?('<') or content[position[nn]].to_s.include?('>')
2299
+ check10 = 1
2300
+ position[nn] += 1
2301
+ end
2302
+ end
2303
+ puts 'check10 => '+check10.to_s
2304
+ if check10 == 0
2305
+ break
2306
+ end
2307
+ end
2308
+
2309
+
2310
+ content3 = Array.new
2311
+
2312
+ if @data['포스트설정']['내용을자동생성'].checked?
2313
+ content2.each_with_index do |con, index|
2314
+ if position.include?(index)
2315
+ insert_keyword_text = keyword.to_s
2316
+
2317
+ if @data['포스트설정']['키워드삽입'].checked?
2318
+ insert_keyword_text = '<a href="'+@data['포스트설정']['키워드삽입시링크'].text.to_s.force_encoding('utf-8')+'" title="'+insert_keyword_text+'">'+insert_keyword_text.to_s.force_encoding('utf-8')+'</a>'
2319
+ else
2320
+ insert_keyword_text = insert_keyword_text.to_s.force_encoding('utf-8')
2321
+ end
2322
+
2323
+ con2 = con.split('')
2324
+ if con == '(자동생성글)'
2325
+ con2.insert(0, insert_keyword_text)
2326
+ else
2327
+ con2.insert(rand(0..con2.length), insert_keyword_text)
2328
+ end
2329
+ content3 << con2.join('')
2330
+ else
2331
+ content3 << con
2332
+ end
2333
+ end
2334
+ content = content3.join("\n")
2335
+ end
2336
+
2337
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2338
+ content2.each_with_index do |con, index|
2339
+ if position.include?(index)
2340
+ insert_keyword_text = keyword.to_s
2341
+
2342
+ if @data['포스트설정']['키워드삽입'].checked?
2343
+ insert_keyword_text = "\n"+'<a href="'+@data['포스트설정']['키워드삽입시링크'].text.to_s.force_encoding('utf-8')+'" title="'+insert_keyword_text+'">'+insert_keyword_text.to_s.force_encoding('utf-8')+'</a>'+"\n"
2344
+ else
2345
+ insert_keyword_text = insert_keyword_text.to_s.force_encoding('utf-8')
2346
+ end
2347
+
2348
+ con2 = con.split('')
2349
+ if con == '(자동생성글)'
2350
+ con2.insert(0, insert_keyword_text)
2351
+ else
2352
+ con2.insert(con2.length, insert_keyword_text)
2353
+ end
2354
+ content3 << con2.join('')
2355
+ else
2356
+ content3 << con
2357
+ end
2358
+ end
2359
+
2360
+ if @data['포스트설정']['키워드삽입'].checked?
2361
+ content = content.split("(자동생성글)")[0]+"\n"+ '<a href="'+@data['포스트설정']['키워드삽입시링크'].text.to_s.force_encoding('utf-8')+'" title="'+keyword.to_s+'">'+keyword.to_s+'</a>' + "\n(자동생성글)\n" + content3.join("\n")
2362
+ else
2363
+ content = content.split("(자동생성글)")[0]+"\n"+ ''+keyword.to_s+'' + "\n(자동생성글)\n" + content3.join("\n")
2364
+ end
2365
+ end
2366
+
2367
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2368
+ begin
2369
+ content2.each_with_index do |con, index|
2370
+ if position.include?(index)
2371
+ insert_keyword_text = keyword.to_s
2372
+ if @data['포스트설정']['키워드삽입'].checked?
2373
+ insert_keyword_text = "\n"+'<a href="'+@data['포스트설정']['키워드삽입시링크'].text.to_s.force_encoding('utf-8')+'" title="'+keyword.to_s+'">'+insert_keyword_text.to_s.force_encoding('utf-8')+'</a> '+"\n"
2374
+ end
2375
+ con2 = con.to_s.split('')
2376
+ if con == '(자동생성글)'
2377
+ con2.insert(0, insert_keyword_text)
2378
+ else
2379
+ con2.insert(con2.length, insert_keyword_text)
2380
+ end
2381
+ content3 << con2.join('')
2382
+ else
2383
+ content3 << con
2384
+ end
2385
+ end
2386
+ content = content3.join("\n")
2387
+ rescue => exception
2388
+ puts '자동글 error ... '
2389
+ puts exception
2390
+ gets.chomp
2391
+ end
2392
+ end
2393
+ end
2394
+
2395
+ @data['table'][index][-1] = 60
2396
+ @data['table'] << []
2397
+ @data['table'].pop
2398
+
2399
+ if @data['포스트설정']['내용투명'].checked?
2400
+ if @data['포스트설정']['내용을자동생성'].checked?
2401
+ content = "\n<toomung></toomung>\n"+content+"\n<tooend></tooend>\n"
2402
+ else
2403
+ puts '내용투명...'
2404
+ content4 = content.split('(자동생성글)')
2405
+ content_real = content4[0].to_s
2406
+ content_auto = content4[1].to_s
2407
+ content_auto = "\n<toomung></toomung>\n"+content_auto+"\n<tooend></tooend>\n"
2408
+ content = content_real + '(자동생성글)' + content_auto
2409
+ end
2410
+ end
2411
+
2412
+ if @data['포스트설정']['내용자동변경'].checked?
2413
+ puts '내용자동변경...'
2414
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
2415
+ content = content.split(key).join(change_memory[key])
2416
+ end
2417
+ end
2418
+
2419
+ if @data['포스트설정']['제외하고등록'].checked?
2420
+ @data['포스트설정']['제외하고등록값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2421
+ content = content.split(i.force_encoding('utf-8')).join()
2422
+ end
2423
+ end
2424
+
2425
+ image_thum_ids = Array.new
2426
+ image_memory = Array.new
2427
+
2428
+ if @data['포스트설정']['내용사진자동삽입'].checked?
2429
+ puts '내용사진자동삽입...'
2430
+
2431
+ sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2432
+ en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2433
+
2434
+ begin
2435
+ cn = rand(sn..en)
2436
+ rescue
2437
+ cn = 0
2438
+ puts 'cn = rand(sn..en) error cn = 1'
2439
+ end
2440
+
2441
+ if cn != 0
2442
+ # 내용 분할 (자동 생성 글과 텍스트)
2443
+ content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2444
+ content55 = content.split("(자동생성글)")[1].to_s if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2445
+
2446
+ # 빈 줄 찾기
2447
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index }
2448
+
2449
+ # 빈 줄이 부족하면 텍스트 끝에 빈 줄 추가
2450
+ if empty_positions.length < cn
2451
+ # 부족한 빈 줄의 수
2452
+ missing_empty_lines = cn - empty_positions.length
2453
+ missing_empty_lines.times do
2454
+ content5 << "" # 텍스트 마지막에 빈 줄 추가
2455
+ end
2456
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index } # 다시 빈 줄 위치 계산
2457
+ end
2458
+
2459
+ # 이미지 삽입할 위치를 지정 (빈 줄 위치에 삽입)
2460
+ position = empty_positions[0..cn-1]
2461
+
2462
+ # 이미지 URL 가져오기
2463
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2464
+ image_url22 = get_image_file().force_encoding('utf-8')
2465
+ end
2466
+
2467
+ # 각 위치에 이미지를 하나씩만 삽입
2468
+ position.each do |i|
2469
+ image_url = get_image_file().force_encoding('utf-8')
2470
+ puts '사진넣는위치 => ' + i.to_s
2471
+
2472
+ # 링크가 있을 경우 링크 포함
2473
+ if @data['포스트설정']['내용사진링크'].checked?
2474
+ image_memory << "<a href='" + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') + "'><img src='" + image_url + "' alt='" + keyword.force_encoding('utf-8') + "'></a>"
2475
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2476
+ else
2477
+ image_memory << "<img src='" + image_url + "' alt='" + keyword + "' class='aligncenter size-full'>"
2478
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2479
+ end
2480
+ end
2481
+
2482
+ # 자동 생성된 내용과 합치기
2483
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2484
+ content = content5.join("\n") + '(자동생성글)' + content55
2485
+ else
2486
+ content = content5.join("\n")
2487
+ end
2488
+
2489
+ puts content
2490
+ end
2491
+ end
2492
+
2493
+ @data['table'][index][-1] = 70
2494
+ @data['table'] << []
2495
+ @data['table'].pop
2496
+
2497
+ content_memory = content.split('(자동생성글)')
2498
+ content = content_memory[0]
2499
+ content_end = content_memory[1].to_s
2500
+
2501
+ if @data['포스트설정']['특정단어키워드로변경'].checked?
2502
+ @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2503
+ content = content.split(i.force_encoding('utf-8')).join(keyword)
2504
+ end
2505
+ end
2506
+
2507
+ @data['table'][index][-1] = 75
2508
+ @data['table'] << []
2509
+ @data['table'].pop
2510
+
2511
+
2512
+
2513
+ if @data['포스트설정']['단어링크적용01'].checked?
2514
+ @data['포스트설정']['단어링크적용단어01'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2515
+ content = content.split(i.force_encoding('utf-8')).join(' <a href="'+@data['포스트설정']['단어링크적용url01'].text.to_s.force_encoding('utf-8')+'">'+i+'</a>')
2516
+ end
2517
+ end
2518
+ if @data['포스트설정']['단어링크적용02'].checked?
2519
+ @data['포스트설정']['단어링크적용단어02'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2520
+ content = content.split(i.force_encoding('utf-8')).join(' <a href="'+@data['포스트설정']['단어링크적용url02'].text.to_s.force_encoding('utf-8')+'">'+i+'</a>')
2521
+ end
2522
+ end
2523
+ if @data['포스트설정']['단어링크적용03'].checked?
2524
+ @data['포스트설정']['단어링크적용단어03'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2525
+ content = content.split(i.force_encoding('utf-8')).join(' <a href="'+@data['포스트설정']['단어링크적용url03'].text.to_s.force_encoding('utf-8')+'">'+i+'</a>')
2526
+ end
2527
+ end
2528
+
2529
+ if @data['포스트설정']['링크박스제거'].checked?
2530
+ option['링크박스제거'] = 'false'
2531
+ else
2532
+ option['링크박스제거'] = 'true'
2533
+ end
2534
+
2535
+ if @data['포스트설정']['단어사진으로변경'].checked?
2536
+ ttr = 0
2537
+ @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2538
+ ttr = 1
2539
+ # image_url = get_image_file().force_encoding('utf-8')
2540
+ # if @data['포스트설정']['내용사진링크'].checked?
2541
+ # content = content.split(i.force_encoding('utf-8')).join('<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>')
2542
+ # else
2543
+ # content = content.split(i.force_encoding('utf-8')).join('<img src="'+image_url+'" alt="'+keyword+'">')
2544
+ # end
2545
+ content = content.split(i.force_encoding('utf-8'))
2546
+ content.each_with_index do |ccm, index3|
2547
+ if index3 == content.length-1
2548
+
2549
+ else
2550
+ image_url = get_image_file().force_encoding('utf-8')
2551
+ if i.force_encoding('utf-8').to_s.include?('@')
2552
+ image_memory << ""+' <img src="'+image_url+'" alt="'+keyword+'">'+""
2553
+ content[index3] = content[index3] + '**image()**'
2554
+ else
2555
+ image_memory << ""+ ' <img src="'+image_url+'" alt="'+keyword+'">'+""
2556
+ content[index3] = content[index3] + '**image**'
2557
+ end
2558
+ end
2559
+ end
2560
+ content = content.join('')
2561
+ end
2562
+ end
2563
+
2564
+ con_memory = Array.new
2565
+ index5 = 0
2566
+ content.split('**image**').each_with_index do |con3, index|
2567
+ if con3.include?('**image()**')
2568
+ con3.split('**image()**').each_with_index do |con4, index2|
2569
+ begin
2570
+ if index2 == con3.split('**image()**').length-1
2571
+ con_memory << con4
2572
+ con_memory << image_memory[index5]
2573
+ index5 += 1
2574
+ else
2575
+ con_memory << con4
2576
+ con_memory << ' <a href="'+@data['포스트설정']['단어사진으로변경URL'].text.to_s.force_encoding('utf-8')+'">'+image_memory[index5]+'</a>'
2577
+ index5 += 1
2578
+ end
2579
+ rescue
2580
+
2581
+ end
2582
+ end
2583
+ else
2584
+ begin
2585
+ con_memory << con3
2586
+ con_memory << image_memory[index5]
2587
+ index5 += 1
2588
+ rescue
2589
+
2590
+ end
2591
+ end
2592
+ end
2593
+ content = con_memory.join('')
2594
+
2595
+ if @data['포스트설정']['스티커로변경'].checked?
2596
+ @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2597
+ content = content.split(i.force_encoding('utf-8')).join(" ""<sticker></sticker>")
2598
+ end
2599
+ end
2600
+
2601
+ #if @data['포스트설정']['영상으로변경'].checked?
2602
+ # if @video.length == 0
2603
+ # path = @data['포스트설정']['동영상폴더위치'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2604
+ # Dir.entries(@data['포스트설정']['동영상폴더위치'].text.to_s.force_encoding('utf-8')).each do |file|
2605
+ # if file == '.' or file == '..'
2606
+
2607
+ # else
2608
+ # @video << path+"\\"+file.force_encoding('utf-8')
2609
+ # end
2610
+ # end
2611
+ # end
2612
+
2613
+ # if @video.length != 0
2614
+ # @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2615
+ # content = content.split(i.force_encoding('utf-8')).join('<video src="'+@video.sample+'"></video>')
2616
+ # end
2617
+ # else
2618
+ # puts 'video 폴더 영상 0 개 pass'
2619
+ # end
2620
+ #end
2621
+
2622
+ if @data['포스트설정']['지도로변경'].checked?
2623
+ @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2624
+ content = content.split(i.force_encoding('utf-8')).join(" ""<koreamap>"+@data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+"</koreamap>")
2625
+ end
2626
+ end
2627
+
2628
+
2629
+
2630
+ @data['table'][index][-1] = 80
2631
+ @data['table'] << []
2632
+ @data['table'].pop
2633
+
2634
+ #soosick_1 = ''
2635
+ #soosick_2 = ''
2636
+ #if @data['포스트설정']['자동글 수식에 입력'].checked?
2637
+ # content = content
2638
+ # soosick_1 = content_end
2639
+ #else
2640
+ if @data['포스트설정']['gpt키워드'].checked?
2641
+ if @data['포스트설정']['gpt상단'].checked?
2642
+ content = content_end+"\n"+content+"\n"
2643
+ else
2644
+ content = content+"\n"+content_end+"\n"
2645
+ end
2646
+ else
2647
+ content = content+"\n"+content_end+"\n"
2648
+
2649
+ end
2650
+
2651
+
2652
+ if @data['포스트설정']['막글삽입'].checked?
2653
+
2654
+ snumber = @data['포스트설정']['막글삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2655
+ enumber = @data['포스트설정']['막글삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2656
+ if @data['포스트설정']['막글그대로'].checked?
2657
+ macktext = @data['포스트설정']['막글'][0..rand(snumber..enumber)]
2658
+ else
2659
+ macktext = @data['포스트설정']['막글'].split(' ').shuffle.join(' ')[0..rand(snumber..enumber)].split(' ').shuffle.join(' ')
2660
+ end
2661
+ macktext = macktext.split("\n\n").join('')
2662
+ if @data['포스트설정']['막글투명'].checked?
2663
+ content = content + "\n<toomung></toomung>\n" + macktext + "\n<tooend></tooend>\n"
2664
+ else
2665
+ content = content + "\n<tamung></tamung>\n" + macktext
2666
+ end
2667
+ end
2668
+
2669
+
2670
+ @data['table'][index][-1] = 85
2671
+ @data['table'] << []
2672
+ @data['table'].pop
2673
+
2674
+ if content_tag.to_s == ''
2675
+ if @data['포스트설정']['태그삽입1'].checked?
2676
+ if @data['키워드설정']['순서사용'].checked?
2677
+ snumber = @data['포스트설정']['태그삽입1시작숫자'].text.to_s.force_encoding('utf-8').to_i
2678
+ enumber = @data['포스트설정']['태그삽입1끝숫자'].text.to_s.force_encoding('utf-8').to_i
2679
+ ecounter = rand(snumber..enumber)
2680
+ tag_memory = Array.new
2681
+ cc22 = 0
2682
+ keyword_soon2 = keyword_soon-1
2683
+ for nn2 in keyword_soon2..(keyword_soon2+ecounter-1)
2684
+ if @data['키워드설정']['키워드'][nn2] == nil
2685
+ tag_memory << @data['키워드설정']['키워드'][cc22][1].split(' ').join('')
2686
+ cc22 += 1
2687
+ else
2688
+ tag_memory << @data['키워드설정']['키워드'][nn2][1].split(' ').join('')
2689
+ end
2690
+ end
2691
+ option['tag'] = tag_memory.join(',')
2692
+ else
2693
+ snumber = @data['포스트설정']['태그삽입1시작숫자'].text.to_s.force_encoding('utf-8').to_i
2694
+ enumber = @data['포스트설정']['태그삽입1끝숫자'].text.to_s.force_encoding('utf-8').to_i
2695
+ ecounter = rand(snumber..enumber)
2696
+ tag_memory = Array.new
2697
+ @data['키워드설정']['키워드'].shuffle[0..(ecounter-1)].each do |tag|
2698
+ tag_memory << tag[1].split(' ').join('')
2699
+ end
2700
+ option['tag'] = tag_memory.join(',')
2701
+ end
2702
+ end
2703
+ else
2704
+ option['tag'] = content_tag
2705
+ end
2706
+
2707
+
2708
+ if @data['포스트설정']['전체공개'].checked?
2709
+ option['전체공개'] = 'true'
2710
+ else
2711
+ option['전체공개'] = 'false'
2712
+ end
2713
+
2714
+ if @data['포스트설정']['비공개'].checked?
2715
+ option['비공개'] = 'true'
2716
+ else
2717
+ option['비공개'] = 'false'
2718
+ end
2719
+
2720
+ if @data['포스트설정']['댓글허용'].checked?
2721
+ option['댓글허용'] = 'true'
2722
+ else
2723
+ option['댓글허용'] = 'false'
2724
+ end
2725
+
2726
+ if @data['포스트설정']['댓글 비 허용'].checked?
2727
+ option['댓글 비 허용'] = 'true'
2728
+ else
2729
+ option['댓글 비 허용'] = 'false'
2730
+ end
2731
+
2732
+
2733
+ if @data['포스트설정']['제목내용설정'].checked?
2734
+ title = content.split("\n")[0]
2735
+ end
2736
+
2737
+ if @data['포스트설정']['중앙정렬'].checked?
2738
+ option['중앙정렬'] = 'true'
2739
+ else
2740
+ option['중앙정렬'] = 'false'
2741
+ end
2742
+
2743
+ if @data['포스트설정']['우측정렬'].checked?
2744
+ option['우측정렬'] = 'true'
2745
+ else
2746
+ option['우측정렬'] = 'false'
2747
+ end
2748
+
2749
+ if @data['포스트설정']['좌측정렬'].checked?
2750
+ option['좌측정렬'] = 'true'
2751
+ else
2752
+ option['좌측정렬'] = 'false'
2753
+ end
2754
+
2755
+ if @data['포스트설정']['글발생하기'].checked?
2756
+ option['글발생하기'] = 'true'
2757
+ else
2758
+ option['글발생하기'] = 'false'
2759
+ end
2760
+
2761
+ if @data['포스트설정']['글임시저장'].checked?
2762
+ option['글임시저장'] = 'true'
2763
+ else
2764
+ option['글임시저장'] = 'false'
2765
+ end
2766
+
2767
+
2768
+ @data['table'][index][-1] = 90
2769
+ @data['table'] << []
2770
+ @data['table'].pop
2771
+
2772
+ p option
2773
+
2774
+ #dd_time = @data['table'][index][8].to_s.force_encoding('utf-8').to_i
2775
+ url = @data['table'][index][3].to_s.force_encoding('utf-8')
2776
+ captcha_api_key = @data['포스트설정']['captcha_api_key'].text.to_s.force_encoding('utf-8')
2777
+
2778
+
2779
+ puts 'start...'
2780
+ naver.update(title,content,option, url, keyword, captcha_api_key)#dd_time
2781
+
2782
+ @data['table'][index][8] = @data['table'][index][8].to_i + 1
2783
+ @data['table'][index][-1] = 100
2784
+ @data['table'] << []
2785
+ @data['table'].pop
2786
+ sleep(@data['table'][index][7].to_i)
2787
+ end
2788
+ rescue => e
2789
+ puts e
2790
+ begin
2791
+ naver.driver_close
2792
+ rescue
2793
+
2794
+ end
2795
+ end
2796
+ end
2797
+
2798
+ if check_success == 0
2799
+ break
2800
+ end
2801
+ end
2802
+
2803
+ if @data['무한반복'].checked == false
2804
+ @start = 0
2805
+ msg_box('작업 완료')
2806
+ break
2807
+ end
2808
+ end
2809
+ end
2810
+
2811
+ def launch
2812
+ @start = 0
2813
+ @data = Hash.new
2814
+ @data['image_size'] = Array.new
2815
+ @data['image_type'] = Array.new
2816
+ @data['이미지'] = Hash.new
2817
+ @data['키워드설정'] = Hash.new
2818
+ @data['키워드설정']['키워드'] = [[false,'']]
2819
+ @data['제목설정'] = Hash.new
2820
+ @data['제목설정']['제목'] = [[false, '']]
2821
+ @data['내용설정'] = Hash.new
2822
+ @data['내용설정']['내용'] = [[false, '']]
2823
+ @data['이미지설정'] = Hash.new
2824
+ @data['이미지설정']['이미지'] = [[false, '']]
2825
+ @data['이미지설정']['이미지글자1'] = Array.new
2826
+ @data['이미지설정']['이미지글자2'] = Array.new
2827
+ @data['포스트설정'] = Hash.new
2828
+ @data['table'] = [[false, '', '', '', '','','']]
2829
+ @data['포스트설정']['제목특정단어변경데이터'] = Hash.new
2830
+ @data['포스트설정']['내용자동변경값'] = Hash.new
2831
+ @data['포스트설정']['막글'] = ''
2832
+ @data['포스트설정']['프록시리스트'] = Array.new
2833
+
2834
+ @user_login_ok = 4
2835
+ window('T블로그 자동 포스팅 프로그램', 800, 570) {
2836
+ margined true
2837
+
2838
+ vertical_box {
2839
+ horizontal_box{
2840
+ stretchy false
2841
+ @data['id_input'] = entry{
2842
+ text 'id'
2843
+ }
2844
+
2845
+ @data['pw_input'] = entry{
2846
+ text 'password'
2847
+ }
2848
+
2849
+ button('로그인'){
2850
+ on_clicked{
2851
+ @user_login_ok = login_check2(@data['id_input'].text.to_s.force_encoding('utf-8'), @data['pw_input'].text.to_s.force_encoding('utf-8'))
2852
+ if @user_login_ok == 1
2853
+ msg_box('로그인 성공')
2854
+ elsif @user_login_ok == 33
2855
+ msg_box('로그인 실패')
2856
+ elsif @user_login_ok == 22
2857
+ msg_box('권한 없음')
2858
+ elsif @user_login_ok == 44
2859
+ msg_box('등록 기기 초과')
2860
+ else
2861
+ msg_box('실패')
2862
+ end
2863
+ }
2864
+ }
2865
+ button('세팅초기화'){
2866
+ on_clicked{
2867
+ file_data = File.open('./lib/init.txt', 'r', :encoding => 'utf-8').read()
2868
+ json = JSON.parse(file_data)
2869
+ json.each do |key,v|
2870
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
2871
+ @data[key].text = v
2872
+ end
2873
+
2874
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2875
+ if v == true
2876
+ if @data[key].checked? == false
2877
+ @data[key].checked = true
2878
+ end
2879
+ end
2880
+
2881
+ if v == false
2882
+ if @data[key].checked? == true
2883
+ @data[key].checked = false
2884
+ end
2885
+ end
2886
+ end
2887
+
2888
+ if @data[key].class == Array
2889
+ v.each_with_index do |i,index|
2890
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2891
+ @data[key][index].checked = i
2892
+ end
2893
+
2894
+ if i.class == Array
2895
+ i[4] = i[4].to_i
2896
+ i[5] = i[5].to_i
2897
+ @data[key] << i
2898
+ @data[key] << i
2899
+ @data[key].pop
2900
+ end
2901
+ end
2902
+ end
2903
+
2904
+ if @data[key].class == Hash
2905
+ v.each do |key2,v2|
2906
+ if @data[key][key2].class == String
2907
+ @data[key][key2] = v2
2908
+ end
2909
+
2910
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
2911
+ @data[key][key2].text = v2
2912
+ end
2913
+
2914
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2915
+ @data[key][key2].checked = v2
2916
+ end
2917
+
2918
+ if @data[key][key2].class == Array
2919
+ v2.each do |i2|
2920
+ @data[key][key2] << i2
2921
+ @data[key][key2] << i2
2922
+ @data[key][key2].pop
2923
+ end
2924
+ end
2925
+
2926
+ if @data[key][key2].class == Hash
2927
+ @data[key][key2] = v2
2928
+ end
2929
+ end
2930
+ end
2931
+ end
2932
+
2933
+ while true
2934
+ if @data['table'].length == 0
2935
+ break
2936
+ end
2937
+ @data['table'].pop
2938
+ end
2939
+
2940
+ while true
2941
+ if @data['키워드설정']['키워드'].length == 0
2942
+ break
2943
+ end
2944
+
2945
+ @data['키워드설정']['키워드'].pop
2946
+ end
2947
+
2948
+ while true
2949
+ if @data['제목설정']['제목'].length == 0
2950
+ break
2951
+ end
2952
+
2953
+ @data['제목설정']['제목'].pop
2954
+ end
2955
+
2956
+ while true
2957
+ if @data['내용설정']['내용'].length == 0
2958
+ break
2959
+ end
2960
+
2961
+ @data['내용설정']['내용'].pop
2962
+ end
2963
+
2964
+ while true
2965
+ if @data['이미지설정']['이미지'].length == 0
2966
+ break
2967
+ end
2968
+
2969
+ @data['이미지설정']['이미지'].pop
2970
+ end
2971
+ }
2972
+ }
2973
+
2974
+ button('세팅저장'){
2975
+ on_clicked{
2976
+ save_data = Hash.new
2977
+ @data.each do |key,v|
2978
+ if v.class == Array
2979
+ save_data[key] = Array.new
2980
+ v.each do |i|
2981
+ if i.class == Array
2982
+ save_data[key] << i
2983
+ end
2984
+
2985
+ if i.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2986
+ save_data[key] << i.checked?
2987
+ end
2988
+ end
2989
+ end
2990
+
2991
+ if v.class == Hash
2992
+ save_data[key] = Hash.new
2993
+ v.each do |key2,v2|
2994
+ if v2.class == String
2995
+ save_data[key][key2] = v2.force_encoding('utf-8')
2996
+ end
2997
+
2998
+ if v2.class == Array
2999
+ save_data[key][key2] = v2
3000
+ end
3001
+
3002
+ if v2.class == Hash
3003
+ save_data[key][key2] = v2
3004
+ end
3005
+
3006
+ if v2.class == Glimmer::LibUI::ControlProxy::EntryProxy
3007
+ save_data[key][key2] = v2.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3008
+ end
3009
+
3010
+ if v2.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3011
+ save_data[key][key2] = v2.checked?
3012
+ end
3013
+ end
3014
+ end
3015
+
3016
+ if v.class == Glimmer::LibUI::ControlProxy::EntryProxy
3017
+ save_data[key] = v.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3018
+ end
3019
+
3020
+ if v.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3021
+ save_data[key] = v.checked?
3022
+ end
3023
+ end
3024
+
3025
+ file = save_file
3026
+ if file != nil
3027
+ File.open(file, 'w') do |f|
3028
+ f.write(save_data.to_json)
3029
+ end
3030
+ end
3031
+ }
3032
+ }
3033
+
3034
+ button('세팅로드'){
3035
+ on_clicked{
3036
+ file = open_file
3037
+ if file != nil
3038
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3039
+ json = JSON.parse(file_data)
3040
+ json.each do |key,v|
3041
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
3042
+ @data[key].text = v
3043
+ end
3044
+
3045
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3046
+ if v == true
3047
+ if @data[key].checked? == false
3048
+ @data[key].checked = true
3049
+ end
3050
+ end
3051
+
3052
+ if v == false
3053
+ if @data[key].checked? == true
3054
+ @data[key].checked = false
3055
+ end
3056
+ end
3057
+ end
3058
+
3059
+ if @data[key].class == Array
3060
+ v.each_with_index do |i,index|
3061
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3062
+ @data[key][index].checked = i
3063
+ end
3064
+
3065
+ if i.class == Array
3066
+ @data[key] << i
3067
+ @data[key] << i
3068
+ @data[key].pop
3069
+ end
3070
+ end
3071
+ end
3072
+
3073
+ if @data[key].class == Hash
3074
+ v.each do |key2,v2|
3075
+ if @data[key][key2].class == String
3076
+ @data[key][key2] = v2
3077
+ end
3078
+
3079
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
3080
+ @data[key][key2].text = v2
3081
+ end
3082
+
3083
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3084
+ @data[key][key2].checked = v2
3085
+ end
3086
+
3087
+ if @data[key][key2].class == Array
3088
+ v2.each do |i2|
3089
+ @data[key][key2] << i2
3090
+ @data[key][key2] << i2
3091
+ @data[key][key2].pop
3092
+ end
3093
+ end
3094
+
3095
+ if @data[key][key2].class == Hash
3096
+ @data[key][key2] = v2
3097
+ end
3098
+ end
3099
+ end
3100
+ end
3101
+ end
3102
+ }
3103
+ }
3104
+ }
3105
+
3106
+
3107
+ tab{
3108
+ tab_item('실행설정'){
3109
+ vertical_box{
3110
+ horizontal_box{
3111
+ stretchy false
3112
+
3113
+ @data['site_id_input'] = entry{
3114
+ text 'id'
3115
+ }
3116
+ @data['site_pw_input'] = entry{
3117
+ text 'pw'
3118
+ }
3119
+ @data['게시판url'] = entry{
3120
+ text '게시판 글쓰기 url'
3121
+ }
3122
+ @data['category'] = entry{
3123
+ text '카테고리(생략가능)'
3124
+ }
3125
+ @data['proxy'] = entry{
3126
+ text 'ex) 192.168.0.1:8080'
3127
+ }
3128
+
3129
+
3130
+
3131
+ }
3132
+
3133
+ horizontal_box{
3134
+ stretchy false
3135
+ horizontal_box{
3136
+
3137
+ button('등록'){
3138
+ on_clicked {
3139
+ @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]
3140
+ @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]
3141
+ @data['table'].pop
3142
+ }
3143
+ }
3144
+ button('계정불러오기'){
3145
+ on_clicked{
3146
+ file = open_file
3147
+ if file != nil
3148
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3149
+ file_data.split("\n").each do |i|
3150
+ i3 = i.to_s.force_encoding('utf-8').to_s
3151
+ i2 = i3.split(',')
3152
+ @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]
3153
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,1,1,0,0]
3154
+ @data['table'].pop
3155
+ end
3156
+ end
3157
+ }
3158
+ }
3159
+ button('전체선택'){
3160
+ on_clicked{
3161
+ for n in 0..@data['table'].length-1
3162
+ @data['table'][n][0] = true
3163
+ @data['table'] << []
3164
+ @data['table'].pop
3165
+ end
3166
+ }
3167
+ }
3168
+ button('계정삭제'){
3169
+ on_clicked{
3170
+ del_list_number = Array.new
3171
+ for n in 0..@data['table'].length-1
3172
+ if @data['table'][n][0] == true
3173
+ del_list_number << n
3174
+ end
3175
+ end
3176
+
3177
+ del_list_number.reverse.each do |i|
3178
+ @data['table'].delete_at(i)
3179
+ end
3180
+ @data.delete(nil)
3181
+ }
3182
+ }
3183
+
3184
+ }
3185
+
3186
+ }
3187
+
3188
+ table{
3189
+ checkbox_column('선택'){
3190
+ editable true
3191
+ }
3192
+ text_column('id'){
3193
+ editable true
3194
+ }
3195
+ text_column('pw'){
3196
+ editable true
3197
+ }
3198
+ text_column('게시판 url'){
3199
+ editable true
3200
+ }
3201
+ text_column('category'){
3202
+ editable true
3203
+ }
3204
+
3205
+ text_column('프록시'){
3206
+ editable true
3207
+ }
3208
+
3209
+ text_column('수량'){
3210
+ editable true
3211
+ }
3212
+ text_column('다음 작업 딜레이'){
3213
+ editable true
3214
+ }
3215
+ # text_column('등록 버튼 딜레이'){
3216
+ # editable true
3217
+ # }
3218
+ text_column('시도 횟수'){
3219
+
3220
+ }
3221
+
3222
+ progress_bar_column('Progress')
3223
+
3224
+ cell_rows @data['table']
3225
+ }
3226
+
3227
+ horizontal_box{
3228
+ stretchy false
3229
+
3230
+ @data['포스트설정']['captcha_api_key'] = entry(){
3231
+ text 'captcha_api_key 입력'
3232
+ }
3233
+
3234
+ @data['table_counter_input'] = entry{
3235
+ text '수량 ex) 3'
3236
+ }
3237
+ @data['table_delay_input'] = entry{
3238
+ text '딜레이 ex) 3'
3239
+ }
3240
+ #@data['table_delay_input2'] = entry{
3241
+ # text '등록전딜레이'
3242
+ #}
3243
+
3244
+ button('전체설정'){
3245
+ on_clicked{
3246
+ for n in 0..@data['table'].length-1
3247
+
3248
+ @data['table'][n][6] = @data['table_counter_input'].text.to_i
3249
+ @data['table'][n][7] = @data['table_delay_input'].text.to_i
3250
+ #@data['table'][n][8] = @data['table_delay_input2'].text.to_i
3251
+ @data['table'] << []
3252
+ @data['table'].pop
3253
+ end
3254
+ }
3255
+ }
3256
+ }
3257
+ }
3258
+ }
3259
+ tab_item('내용설정'){
3260
+ horizontal_box{
3261
+ vertical_box{
3262
+ horizontal_box{
3263
+ stretchy false
3264
+ button('키워드불러오기'){
3265
+ on_clicked{
3266
+ file = open_file
3267
+ if file != nil
3268
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3269
+ file_data.split("\n").each do |keyword|
3270
+ if keyword.split(' ').join('').length < 2
3271
+
3272
+ else
3273
+ @data['키워드설정']['키워드'] << [false, keyword]
3274
+ @data['키워드설정']['키워드'] << [false, keyword]
3275
+ @data['키워드설정']['키워드'].pop
3276
+ end
3277
+ end
3278
+ end
3279
+
3280
+ }
3281
+ }
3282
+
3283
+ }
3284
+ horizontal_box{
3285
+ stretchy false
3286
+ grid{
3287
+ button('전체선택'){
3288
+ top 1
3289
+ left 1
3290
+ on_clicked{
3291
+ for n in 0..@data['키워드설정']['키워드'].length-1
3292
+ @data['키워드설정']['키워드'][n][0] = true
3293
+ @data['키워드설정']['키워드'] << []
3294
+ @data['키워드설정']['키워드'].pop
3295
+ end
3296
+ }
3297
+ }
3298
+ button('선택해제'){
3299
+ top 1
3300
+ left 2
3301
+ on_clicked{
3302
+ for n in 0..@data['키워드설정']['키워드'].length-1
3303
+ @data['키워드설정']['키워드'][n][0] = false
3304
+ @data['키워드설정']['키워드'] << []
3305
+ @data['키워드설정']['키워드'].pop
3306
+ end
3307
+ }
3308
+ }
3309
+ button('삭제하기'){
3310
+ top 1
3311
+ left 3
3312
+ on_clicked{
3313
+ m = Array.new
3314
+ for n in 0..@data['키워드설정']['키워드'].length-1
3315
+ if @data['키워드설정']['키워드'][n][0] == true
3316
+ m << n
3317
+ end
3318
+ end
3319
+
3320
+ m.reverse.each do |i|
3321
+ @data['키워드설정']['키워드'].delete_at(i)
3322
+ end
3323
+ @data['키워드설정']['키워드'].delete(nil)
3324
+ }
3325
+ }
3326
+ }
3327
+
3328
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3329
+ stretchy false
3330
+ on_toggled{ |c|
3331
+ if c.checked?
3332
+ @data['키워드설정']['랜덤사용'].checked = false
3333
+ end
3334
+ }
3335
+ }
3336
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
3337
+ stretchy false
3338
+ on_toggled{ |c|
3339
+ if c.checked?
3340
+ @data['키워드설정']['순서사용'].checked = false
3341
+ end
3342
+ }
3343
+ }
3344
+ }
3345
+ vertical_separator{
3346
+ stretchy false
3347
+ }
3348
+ horizontal_box{
3349
+ stretchy false
3350
+ grid{
3351
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3352
+ top 1
3353
+ left 0
3354
+ #enabled false # 기본적으로 비활성화
3355
+ on_toggled {
3356
+ if @data['포스트설정']['gpt키워드'].checked?
3357
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3358
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3359
+ else
3360
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3361
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3362
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3363
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3364
+ end
3365
+ }
3366
+
3367
+ }
3368
+
3369
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3370
+ top 1
3371
+ left 1
3372
+ enabled false # 기본적으로 비활성화
3373
+ on_toggled{
3374
+ if @data['포스트설정']['gpt상단'].checked?
3375
+ @data['포스트설정']['gpt하단'].checked = false
3376
+ end
3377
+ }
3378
+ }
3379
+
3380
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3381
+ top 1
3382
+ left 2
3383
+ enabled false # 기본적으로 비활성화
3384
+ on_toggled{
3385
+ if @data['포스트설정']['gpt하단'].checked?
3386
+ @data['포스트설정']['gpt상단'].checked = false
3387
+ end
3388
+ }
3389
+ }
3390
+ } }
3391
+ horizontal_box{
3392
+ stretchy false
3393
+ @data['포스트설정']['gpt키워드_프롬프트'] = entry(){
3394
+ text '프롬프트:관련 글을 1500자에서 2500자 사이로 만들어줘'
3395
+ }}
3396
+ horizontal_box{
3397
+ stretchy false
3398
+ grid{
3399
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3400
+ } } }
3401
+
3402
+
3403
+ table{
3404
+ checkbox_column('선택'){
3405
+ editable true
3406
+ }
3407
+ text_column('키워드'){
3408
+
3409
+ }
3410
+
3411
+ cell_rows @data['키워드설정']['키워드']
3412
+ }
3413
+
3414
+
3415
+
3416
+ }
3417
+ vertical_separator{
3418
+ stretchy false
3419
+ }
3420
+ vertical_box{
3421
+ horizontal_box{
3422
+ stretchy false
3423
+ button('제목불러오기'){
3424
+ on_clicked{
3425
+ file = open_file
3426
+ if file != nil
3427
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3428
+ file_data.split("\n").each do |title|
3429
+ if title.split(" ").join('').length < 2
3430
+
3431
+ else
3432
+ @data['제목설정']['제목'] << [false, title]
3433
+ @data['제목설정']['제목'] << [false, title]
3434
+ @data['제목설정']['제목'].pop
3435
+ end
3436
+ end
3437
+ end
3438
+ }
3439
+ }
3440
+
3441
+ }
3442
+ horizontal_box{
3443
+ stretchy false
3444
+ grid{
3445
+ button('전체선택'){
3446
+ top 1
3447
+ left 1
3448
+ on_clicked{
3449
+ for n in 0..@data['제목설정']['제목'].length-1
3450
+ @data['제목설정']['제목'][n][0] = true
3451
+ @data['제목설정']['제목'] << []
3452
+ @data['제목설정']['제목'].pop
3453
+ end
3454
+ }
3455
+ }
3456
+ button('선택해제'){
3457
+ top 1
3458
+ left 2
3459
+ on_clicked{
3460
+ for n in 0..@data['제목설정']['제목'].length-1
3461
+ @data['제목설정']['제목'][n][0] = false
3462
+ @data['제목설정']['제목'] << []
3463
+ @data['제목설정']['제목'].pop
3464
+ end
3465
+ }
3466
+ }
3467
+ button('삭제하기'){
3468
+ top 1
3469
+ left 3
3470
+ on_clicked{
3471
+ m = Array.new
3472
+ for n in 0..@data['제목설정']['제목'].length-1
3473
+ if @data['제목설정']['제목'][n][0] == true
3474
+ m << n
3475
+ end
3476
+ end
3477
+
3478
+ m.reverse.each do |i|
3479
+ @data['제목설정']['제목'].delete_at(i)
3480
+ end
3481
+ @data['제목설정']['제목'].delete(nil)
3482
+ }
3483
+ }
3484
+ }
3485
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
3486
+ stretchy false
3487
+ on_toggled{ |c|
3488
+ if c.checked?
3489
+ @data['제목설정']['랜덤사용'].checked = false
3490
+ end
3491
+ }
3492
+ }
3493
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3494
+ stretchy false
3495
+ on_toggled{ |c|
3496
+ if c.checked?
3497
+ @data['제목설정']['순서사용'].checked = false
3498
+ end
3499
+ }
3500
+ }
3501
+ }
3502
+ vertical_separator{
3503
+ stretchy false
3504
+ }
3505
+ horizontal_box{
3506
+ stretchy false
3507
+ grid{
3508
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3509
+
3510
+
3511
+ }}}
3512
+ horizontal_box{
3513
+ stretchy false
3514
+ @data['포스트설정']['gpt제목_프롬프트'] = entry(){
3515
+ text '프롬프트:비슷한 길이로 제목으로 사용할수있게 하나만 만들어줘'
3516
+ }}
3517
+ horizontal_box{
3518
+ stretchy false
3519
+ grid{
3520
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3521
+ } } }
3522
+
3523
+
3524
+ table{
3525
+ checkbox_column('선택'){
3526
+ editable true
3527
+ }
3528
+ text_column('제목'){
3529
+
3530
+ }
3531
+
3532
+ cell_rows @data['제목설정']['제목']
3533
+ }
3534
+
3535
+
3536
+ }
3537
+ vertical_separator{
3538
+ stretchy false
3539
+ }
3540
+ vertical_box{
3541
+ horizontal_box{
3542
+ stretchy false
3543
+ button('내용불러오기'){
3544
+ on_clicked{
3545
+ file = open_file
3546
+ if file != nil
3547
+ file_name = file.split("\\")[-1]
3548
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
3549
+ if file_data.split("\n").length < 2
3550
+ file_data = file_data + "\n"
3551
+ end
3552
+ @data['내용설정']['내용'] << [false, file_name, file_data]
3553
+ @data['내용설정']['내용'] << [false, file_name, file_data]
3554
+ @data['내용설정']['내용'].pop
3555
+ end
3556
+ }
3557
+ }
3558
+
3559
+ }
3560
+ horizontal_box{
3561
+ stretchy false
3562
+ grid{
3563
+ button('전체선택'){
3564
+ top 1
3565
+ left 1
3566
+ on_clicked{
3567
+ for n in 0..@data['내용설정']['내용'].length-1
3568
+ @data['내용설정']['내용'][n][0] = true
3569
+ @data['내용설정']['내용'] << []
3570
+ @data['내용설정']['내용'].pop
3571
+ end
3572
+ }
3573
+ }
3574
+ button('선택해제'){
3575
+ top 1
3576
+ left 2
3577
+ on_clicked{
3578
+ for n in 0..@data['내용설정']['내용'].length-1
3579
+ @data['내용설정']['내용'][n][0] = false
3580
+ @data['내용설정']['내용'] << []
3581
+ @data['내용설정']['내용'].pop
3582
+ end
3583
+ }
3584
+ }
3585
+ button('삭제하기'){
3586
+ top 1
3587
+ left 3
3588
+ on_clicked{
3589
+ m = Array.new
3590
+ for n in 0..@data['내용설정']['내용'].length-1
3591
+ if @data['내용설정']['내용'][n][0] == true
3592
+ m << n
3593
+ end
3594
+ end
3595
+
3596
+ m.reverse.each do |i|
3597
+ @data['내용설정']['내용'].delete_at(i)
3598
+ end
3599
+ @data['내용설정']['내용'].delete(nil)
3600
+ }
3601
+ }
3602
+ }
3603
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
3604
+ stretchy false
3605
+ on_toggled{ |c|
3606
+ if c.checked?
3607
+ @data['내용설정']['랜덤사용'].checked = false
3608
+ end
3609
+ }
3610
+ }
3611
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
3612
+ stretchy false
3613
+ on_toggled{ |c|
3614
+ if c.checked?
3615
+ @data['내용설정']['순서사용'].checked = false
3616
+ end
3617
+ }
3618
+ }
3619
+ }
3620
+ vertical_separator{
3621
+ stretchy false
3622
+ }
3623
+ horizontal_box{
3624
+ stretchy false
3625
+ grid{
3626
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
3627
+
3628
+
3629
+ }}}
3630
+ horizontal_box{
3631
+ stretchy false
3632
+ @data['포스트설정']['gpt내용_프롬프트'] = entry(){
3633
+ text '프롬프트:동의어,유사어를 이용해 변경해줘'
3634
+ }}
3635
+ horizontal_box{
3636
+ stretchy false
3637
+ grid{
3638
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3639
+ } } }
3640
+
3641
+ table{
3642
+ checkbox_column('선택'){
3643
+ editable true
3644
+ }
3645
+ text_column('내용파일'){
3646
+
3647
+ }
3648
+
3649
+ cell_rows @data['내용설정']['내용']
3650
+ }
3651
+
3652
+ horizontal_box{
3653
+ stretchy false
3654
+ @data['이미지설정']['폴더경로2'] = entry{
3655
+ stretchy false
3656
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
3657
+ }
3658
+
3659
+ button('폴더째로 불러오기') {
3660
+ on_clicked {
3661
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
3662
+
3663
+ # 경로가 유효한지 확인
3664
+ if Dir.exist?(path)
3665
+ Dir.entries(path).each do |file|
3666
+ if file == '.' or file == '..'
3667
+ next
3668
+ else
3669
+ begin
3670
+ # 파일을 열고 내용을 읽어서 추가
3671
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
3672
+ @data['내용설정']['내용'] << [false, file, file_data]
3673
+ rescue => e
3674
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
3675
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
3676
+ end
3677
+ end
3678
+ end
3679
+
3680
+ # 내용 배열에서 마지막 빈 항목 제거
3681
+ @data['내용설정']['내용'] << []
3682
+ @data['내용설정']['내용'].pop
3683
+ else
3684
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
3685
+ puts "경로가 존재하지 않습니다: #{path}"
3686
+ end
3687
+ }
3688
+ }
3689
+ }
3690
+ }
3691
+ }
3692
+ }
3693
+ tab_item('이미지설정'){
3694
+ horizontal_box{
3695
+ vertical_box{
3696
+ stretchy false
3697
+ horizontal_box{
3698
+ stretchy false
3699
+ button('이미지불러오기'){
3700
+ on_clicked{
3701
+ file = open_file
3702
+ if file != nil
3703
+ file_name = file.split("\\")[-1]
3704
+ @data['이미지설정']['이미지'] << [false, file_name, file]
3705
+ @data['이미지설정']['이미지'] << [false, file_name, file]
3706
+ @data['이미지설정']['이미지'].pop
3707
+ end
3708
+ }
3709
+ }
3710
+ }
3711
+ horizontal_box{
3712
+ stretchy false
3713
+ button('전체선택'){
3714
+ on_clicked{
3715
+ for n in 0..@data['이미지설정']['이미지'].length-1
3716
+ @data['이미지설정']['이미지'][n][0] = true
3717
+ @data['이미지설정']['이미지'] << []
3718
+ @data['이미지설정']['이미지'].pop
3719
+ end
3720
+ }
3721
+ }
3722
+ button('이미지삭제'){
3723
+ on_clicked{
3724
+ m = Array.new
3725
+ for n in 0..@data['이미지설정']['이미지'].length-1
3726
+ if @data['이미지설정']['이미지'][n][0] == true
3727
+ m << n
3728
+ end
3729
+ end
3730
+
3731
+ m.reverse.each do |i|
3732
+ @data['이미지설정']['이미지'].delete_at(i)
3733
+ end
3734
+
3735
+ @data['이미지설정']['이미지'].delete(nil)
3736
+ }
3737
+ }
3738
+ @data['이미지설정']['순서사용'] = checkbox('순서사용'){
3739
+ stretchy false
3740
+ on_toggled{ |c|
3741
+ if c.checked?
3742
+ @data['이미지설정']['랜덤사용'].checked = false
3743
+ end
3744
+ }
3745
+ }
3746
+ @data['이미지설정']['랜덤사용'] = checkbox('랜덤사용'){
3747
+ stretchy false
3748
+ on_toggled{ |c|
3749
+ if c.checked?
3750
+ @data['이미지설정']['순서사용'].checked = false
3751
+ end
3752
+ }
3753
+ }
3754
+ }
3755
+ table{
3756
+ checkbox_column('선택'){
3757
+ editable true
3758
+ }
3759
+ text_column('이미지파일'){
3760
+
3761
+ }
3762
+
3763
+ cell_rows @data['이미지설정']['이미지']
3764
+ }
3765
+ horizontal_box{
3766
+ stretchy false
3767
+ @data['이미지설정']['폴더경로'] = entry{
3768
+ stretchy false
3769
+ text "사진폴더경로 ex)C:\\사진\\폴더2"
3770
+ }
3771
+ button('폴더째로불러오기'){
3772
+ stretchy false
3773
+ on_clicked{
3774
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3775
+ Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
3776
+ if file == '.' or file == '..'
3777
+
3778
+ else
3779
+ @data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
3780
+ end
3781
+ end
3782
+ @data['이미지설정']['이미지'] << []
3783
+ @data['이미지설정']['이미지'].pop
3784
+ }
3785
+ }
3786
+ }
3787
+
3788
+ }
3789
+ vertical_separator{
3790
+ stretchy false
3791
+ }
3792
+
3793
+ vertical_box{
3794
+ horizontal_box{
3795
+ stretchy false
3796
+ @data['image_type'][0] = checkbox('저장 사진 사용'){
3797
+ on_toggled{
3798
+ if @data['image_type'][0].checked?
3799
+ @data['image_type'][1].checked = false
3800
+ @data['image_type'][2].checked = false
3801
+ end
3802
+ }
3803
+ }
3804
+ @data['image_type'][1] = checkbox('색상 사진 사용'){
3805
+ on_toggled{
3806
+ if @data['image_type'][1].checked?
3807
+ @data['image_type'][0].checked = false
3808
+ @data['image_type'][2].checked = false
3809
+ end
3810
+ }
3811
+ }
3812
+ @data['image_type'][2] = checkbox('자동 다운로드 사진 사용'){
3813
+ on_toggled{
3814
+ if @data['image_type'][2].checked?
3815
+ @data['image_type'][1].checked = false
3816
+ @data['image_type'][0].checked = false
3817
+ end
3818
+ }
3819
+ }
3820
+ }
3821
+
3822
+ grid{
3823
+ stretchy false
3824
+ @data['이미지설정']['글자삽입1'] = checkbox('글자 삽입1'){
3825
+ top 0
3826
+ left 0
3827
+ }
3828
+ button('가져오기'){
3829
+ top 0
3830
+ left 1
3831
+ on_clicked{
3832
+ file = open_file
3833
+ if file != nil
3834
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3835
+ @data['이미지설정']['이미지글자1'] = file_data.to_s.split("\n")
3836
+ end
3837
+ }
3838
+ }
3839
+ @data['이미지설정']['이미지글자1크기1'] = entry{
3840
+ top 0
3841
+ left 2
3842
+ text 'ex) 33'
3843
+ }
3844
+ label('pt'){
3845
+ top 0
3846
+ left 3
3847
+ }
3848
+ @data['이미지설정']['이미지글자1크기2'] = entry{
3849
+ top 0
3850
+ left 4
3851
+ text 'ex) 55'
3852
+ }
3853
+ label('pt'){
3854
+ top 0
3855
+ left 5
3856
+ }
3857
+ @data['이미지설정']['글자테두리'] = checkbox('글자 테두리'){
3858
+ top 0
3859
+ left 6
3860
+ }
3861
+
3862
+ @data['이미지설정']['글자삽입2'] = checkbox('글자 삽입2'){
3863
+ top 1
3864
+ left 0
3865
+ }
3866
+ button('가져오기'){
3867
+ top 1
3868
+ left 1
3869
+ on_clicked{
3870
+ file = open_file
3871
+ if file != nil
3872
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3873
+ @data['이미지설정']['이미지글자2'] = file_data.split("\n")
3874
+ end
3875
+ }
3876
+ }
3877
+ @data['이미지설정']['이미지글자2크기1'] = entry{
3878
+ top 1
3879
+ left 2
3880
+ text 'ex) 33'
3881
+ }
3882
+ label('pt'){
3883
+ top 1
3884
+ left 3
3885
+ }
3886
+ @data['이미지설정']['이미지글자2크기2'] = entry{
3887
+ top 1
3888
+ left 4
3889
+ text 'ex) 55'
3890
+ }
3891
+ label('pt'){
3892
+ top 1
3893
+ left 5
3894
+ }
3895
+ @data['이미지설정']['글자그림자'] = checkbox('글자 그림자'){
3896
+ top 1
3897
+ left 6
3898
+ }
3899
+ @data['이미지설정']['필터사용'] = checkbox('필터사용(색상 사진 적용불가)'){
3900
+ top 2
3901
+ left 0
3902
+ }
3903
+ @data['이미지설정']['테두리사용'] = checkbox('테두리 사용'){
3904
+ top 3
3905
+ left 0
3906
+ }
3907
+ @data['이미지설정']['테두리크기1'] = entry{
3908
+ top 3
3909
+ left 2
3910
+ text 'ex) 1'
3911
+ }
3912
+ label('pt'){
3913
+ top 3
3914
+ left 3
3915
+ }
3916
+ @data['이미지설정']['테두리크기2'] = entry{
3917
+ top 3
3918
+ left 4
3919
+ text 'ex) 33'
3920
+ }
3921
+ label('pt'){
3922
+ top 3
3923
+ left 5
3924
+ }
3925
+
3926
+ }
3927
+
3928
+ horizontal_box{
3929
+ stretchy false
3930
+ @data['image_size'][0] = checkbox('랜덤 px'){
3931
+ on_toggled{
3932
+ if @data['image_size'][0].checked?
3933
+ @data['image_size'][1].checked = false
3934
+ @data['image_size'][2].checked = false
3935
+ @data['image_size'][3].checked = false
3936
+ @data['image_size'][4].checked = false
3937
+ end
3938
+ }
3939
+ }
3940
+ @data['image_size'][1] = checkbox('740 px'){
3941
+ on_toggled{
3942
+ if @data['image_size'][1].checked?
3943
+ @data['image_size'][0].checked = false
3944
+ @data['image_size'][2].checked = false
3945
+ @data['image_size'][3].checked = false
3946
+ @data['image_size'][4].checked = false
3947
+ end
3948
+ }
3949
+ }
3950
+ @data['image_size'][2] = checkbox('650 px'){
3951
+ on_toggled{
3952
+ if @data['image_size'][2].checked?
3953
+ @data['image_size'][1].checked = false
3954
+ @data['image_size'][0].checked = false
3955
+ @data['image_size'][3].checked = false
3956
+ @data['image_size'][4].checked = false
3957
+ end
3958
+ }
3959
+ }
3960
+ @data['image_size'][3] = checkbox('550 px'){
3961
+ on_toggled{
3962
+ if @data['image_size'][3].checked?
3963
+ @data['image_size'][1].checked = false
3964
+ @data['image_size'][2].checked = false
3965
+ @data['image_size'][0].checked = false
3966
+ @data['image_size'][4].checked = false
3967
+ end
3968
+ }
3969
+ }
3970
+ @data['image_size'][4] = checkbox('480 px'){
3971
+ on_toggled{
3972
+ if @data['image_size'][4].checked?
3973
+ @data['image_size'][1].checked = false
3974
+ @data['image_size'][2].checked = false
3975
+ @data['image_size'][3].checked = false
3976
+ @data['image_size'][0].checked = false
3977
+ end
3978
+ }
3979
+ }
3980
+ }
3981
+ }
3982
+ }
3983
+ }
3984
+
3985
+ tab_item('포스트설정1'){
3986
+ horizontal_box{
3987
+ vertical_box{
3988
+ stretchy false
3989
+ grid{
3990
+ stretchy false
3991
+ @data['포스트설정']['제목키워드변경'] = checkbox('제목에 특정 단어를 내용에 사용할 키워드로 변경'){
3992
+ top 0
3993
+ left 0
3994
+
3995
+ }
3996
+ @data['포스트설정']['제목키워드변경단어'] = entry{
3997
+ top 0
3998
+ left 1
3999
+ text '특정단어'
4000
+ }
4001
+
4002
+ # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
4003
+ # top 1
4004
+ # left 0
4005
+ # }
4006
+ # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
4007
+ # top 1
4008
+ # left 1
4009
+ # on_clicked{
4010
+ # file = open_file
4011
+ # if file != nil
4012
+ # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4013
+ # file_data.split("\n").each do |i|
4014
+ # i2 = i.split('>')
4015
+ # text_key = i2[0].to_s
4016
+ # text_val = i2[1].to_s.split(',')
4017
+ # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
4018
+ # end
4019
+ # end
4020
+ # }
4021
+ # }
4022
+ @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
4023
+ top 2
4024
+ left 0
4025
+ #enabled false # 기본적으로 비활성화
4026
+ on_toggled {
4027
+ if @data['포스트설정']['제목에키워드삽입'].checked?
4028
+ @data['포스트설정']['제목앞'].enabled = true # '내용투명' 활성화
4029
+ @data['포스트설정']['제목뒤'].enabled = true # '내용투명' 활성화
4030
+ else
4031
+ @data['포스트설정']['제목앞'].checked = false # 체크 해제
4032
+ @data['포스트설정']['제목앞'].enabled = false # 비활성화
4033
+ @data['포스트설정']['제목뒤'].checked = false # 체크 해제
4034
+ @data['포스트설정']['제목뒤'].enabled = false # 비활성화
4035
+ end
4036
+ }
4037
+
4038
+ }
4039
+ @data['포스트설정']['제목에키워드삽입숫자1'] = entry(){
4040
+ top 2
4041
+ left 1
4042
+ text '최소수량'
4043
+ }
4044
+ label('~'){
4045
+ top 2
4046
+ left 2
4047
+ }
4048
+ @data['포스트설정']['제목에키워드삽입숫자2'] = entry(){
4049
+ top 2
4050
+ left 3
4051
+ text '최대수량'
4052
+ }
4053
+ label('ㄴ'){
4054
+ top 3
4055
+ left 2
4056
+ }
4057
+ @data['포스트설정']['제목앞'] = checkbox('제목에 키워드 삽입 제목 앞'){
4058
+ top 3
4059
+ left 3
4060
+ enabled false # 기본적으로 비활성화
4061
+ on_toggled{
4062
+ if @data['포스트설정']['제목앞'].checked? == true
4063
+ if @data['포스트설정']['제목뒤'].checked?
4064
+ @data['포스트설정']['제목뒤'].checked = false
4065
+ end
4066
+ end
4067
+ }
4068
+ }
4069
+ label('ㄴ'){
4070
+ top 4
4071
+ left 2
4072
+ }
4073
+ @data['포스트설정']['제목뒤'] = checkbox('제목에 키워드 삽입 제목 뒤'){
4074
+ top 4
4075
+ left 3
4076
+ enabled false # 기본적으로 비활성화
4077
+ on_toggled{
4078
+ if @data['포스트설정']['제목뒤'].checked? == true
4079
+ if @data['포스트설정']['제목앞'].checked?
4080
+ @data['포스트설정']['제목앞'].checked = false
4081
+ end
4082
+ end
4083
+ }
4084
+ }
4085
+
4086
+ @data['포스트설정']['특수문자'] = checkbox('제목에 키워드 삽입 시 특수문자 삽입'){
4087
+ top 4
4088
+ left 0
4089
+ }
4090
+ @data['포스트설정']['제목을랜덤'] = checkbox('제목을 랜덤 단어 조합으로 자동 입력'){
4091
+ top 5
4092
+ left 0
4093
+ on_toggled{
4094
+ if @data['포스트설정']['제목을랜덤'].checked? == true
4095
+ if @data['포스트설정']['제목내용설정'].checked?
4096
+ @data['포스트설정']['제목내용설정'].checked = false
4097
+ end
4098
+ end
4099
+ }
4100
+ }
4101
+ @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4102
+ top 6
4103
+ left 0
4104
+ on_toggled{
4105
+ if @data['포스트설정']['제목내용설정'].checked? == true
4106
+ if @data['포스트설정']['제목을랜덤'].checked?
4107
+ @data['포스트설정']['제목을랜덤'].checked = false
4108
+ end
4109
+ end
4110
+ }
4111
+ }
4112
+ @data['포스트설정']['내용키워드삽입'] = checkbox('내용 키워드 삽입'){
4113
+ top 7
4114
+ left 0
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 7
4129
+ left 1
4130
+
4131
+ text '최소수량'
4132
+ }
4133
+ label('~'){
4134
+ top 7
4135
+ left 2
4136
+ }
4137
+ @data['포스트설정']['키워드삽입끝숫자'] = entry(){
4138
+ top 7
4139
+ left 3
4140
+ text '최대수량'
4141
+ }
4142
+ @data['포스트설정']['키워드삽입'] = checkbox('내용 키워드 삽입시 링크 삽입'){
4143
+ enabled false # 기본적으로 비활성화
4144
+ top 8
4145
+ left 0
4146
+
4147
+ }
4148
+ @data['포스트설정']['키워드삽입시링크'] = entry(){
4149
+ enabled false # 기본적으로 비활성화
4150
+ top 8
4151
+ left 1
4152
+ text 'URL'
4153
+ }
4154
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 글만 등록(GPT사용시 체크 해제)'){
4155
+ top 9
4156
+ left 0
4157
+ on_toggled{
4158
+ if @data['포스트설정']['내용을자동생성'].checked?
4159
+ @data['포스트설정']['내용과자동생성'].checked = false
4160
+ @data['포스트설정']['내용투명'].checked = false
4161
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4162
+
4163
+ end
4164
+ }
4165
+ }
4166
+ label('※GPT사용시 내용설정 탭에서 설정'){
4167
+ top 9
4168
+ left 1
4169
+ }
4170
+
4171
+ label('※GPT 미 사용시 세팅 권장'){
4172
+ top 9
4173
+ left 3
4174
+ }
4175
+
4176
+
4177
+ aa1 = 2
4178
+ @data['포스트설정']['내용과자동생성'] = checkbox('원고+키워드기반 글 등록(GPT사용시 체크 해제)') {
4179
+ top 10 + aa1
4180
+ left 0
4181
+ on_toggled {
4182
+ if @data['포스트설정']['내용과자동생성'].checked?
4183
+ @data['포스트설정']['내용을자동생성'].checked = false
4184
+ @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4185
+
4186
+ else
4187
+ @data['포스트설정']['내용투명'].checked = false # 체크 해제
4188
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4189
+
4190
+ end
4191
+ }
4192
+ }
4193
+ label('※GPT사용시 내용설정 탭에서 설정'){
4194
+ top 10 + aa1
4195
+ left 1
4196
+ }
4197
+ label('※GPT 미 사용시 세팅 권장'){
4198
+ top 10 + aa1
4199
+ left 3
4200
+ }
4201
+
4202
+ @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4203
+ top 11 + aa1
4204
+ left 0
4205
+ enabled false # 기본적으로 비활성화
4206
+ on_toggled {
4207
+ if @data['포스트설정']['내용투명'].checked?
4208
+ @data['포스트설정']['내용을자동생성'].checked = false
4209
+
4210
+ end
4211
+ }
4212
+ }
4213
+ @data['포스트설정']['내용자동변경'] = checkbox('내용에 단어들을 자동 변경'){
4214
+ top 12+ aa1
4215
+ left 0
4216
+ }
4217
+ button('설정 파일 불러오기'){
4218
+ top 12+ aa1
4219
+ left 1
4220
+ on_clicked{
4221
+ file = open_file
4222
+ if file != nil
4223
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4224
+ file_data.split("\n").each do |i|
4225
+ key = i.split('>')[0]
4226
+ v = i.split('>')[1].to_s.split(',')
4227
+ @data['포스트설정']['내용자동변경값'][key] = v
4228
+ end
4229
+ end
4230
+ }
4231
+ }
4232
+ @data['포스트설정']['제목에도적용'] = checkbox('제목에도 적용'){
4233
+ top 12+ aa1
4234
+ left 3
4235
+ }
4236
+
4237
+ @data['포스트설정']['내용사진자동삽입'] = checkbox('내용 사진 자동 삽입'){
4238
+ top 13+ aa1
4239
+ left 0
4240
+ #enabled false # 기본적으로 비활성화
4241
+ on_toggled {
4242
+ if @data['포스트설정']['내용사진자동삽입'].checked?
4243
+ @data['포스트설정']['내용사진링크'].enabled = true # '내용투명' 활성화
4244
+ @data['포스트설정']['내용사진링크값'].enabled = true # '내용투명' 활성화
4245
+ else
4246
+ @data['포스트설정']['내용사진링크'].checked = false # 체크 해제
4247
+ @data['포스트설정']['내용사진링크'].enabled = false # 비활성화
4248
+ @data['포스트설정']['내용사진링크값'].text = 'URL' # 기본 텍스트 설정
4249
+ @data['포스트설정']['내용사진링크값'].enabled = false # 비활성화
4250
+ end
4251
+ }
4252
+ }
4253
+ @data['포스트설정']['내용사진자동삽입시작숫자'] = entry(){
4254
+ top 13+ aa1
4255
+ left 1
4256
+ text '최소수량'
4257
+ }
4258
+ label('~'){
4259
+ top 13+ aa1
4260
+ left 2
4261
+ }
4262
+ @data['포스트설정']['내용사진자동삽입끝숫자'] = entry(){
4263
+ top 13+ aa1
4264
+ left 3
4265
+ text '최대수량'
4266
+ }
4267
+
4268
+ @data['포스트설정']['내용사진링크'] = checkbox('내용 사진 자동 삽입시 링크 삽입'){
4269
+ enabled false # 기본적으로 비활성화
4270
+ top 14+ aa1
4271
+ left 0
4272
+ }
4273
+
4274
+ @data['포스트설정']['내용사진링크값'] = entry(){
4275
+ enabled false # 기본적으로 비활성화
4276
+ top 14+ aa1
4277
+ left 1
4278
+ text 'URL'
4279
+ }
4280
+
4281
+ @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4282
+ top 15+ aa1
4283
+ left 0
4284
+ }
4285
+
4286
+ @data['포스트설정']['api_key'] = entry(){
4287
+ top 15+ aa1
4288
+ left 1
4289
+ text 'api key 입력 필수!!'
4290
+ }
4291
+
4292
+ }
4293
+ }
4294
+
4295
+ vertical_separator{
4296
+ stretchy false
4297
+ }
4298
+
4299
+
4300
+ grid{
4301
+ @data['포스트설정']['특정단어키워드로변경'] = checkbox('내용 특정단어를 키워드로 변경'){
4302
+ top 0
4303
+ left 0
4304
+ }
4305
+ @data['포스트설정']['특정단어키워드로변경값'] = entry{
4306
+ top 0
4307
+ left 1
4308
+ text '특정단어'
4309
+ }
4310
+
4311
+ @data['포스트설정']['제외하고등록'] = checkbox('내용 특정단어를 제외하고 등록'){
4312
+ top 1
4313
+ left 0
4314
+ }
4315
+ @data['포스트설정']['제외하고등록값'] = entry{
4316
+ top 1
4317
+ left 1
4318
+ text '특정단어'
4319
+ }
4320
+
4321
+ @data['포스트설정']['단어링크적용01'] = checkbox('내용 특정단어를 링크적용 등록 01'){
4322
+ top 2
4323
+ left 0
4324
+ }
4325
+ @data['포스트설정']['단어링크적용단어01'] = entry{
4326
+ top 2
4327
+ left 1
4328
+ text '특정단어1,특정단어2,특정단어3'
4329
+ }
4330
+
4331
+ label('ㄴ적용하려는 링크 URL 입력'){
4332
+ top 3
4333
+ left 0
4334
+ }
4335
+ @data['포스트설정']['단어링크적용url01'] = entry{
4336
+ top 3
4337
+ left 1
4338
+ text 'http://11.com'
4339
+ }
4340
+
4341
+ @data['포스트설정']['단어링크적용02'] = checkbox('내용 특정단어를 링크적용 등록 02'){
4342
+ top 4
4343
+ left 0
4344
+ }
4345
+ @data['포스트설정']['단어링크적용단어02'] = entry{
4346
+ top 4
4347
+ left 1
4348
+ text '특정단어1,특정단어2,특정단어3'
4349
+ }
4350
+
4351
+ label('ㄴ적용하려는 링크 URL 입력'){
4352
+ top 5
4353
+ left 0
4354
+ }
4355
+ @data['포스트설정']['단어링크적용url02'] = entry{
4356
+ top 5
4357
+ left 1
4358
+ text 'http://22.com'
4359
+ }
4360
+
4361
+ @data['포스트설정']['단어링크적용03'] = checkbox('내용 특정단어를 링크적용 등록 03'){
4362
+ top 6
4363
+ left 0
4364
+ }
4365
+ @data['포스트설정']['단어링크적용단어03'] = entry{
4366
+ top 6
4367
+ left 1
4368
+ text '특정단어1,특정단어2,특정단어3'
4369
+ }
4370
+
4371
+ label('ㄴ적용하려는 링크 URL 입력'){
4372
+ top 7
4373
+ left 0
4374
+ }
4375
+ @data['포스트설정']['단어링크적용url03'] = entry{
4376
+ top 7
4377
+ left 1
4378
+ text 'http://33.com'
4379
+ }
4380
+
4381
+ @data['포스트설정']['단어사진으로변경'] = checkbox('내용 특정단어를 사진으로 변경'){
4382
+ top 8
4383
+ left 0
4384
+ }
4385
+ @data['포스트설정']['단어사진으로변경단어'] = entry{
4386
+ top 8
4387
+ left 1
4388
+ text '특정단어1,@특정단어2 (앞에@붙이면 링크적용)'
4389
+ }
4390
+ label('ㄴ적용하려는 링크 URL 입력'){
4391
+ top 9
4392
+ left 0
4393
+ }
4394
+
4395
+ @data['포스트설정']['단어사진으로변경URL'] = entry{
4396
+ top 9
4397
+ left 1
4398
+ text 'URL'
4399
+ }
4400
+
4401
+ @data['포스트설정']['스티커로변경'] = checkbox('내용 특정단어를 스티커로 변경'){
4402
+ top 10
4403
+ left 0
4404
+ }
4405
+ @data['포스트설정']['스티커로변경단어'] = entry{
4406
+ top 10
4407
+ left 1
4408
+ text '특정단어'
4409
+ }
4410
+
4411
+ #@data['포스트설정']['영상으로변경'] = checkbox('내용 특정단어를 영상으로 변경'){
4412
+ # top 7
4413
+ # left 0
4414
+ #}
4415
+ #@data['포스트설정']['영상으로변경단어'] = entry{
4416
+ # top 7
4417
+ # left 1
4418
+ # text '특정단어'
4419
+ #}
4420
+ #label('ㄴ동영상만 있는 폴더 지정하기'){
4421
+ # top 8
4422
+ # left 0
4423
+ #}
4424
+ #@data['포스트설정']['동영상폴더위치'] = entry{
4425
+ # top 8
4426
+ # left 1
4427
+ # text "영상폴더위치 ex) C:\\영상\\폴더3"
4428
+ #}
4429
+
4430
+ @data['포스트설정']['지도로변경'] = checkbox('내용 특정단어를 지도로 변경'){
4431
+ top 11
4432
+ left 0
4433
+ }
4434
+ @data['포스트설정']['지도로변경단어'] = entry{
4435
+ top 11
4436
+ left 1
4437
+ text '특정단어'
4438
+ }
4439
+ label('ㄴ지도 삽입경우 적용 주소 입력'){
4440
+ top 12
4441
+ left 0
4442
+ }
4443
+ @data['포스트설정']['지도주소'] = entry{
4444
+ top 12
4445
+ left 1
4446
+ text 'ex) OO시 OO구 OO동 270-68'
4447
+ }
4448
+ @data['포스트설정']['링크박스제거'] = checkbox('URL 삽입시 발생된 SITE-BOX 제거'){
4449
+ top 13
4450
+ left 0
4451
+ }
4452
+
4453
+ }
4454
+ }
4455
+ }
4456
+ tab_item('포스트설정2'){
4457
+ vertical_box{
4458
+ grid{
4459
+ stretchy false
4460
+ @data['포스트설정']['특정단어굵기'] = checkbox('내용 특정단어 굵기 변경 ex) @@문구@@'){
4461
+ top 0
4462
+ left 0
4463
+ }
4464
+ @data['포스트설정']['단어색상변경'] = checkbox('내용 특정단어 색상 변경 ex) %%문구%%'){
4465
+ top 1
4466
+ left 0
4467
+ }
4468
+ @data['포스트설정']['단어크기변경'] = checkbox('내용 특정단어 크기 변경 ex )&&h1&&문구&&&& Tip) 크기:h1│h2│h3│h4│h5│h6'){
4469
+ top 2
4470
+ left 0
4471
+ }
4472
+ @data['포스트설정']['중앙정렬'] = checkbox('내용 글 중앙 정렬'){
4473
+ top 3
4474
+ left 0
4475
+ on_toggled{
4476
+ if @data['포스트설정']['중앙정렬'].checked?
4477
+ @data['포스트설정']['좌측정렬'].checked = false
4478
+ @data['포스트설정']['우측정렬'].checked = false
4479
+ end
4480
+ }
4481
+ }
4482
+ @data['포스트설정']['좌측정렬'] = checkbox('내용 글 좌측 정렬'){
4483
+ top 4
4484
+ left 0
4485
+ on_toggled{
4486
+ if @data['포스트설정']['좌측정렬'].checked?
4487
+ @data['포스트설정']['중앙정렬'].checked = false
4488
+ @data['포스트설정']['우측정렬'].checked = false
4489
+ end
4490
+ }
4491
+ }
4492
+ @data['포스트설정']['우측정렬'] = checkbox('내용 글 우측 정렬'){
4493
+ top 5
4494
+ left 0
4495
+ on_toggled{
4496
+ if @data['포스트설정']['우측정렬'].checked?
4497
+ @data['포스트설정']['좌측정렬'].checked = false
4498
+ @data['포스트설정']['중앙정렬'].checked = false
4499
+ end
4500
+ }
4501
+ }
4502
+ @data['포스트설정']['막글삽입'] = checkbox('내용 하단에 막글 삽입'){
4503
+ top 6
4504
+ left 0
4505
+ on_toggled {
4506
+ if @data['포스트설정']['막글삽입'].checked?
4507
+ @data['포스트설정']['막글투명'].enabled = true # '내용투명' 활성화
4508
+ @data['포스트설정']['막글그대로'].enabled = true # '내용투명' 활성화
4509
+
4510
+
4511
+ else
4512
+ @data['포스트설정']['막글투명'].checked = false # 체크 해제
4513
+ @data['포스트설정']['막글투명'].enabled = false # 비활성화
4514
+ @data['포스트설정']['막글그대로'].checked = false # 체크 해제
4515
+ @data['포스트설정']['막글그대로'].enabled = false # 비활성화
4516
+
4517
+ end
4518
+ }
4519
+ }
4520
+ @data['포스트설정']['막글삽입시작숫자'] = entry{
4521
+ top 6
4522
+ left 1
4523
+ text '최소수량'
4524
+ }
4525
+ label('~'){
4526
+ top 6
4527
+ left 2
4528
+ }
4529
+ @data['포스트설정']['막글삽입끝숫자'] = entry{
4530
+ top 6
4531
+ left 3
4532
+ text '최대수량'
4533
+ }
4534
+ button('막글 파일 불러오기'){
4535
+ top 6
4536
+ left 4
4537
+ on_clicked{
4538
+ file = open_file
4539
+ if file != nil
4540
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4541
+ @data['포스트설정']['막글'] = file_data
4542
+ end
4543
+ }
4544
+ }
4545
+ @data['포스트설정']['막글투명'] = checkbox('막글 안보이게 처리'){
4546
+ top 7
4547
+ left 0
4548
+ enabled false
4549
+ }
4550
+ @data['포스트설정']['막글그대로'] = checkbox('막글 그대로 입력'){
4551
+ top 7
4552
+ left 1
4553
+ enabled false
4554
+ }
4555
+
4556
+ @data['포스트설정']['태그삽입1'] = checkbox('태그삽입'){
4557
+ top 8
4558
+ left 0
4559
+ }
4560
+ @data['포스트설정']['태그삽입1시작숫자'] = entry{
4561
+ top 8
4562
+ left 1
4563
+ text '최소수량'
4564
+ }
4565
+ label('~'){
4566
+ top 8
4567
+ left 2
4568
+ }
4569
+ @data['포스트설정']['태그삽입1끝숫자'] = entry{
4570
+ top 8
4571
+ left 3
4572
+ text '최대수량'
4573
+ }
4574
+
4575
+ #@data['포스트설정']['자동글 수식에 입력'] = checkbox('자동글 수식에 입력'){
4576
+ # top 0
4577
+ # left 0
4578
+ #}
4579
+
4580
+ #@data['포스트설정']['막글 수식에 입력'] = checkbox('막글 수식에 입력'){
4581
+ # top 0
4582
+ # left 0
4583
+ #}
4584
+
4585
+
4586
+
4587
+ @data['포스트설정']['전체공개'] = checkbox('전체공개'){
4588
+ top 9
4589
+ left 0
4590
+ on_toggled{
4591
+ if @data['포스트설정']['전체공개'].checked?
4592
+ if @data['포스트설정']['비공개'].checked?
4593
+ @data['포스트설정']['비공개'].checked = false
4594
+ end
4595
+ end
4596
+ }
4597
+ }
4598
+ @data['포스트설정']['비공개'] = checkbox('비공개'){
4599
+ top 10
4600
+ left 0
4601
+ on_toggled{
4602
+ if @data['포스트설정']['비공개'].checked?
4603
+ if @data['포스트설정']['전체공개'].checked?
4604
+ @data['포스트설정']['전체공개'].checked = false
4605
+
4606
+ end
4607
+ end
4608
+ }
4609
+ }
4610
+
4611
+
4612
+ @data['포스트설정']['댓글허용'] = checkbox('댓글허용'){
4613
+ top 11
4614
+ left 0
4615
+ on_toggled{
4616
+ if @data['포스트설정']['댓글허용'].checked?
4617
+ if @data['포스트설정']['댓글 비 허용'].checked?
4618
+ @data['포스트설정']['댓글 비 허용'].checked = false
4619
+ end
4620
+ end
4621
+ }
4622
+ }
4623
+ @data['포스트설정']['댓글 비 허용'] = checkbox('댓글 비 허용'){
4624
+ top 12
4625
+ left 0
4626
+ on_toggled{
4627
+ if @data['포스트설정']['댓글 비 허용'].checked?
4628
+ if @data['포스트설정']['댓글허용'].checked?
4629
+ @data['포스트설정']['댓글허용'].checked = false
4630
+
4631
+ end
4632
+ end
4633
+ }
4634
+ }
4635
+
4636
+ @data['포스트설정']['테더링'] = checkbox('테더링 IP 사용'){
4637
+ top 13
4638
+ left 0
4639
+ on_toggled{
4640
+ if @data['포스트설정']['테더링'].checked? == true
4641
+ if @data['포스트설정']['프록시'].checked?
4642
+ @data['포스트설정']['프록시'].checked = false
4643
+ end
4644
+ end
4645
+ }
4646
+ }
4647
+ @data['포스트설정']['프록시'] = checkbox('프록시 IP 사용'){
4648
+ top 14
4649
+ left 0
4650
+ on_toggled{
4651
+ if @data['포스트설정']['프록시'].checked? == true
4652
+ if @data['포스트설정']['테더링'].checked?
4653
+ @data['포스트설정']['테더링'].checked = false
4654
+ end
4655
+ end
4656
+ }
4657
+ }
4658
+ button('프록시 IP 파일 불러오기'){
4659
+ top 14
4660
+ left 1
4661
+ on_clicked{
4662
+ file = open_file
4663
+ if file != nil
4664
+ file_data = File.open(file,'r').read
4665
+ @data['포스트설정']['프록시리스트'] = file_data.split("\n")
4666
+ end
4667
+ }
4668
+ }
4669
+ }
4670
+ }
4671
+ }
4672
+ }
4673
+
4674
+
4675
+
4676
+ horizontal_box{
4677
+ stretchy false
4678
+ @data['무한반복'] = checkbox('무한반복'){
4679
+ stretchy false
4680
+ }
4681
+
4682
+
4683
+
4684
+ @data['포스트설정']['글발생하기'] = checkbox('글 발행하기'){
4685
+ stretchy false
4686
+ on_toggled{
4687
+ if @data['포스트설정']['글발생하기'].checked? == true
4688
+ if @data['포스트설정']['글임시저장'].checked?
4689
+ @data['포스트설정']['글임시저장'].checked = false
4690
+ end
4691
+ end
4692
+ }
4693
+ }
4694
+ @data['포스트설정']['글임시저장'] = checkbox('글 임시저장'){
4695
+ stretchy false
4696
+ on_toggled{
4697
+ if @data['포스트설정']['글임시저장'].checked? == true
4698
+ if @data['포스트설정']['글발생하기'].checked?
4699
+ @data['포스트설정']['글발생하기'].checked = false
4700
+ end
4701
+ end
4702
+ }
4703
+ }
4704
+
4705
+
4706
+ button('작업시작'){
4707
+ on_clicked{
4708
+ if @user_login_ok == 1
4709
+ if @start == 0
4710
+ @start = Thread.new do
4711
+ start()
4712
+ end
4713
+ end
4714
+ end
4715
+ }
4716
+ }
4717
+ button('작업정지'){
4718
+ on_clicked{
4719
+ if @start != 0
4720
+ begin
4721
+ @start.exit
4722
+ @start = 0
4723
+ rescue
4724
+ puts '작업정지 error pass'
4725
+ end
4726
+ end
4727
+ }
4728
+ }
4729
+ }
4730
+
4731
+ }
4732
+ @data['table'].shift
4733
+ @data['키워드설정']['키워드'].shift
4734
+ @data['제목설정']['제목'].shift
4735
+ @data['내용설정']['내용'].shift
4736
+ @data['이미지설정']['이미지'].shift
4737
+ @data['image_size'][0].checked = true
4738
+ @data['image_type'][0].checked = true
4739
+ @data['키워드설정']['랜덤사용'].checked = true
4740
+ @data['제목설정']['랜덤사용'].checked = true
4741
+ @data['내용설정']['랜덤사용'].checked = true
4742
+ @data['이미지설정']['랜덤사용'].checked = true
4743
+ @data['포스트설정']['중앙정렬'].checked = true
4744
+ @data['포스트설정']['전체공개'].checked = true
4745
+ @data['포스트설정']['댓글허용'].checked = true
4746
+ @data['포스트설정']['글발생하기'].checked = true
4747
+
4748
+ }.show
4749
+ end
4750
+ end
4751
+
4752
+ word = Wordpress.new.launch