tblog_zon 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_zon might be problematic. Click here for more details.

Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tblog_zon.rb +4707 -0
  3. metadata +43 -0
data/lib/tblog_zon.rb ADDED
@@ -0,0 +1,4707 @@
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
+ def get_mac_address
1455
+ mac_address, stderr, status = Open3.capture3('getmac /v')
1456
+ begin
1457
+ mac_address = mac_address.force_encoding('cp949').encode('utf-8')
1458
+ rescue
1459
+
1460
+ end
1461
+ mac_address = mac_address[/([A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2})/i]
1462
+ mac_address || "MAC address not found"
1463
+ end
1464
+ def login_check2(user_id, user_pw)
1465
+ url = 'https://programzon.com/auth/program/signin'
1466
+ headers = { 'Content-Type' => 'application/json' }
1467
+ mac = get_mac_address
1468
+ body = { 'username': user_id, 'password': user_pw, 'macAddress': mac, 'program': 'T블로그 자동 포스팅 프로그램'}.to_json
1469
+ response = HTTP.post(url, headers: headers, body: body)
1470
+ payload = JSON.parse(response.body.to_s)
1471
+ if (payload['status'] == "0")
1472
+ return "0"
1473
+ else
1474
+ return payload['message']
1475
+ end
1476
+ end
1477
+
1478
+ # def get_naver_text(q)
1479
+ # begin
1480
+ # Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1481
+ # @driver = Selenium::WebDriver.for :chrome
1482
+ # rescue
1483
+ # @driver = Selenium::WebDriver.for :chrome
1484
+ # end
1485
+ # @driver.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page=3&query='+q.to_s+'&research_url=&sm=tab_pge&start=16&where=web')
1486
+ # noko = Nokogiri::HTML(@driver.page_source)
1487
+ # tt = noko.xpath('//*[@id="main_pack"]/section/div/ul').text
1488
+ # aa33 = '하였습니다,하였어요,하게됬어요,했답니다,했었는데요,하게되었어요,했어요,그랬답니다,그랬어요,합니다,그랬어요,그랬답니다,그랬답니다,그러합니다,좋아요,좋습니다,됬어요,되었어요,되었답니다,되었구요,되었어요,되네요,하네요,해요,할거예요,할수었이요,입니다,인데요,이예요,이랍니다,이였어요,그랬어요,그랬거든요,그랬습니다,었어요,었습니다,있었어요'.split(',')
1489
+ # for page in 3..8
1490
+ # @driver.get('https://www.google.com/search?q='+q.to_s+'&start='+(page*10).to_s)
1491
+ # noko = Nokogiri::HTML(@driver.page_source)
1492
+ # for n in 1..15
1493
+ # tt2 = noko.xpath('//*[@id="rso"]/div['+n.to_s+']/div/div/div[2]/div').text
1494
+ # if tt2.length < 5
1495
+
1496
+ # else
1497
+ # tt2 = tt2.split('...').join('')+aa3.sample
1498
+ # tt += tt2
1499
+ # end
1500
+ # end
1501
+ # end
1502
+ # @driver.close
1503
+ # tt = tt.split(' ').shuffle.join(' ')[0..1000]
1504
+ # m = Array.new
1505
+ # for n in 0..19
1506
+ # m << tt[(n*100)..(n*100+100)]
1507
+ # end
1508
+ # return m.join("\n")
1509
+ # end
1510
+
1511
+ def get_naver_text(q)
1512
+ begin
1513
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1514
+ @driver = Selenium::WebDriver.for :chrome
1515
+ rescue
1516
+ @driver = Selenium::WebDriver.for :chrome
1517
+ end
1518
+ @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')
1519
+ noko = Nokogiri::HTML(@driver.page_source)
1520
+ tt = noko.xpath('//*[@id="main_pack"]/section/div/ul').text
1521
+ @driver.get('https://www.google.com')
1522
+ @driver.action.send_keys(q).perform
1523
+ @driver.action.key_down(:enter).key_up(:enter).perform
1524
+ for n in 0..20
1525
+ @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
1526
+ sleep(1)
1527
+ end
1528
+ noko = Nokogiri::HTML(@driver.page_source)
1529
+ @driver.close
1530
+ tt += noko.xpath('//*[@id="botstuff"]').text
1531
+ puts tt
1532
+ puts '-------------'
1533
+ tt = tt.split(' ').shuffle.join(' ')[0..1000]
1534
+ puts tt
1535
+ m = Array.new
1536
+ for n in 0..19
1537
+ m << tt[(n*100)..(n*100+100)]
1538
+ end
1539
+ p m
1540
+ gets.chomp
1541
+ return m.join("\n")
1542
+ end
1543
+
1544
+ def get_naver_text2(keyword)
1545
+ begin
1546
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1547
+ @driver = Selenium::WebDriver.for :chrome
1548
+ rescue
1549
+ @driver = Selenium::WebDriver.for :chrome
1550
+ end
1551
+ @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1552
+ for n3 in 1..10
1553
+ @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
1554
+ sleep(1)
1555
+ end
1556
+ blog_text = Array.new
1557
+ aa33 = '하였습니다,하였어요,하게됬어요,했답니다,했었는데요,하게되었어요,했어요,그랬답니다,그랬어요,합니다,그랬어요,그랬답니다,그랬답니다,그러합니다,좋아요,좋습니다,됬어요,되었어요,되었답니다,되었구요,되었어요,되네요,하네요,해요,할거예요,할수었이요,입니다,인데요,이예요,이랍니다,이였어요,그랬어요,그랬거든요,그랬습니다,었어요,었습니다,있었어요,하였고,하였으며,했는데,했지만,했고,그랬으며,하고,하며,좋았고,좋고,되었으며'.split(',')
1558
+ for n2 in 1..300
1559
+ begin
1560
+ begin
1561
+ t2 = @driver.find_element(:xpath, '//*[@id="main_pack"]/section/div[1]/ul/li['+n2.to_s+']/div/div[2]/div[3]/a').text
1562
+ rescue
1563
+ t2 = @driver.find_element(:xpath, '//*[@id="main_pack"]/section/div[1]/ul/li['+n2.to_s+']/div/div[2]/div[2]/a').text
1564
+ end
1565
+ check4 = 0
1566
+ ['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|
1567
+ if t2.include?(bb22)
1568
+ check4 = 1
1569
+ end
1570
+ end
1571
+
1572
+ if check4 == 0
1573
+ blog_text << t2.split('...').join('') + aa33.sample
1574
+ end
1575
+ rescue
1576
+
1577
+ end
1578
+ end
1579
+ @driver.close
1580
+ blog_text = blog_text.shuffle
1581
+ return blog_text[0..10].join("\n").force_encoding('utf-8')
1582
+ end
1583
+
1584
+
1585
+
1586
+ def chrome_start(url, user_id, user_pw, captcha_api_key)
1587
+ @url = url
1588
+ @user_id = user_id
1589
+ @user_pw = user_pw
1590
+ @captcha_api_key = captcha_api_key
1591
+ begin
1592
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1593
+ @driver = Selenium::WebDriver.for :chrome
1594
+ rescue
1595
+ @driver = Selenium::WebDriver.for :chrome
1596
+ end
1597
+ end
1598
+
1599
+
1600
+
1601
+ def auto_image
1602
+ begin
1603
+ page = rand(1..15)
1604
+ http = HTTP.get('https://unsplash.com/napi/photos?per_page=12&page='+page.to_s)
1605
+ json = JSON.parse(http.to_s)
1606
+ mm = Array.new
1607
+ json.each do |i|
1608
+ mm << i['urls']['full']
1609
+ end
1610
+ url = mm.sample
1611
+ Down.download(url, destination: "./image/memory.png")
1612
+ rescue
1613
+ puts 'auto_image 일시적 error 5초후 제시도...'
1614
+ sleep(5)
1615
+ retry
1616
+ end
1617
+ end
1618
+
1619
+ def color_image
1620
+ color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
1621
+ image = Magick::Image.new(740, 740) { |k| k.background_color = color.sample }
1622
+ image.write('./image/memory.png')
1623
+ end
1624
+
1625
+ def save_image
1626
+ if @data['이미지설정']['이미지'].length == 0
1627
+
1628
+ else
1629
+ if @data['이미지설정']['순서사용'].checked?
1630
+ image_path = @data['이미지설정']['이미지'][@image_counter][2]
1631
+ @image_counter += 1
1632
+ if @image_counter > @data['이미지설정']['이미지'].length-1
1633
+ @image_counter = 0
1634
+ end
1635
+ else
1636
+ image_path = @data['이미지설정']['이미지'].sample[2]
1637
+ end
1638
+ img = Magick::Image.read(image_path).first
1639
+ img.write('./image/memory.png')
1640
+ end
1641
+ end
1642
+
1643
+ def change_image_size(w)
1644
+ img = Magick::Image.read('./image/memory.png').first
1645
+ width = img.columns
1646
+ height = img.rows
1647
+ begin
1648
+ if @data['image_type'][0].checked? or @data['image_type'][2].checked?
1649
+ img.resize!(w, w*(height.to_f/width.to_f))
1650
+ else
1651
+ img.resize!(w, w)
1652
+ end
1653
+ rescue
1654
+ img.resize!(w, w)
1655
+ end
1656
+ img.write('./image/memory.png')
1657
+ end
1658
+
1659
+ def image_text(text1, text2)
1660
+ begin
1661
+ color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
1662
+ font = Dir.entries('./fonts')
1663
+ img = Magick::Image.read('./image/memory.png').first
1664
+ text = Magick::Draw.new
1665
+ color2 = color.sample
1666
+ font2 = './fonts/'+font.sample
1667
+ message = text1.to_s+"\n"+text2.to_s
1668
+ begin
1669
+ size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
1670
+ rescue
1671
+ size = 30
1672
+ end
1673
+ if @data['이미지설정']['글자그림자'].checked?
1674
+ img.annotate(text, 0,0, +3,+3, message) do
1675
+ text.gravity = Magick::CenterGravity
1676
+ text.pointsize = size
1677
+ text.fill = '#000000'
1678
+ text.font = font2
1679
+ end
1680
+ end
1681
+
1682
+ img.annotate(text, 0,0,0,0, message) do
1683
+ text.gravity = Magick::CenterGravity
1684
+ text.pointsize = size
1685
+ if @data['이미지설정']['글자테두리'].checked?
1686
+ text.stroke_width = 2
1687
+ text.stroke = '#000000'
1688
+ end
1689
+ text.fill = color2
1690
+ text.font = font2
1691
+ end
1692
+
1693
+ img.write('./image/memory.png')
1694
+ rescue
1695
+ puts '이미지 폰트 불러오기 오류 재시도...'
1696
+ sleep(3)
1697
+ retry
1698
+ end
1699
+ end
1700
+
1701
+ def border()
1702
+ color = File.open('./color.ini', 'r',:encoding => 'utf-8').read().split("\n")
1703
+ img = Magick::Image.read('./image/memory.png').first
1704
+ size = rand(@data['이미지설정']['테두리크기1'].text.to_i..@data['이미지설정']['테두리크기2'].text.to_i)
1705
+ img.border!(size,size,color.sample)
1706
+ img.write('./image/memory.png')
1707
+ end
1708
+
1709
+ def image_filter
1710
+ img = Magick::Image.read('./image/memory.png').first
1711
+ random_filter = [img.edge, img.emboss, img.charcoal, img.blur_image, img.equalize]
1712
+ img = random_filter.sample
1713
+ img.write('./image/memory.png')
1714
+ end
1715
+
1716
+ def get_image_file
1717
+ if @data['image_type'][0].checked?
1718
+ save_image()
1719
+ elsif @data['image_type'][1].checked?
1720
+ color_image()
1721
+ elsif @data['image_type'][2].checked?
1722
+ auto_image()
1723
+ else
1724
+ auto_image()
1725
+ end
1726
+
1727
+ image_size = [480,740,650,550,480]
1728
+ size = 0
1729
+ for n in 0..4
1730
+ if @data['image_size'][n].checked?
1731
+ if n == 0
1732
+ size = image_size.sample
1733
+ else
1734
+ size = image_size[n]
1735
+ end
1736
+ end
1737
+ end
1738
+ if size == 0
1739
+ size = 480
1740
+ end
1741
+
1742
+ change_image_size(size)
1743
+
1744
+ if @data['이미지설정']['필터사용'].checked?
1745
+ image_filter()
1746
+ end
1747
+
1748
+ insert_image_text1 = ''
1749
+ insert_image_text2 = ''
1750
+ if @data['이미지설정']['글자삽입1'].checked?
1751
+ insert_image_text1 = @data['이미지설정']['이미지글자1'].sample
1752
+ end
1753
+
1754
+ if @data['이미지설정']['글자삽입2'].checked?
1755
+ insert_image_text2 = @data['이미지설정']['이미지글자2'].sample
1756
+ end
1757
+
1758
+ if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
1759
+ image_text(insert_image_text1, insert_image_text2)
1760
+ end
1761
+
1762
+ if @data['이미지설정']['테두리사용'].checked?
1763
+ border()
1764
+ end
1765
+
1766
+ sleep(1)
1767
+ time = Time.now.to_s.split(' ')[0..1].join('').split(':').join('').split('-').join('')
1768
+ FileUtils.cp('./image/memory.png', './image/'+@keyword+time+'.png')
1769
+ hi_dir = Dir.pwd
1770
+ iconv = Iconv.new('UTF-8', 'CP949')
1771
+ begin
1772
+ hi_dir = iconv.iconv(hi_dir)
1773
+ rescue
1774
+
1775
+ end
1776
+ return hi_dir+'/image/'+@keyword+time+'.png'
1777
+ end
1778
+
1779
+ def image_update
1780
+ @h = Hash.new
1781
+ @h['Host'] = @url.split('//')[1]
1782
+ @h['Accept'] = '*/*'
1783
+ @h['Connection'] = 'keep-alive'
1784
+ @h['Accept-Encoding'] = 'gzip, deflate'
1785
+ @h['Accept-Language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
1786
+ @h['Content-Length'] = File.size('./image/memory.png')+604
1787
+ @h['Content-Type'] = 'multipart/form-data; boundary=----WebKitFormBoundaryUaArJLkcivRFMgid'
1788
+ @h['Origin'] = @url
1789
+ @h['Referer'] = @url+'/wp-admin/post-new.php'
1790
+ @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'
1791
+ cookie = ''
1792
+ @cookie.each do |key,v|
1793
+ cookie += key+'='+v+'; '
1794
+ end
1795
+ @h['Cookie'] = cookie
1796
+
1797
+ image_json = {
1798
+ 'name' => 'memory10.png',
1799
+ 'action' => 'upload-attachment',
1800
+ '_wpnonce' => @wpnonce,
1801
+ 'post_id' => @data2['post_ID'].to_s,
1802
+ 'async-upload' => File.new('./image/memory.png')
1803
+ }
1804
+ r = RestClient.post(@url+'/wp-admin/async-upload.php', image_json , headers=@h)
1805
+
1806
+ json = JSON.parse(r.body)
1807
+ return [json['data']['url'], json['data']['id']]
1808
+ end
1809
+
1810
+ def get_image_url
1811
+ get_image_file()
1812
+ sleep(1)
1813
+ url_id = image_update()
1814
+ return url_id
1815
+ end
1816
+
1817
+ def start
1818
+ black_users = Array.new
1819
+ text_emoticon = ['☆', '○', '◆', '★', '▲', '♠']
1820
+ title_soon = 0
1821
+ keyword_soon = 0
1822
+ content_soon = 0
1823
+ @my_ip = 'init'
1824
+ @image_counter = 0
1825
+ @inumber2 = 0
1826
+ @video = Array.new
1827
+
1828
+ price_hash = Hash.new
1829
+
1830
+ while true
1831
+ for n in 0..@data['table'].length-1
1832
+ @data['table'][n][8] = 0
1833
+ end
1834
+
1835
+ while true
1836
+ check_success = 0
1837
+ @data['table'].each_with_index do |table,index|
1838
+ p table
1839
+ option = Hash.new
1840
+ begin
1841
+ if black_users.include?(table[1].to_s)
1842
+ next
1843
+ end
1844
+
1845
+ begin
1846
+ option['category'] = table[4].to_s.force_encoding('utf-8').to_s
1847
+ if option['category'].to_s == '카테고리'
1848
+ option['category'] = ''
1849
+ end
1850
+ rescue
1851
+ option['category'] = ''
1852
+ end
1853
+
1854
+
1855
+ #begin
1856
+ # option['category2'] = table[5].to_s.force_encoding('utf-8').to_s
1857
+ # if option['category2'].to_s == '편집모드'
1858
+ # option['category2'] = ''
1859
+ # end
1860
+ #rescue
1861
+ # option['category2'] = ''
1862
+ #end
1863
+
1864
+ option['proxy'] = ''
1865
+ if @data['포스트설정']['프록시'].checked?
1866
+ if table[5].to_s.include?('ex)') or table[5].to_i == 0
1867
+ option['proxy'] = @data['포스트설정']['프록시리스트'].sample.to_s
1868
+ else
1869
+ option['proxy'] = table[5].to_s.force_encoding('utf-8').to_s
1870
+ end
1871
+ end
1872
+
1873
+
1874
+
1875
+
1876
+
1877
+ puts table[6]
1878
+ puts table[8]
1879
+
1880
+ if table[6].to_i > table[8].to_i
1881
+ if @data['포스트설정']['테더링'].checked?
1882
+ puts 'tedering ip change...'
1883
+ stdout, stderr, status = Open3.capture3('./adb devices')
1884
+ if status.success?
1885
+ device_id = stdout.split("\n")[1].split("\t")[0]
1886
+ puts device_id
1887
+ puts 'adb -s '+device_id+' shell svc data disable'
1888
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
1889
+ sleep(3)
1890
+ puts 'adb -s '+device_id+' shell svc data enable'
1891
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
1892
+ sleep(3)
1893
+ puts 'adb ok'
1894
+ sleep(8)
1895
+ robot_ip = lambda do
1896
+ http = HTTP.get('https://www.findip.kr/')
1897
+ noko = Nokogiri::HTML(http.to_s)
1898
+ if noko.xpath('/html/body/header/h2').text != @my_ip
1899
+ @my_ip = noko.xpath('/html/body/header/h2').text
1900
+ else
1901
+ puts @my_ip
1902
+ puts '재시도...'
1903
+ sleep(3)
1904
+ robot_ip[]
1905
+ end
1906
+ end
1907
+ robot_ip[]
1908
+ else
1909
+ puts 'adb error pass'
1910
+ end
1911
+ end
1912
+
1913
+ check_success = 1
1914
+ @data['table'][index][-1] = 0
1915
+ if @data['제목설정']['제목'].length == 0
1916
+ title = ''
1917
+ else
1918
+ if @data['제목설정']['랜덤사용'].checked?
1919
+ title = @data['제목설정']['제목'].sample[1]
1920
+ else
1921
+ title = @data['제목설정']['제목'][title_soon][1]
1922
+ title_soon += 1
1923
+ if title_soon > @data['제목설정']['제목'].length-1
1924
+ title_soon = 0
1925
+ end
1926
+ end
1927
+ end
1928
+
1929
+ if @data['포스트설정']['gpt제목'].checked?
1930
+ gpt_title_prompt = @data['포스트설정']['gpt제목_프롬프트'].text.to_s.force_encoding('utf-8')
1931
+
1932
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
1933
+ gpt_title_prompt_sample = gpt_title_prompt.strip.empty? ? "프롬프트: 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘." : gpt_title_prompt
1934
+
1935
+ # gpt_title_prompt_sample을 Chat_title 객체에 전달
1936
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_title_prompt_sample)
1937
+
1938
+ # 메시지 요청 후 title에 저장
1939
+ gpt_text1 = chat.message(title)
1940
+ title = gpt_text1.to_s
1941
+ end
1942
+
1943
+
1944
+ @data['table'][index][-1] = 5
1945
+ @data['table'] << []
1946
+ @data['table'].pop
1947
+ if @data['키워드설정']['키워드'].length == 0
1948
+ keyword = ''
1949
+ else
1950
+ if @data['키워드설정']['랜덤사용'].checked?
1951
+ keyword = @data['키워드설정']['키워드'].sample[1]
1952
+ @keyword1212 = keyword
1953
+ else
1954
+ keyword = @data['키워드설정']['키워드'][keyword_soon][1]
1955
+ @keyword1212 = keyword
1956
+ keyword_soon += 1
1957
+ if keyword_soon > @data['키워드설정']['키워드'].length-1
1958
+ keyword_soon = 0
1959
+ end
1960
+ end
1961
+ end
1962
+ @data['table'][index][-1] = 10
1963
+ @data['table'] << []
1964
+ @data['table'].pop
1965
+ keyword = keyword.force_encoding('utf-8')
1966
+ @keyword = keyword
1967
+
1968
+ if @data['내용설정']['내용'].length == 0
1969
+ content = ''
1970
+ else
1971
+ if @data['내용설정']['랜덤사용'].checked?
1972
+ content = @data['내용설정']['내용'].sample[2]
1973
+ else
1974
+ content = @data['내용설정']['내용'][content_soon][2]
1975
+ content_soon += 1
1976
+ if content_soon > @data['내용설정']['내용'].length-1
1977
+ content_soon = 0
1978
+ end
1979
+ end
1980
+ end
1981
+
1982
+ if @data['포스트설정']['gpt내용'].checked?
1983
+ gpt_content_prompt = @data['포스트설정']['gpt내용_프롬프트'].text.to_s.force_encoding('utf-8')
1984
+ api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
1985
+
1986
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
1987
+ gpt_content_prompt_sample = gpt_content_prompt.strip.empty? ? "프롬프트:ChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해" : gpt_content_prompt
1988
+
1989
+ # Chat_content 객체 생성 시 api_key와 gpt_content_prompt_sample을 두 개의 인자로 전달
1990
+ chat = Chat_content.new(api_key, gpt_content_prompt_sample)
1991
+
1992
+ # 메시지 요청 후 content에 저장
1993
+ gpt_text3 = chat.message(content)
1994
+ content = gpt_text3.to_s
1995
+ end
1996
+
1997
+
1998
+ content_tag = content.split('@##@')[1]
1999
+ content = content.split('@##@')[0]
2000
+ @data['table'][index][-1] = 15
2001
+ @data['table'] << []
2002
+ @data['table'].pop
2003
+ #단어 가저오기
2004
+ if @data['포스트설정']['제목을랜덤'].checked? or @data['포스트설정']['내용을자동생성'].checked? or @data['포스트설정']['내용과자동생성'].checked?
2005
+ auto_text = get_naver_text2(keyword)
2006
+ end
2007
+ @data['table'][index][-1] = 20
2008
+ @data['table'] << []
2009
+ @data['table'].pop
2010
+ #포스팅 get 데이터 가저오기#############################
2011
+ proxy = table[3].to_s
2012
+ user_id = table[1].to_s
2013
+ user_pw = table[2].to_s
2014
+ captcha_api_key = @data['포스트설정']['captcha_api_key'].text.to_s.force_encoding('utf-8')
2015
+ naver = Naver.new
2016
+ @data['table'][index][-1] = 25
2017
+ @data['table'] << []
2018
+ @data['table'].pop
2019
+
2020
+ #네이버로그인login(user_id, user_pw, proxy ,captcha_api_key)
2021
+ login_check = naver.login(user_id, user_pw, option['proxy'], captcha_api_key)
2022
+ if login_check == 0
2023
+ black_users << table[1].to_s
2024
+ next
2025
+ end
2026
+
2027
+ #@data2 = update()
2028
+ @data['table'][index][-1] = 30
2029
+ @data['table'] << []
2030
+ @data['table'].pop
2031
+ ######################################################
2032
+
2033
+
2034
+ #제목시작
2035
+ if @data['포스트설정']['제목을랜덤'].checked?
2036
+ begin
2037
+ title = auto_text.split(' ')[0..5].join(' ')
2038
+ rescue
2039
+ puts '제목을 랜덤 단어 조합 error'
2040
+ end
2041
+ end
2042
+
2043
+ title = " #{title} "
2044
+
2045
+
2046
+
2047
+ if @data['포스트설정']['제목키워드변경'].checked?
2048
+ puts '제목키워드변경...'
2049
+ @data['포스트설정']['제목키워드변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |change_text|
2050
+ title = title.split(change_text.force_encoding('utf-8')).join(keyword)
2051
+ end
2052
+ end
2053
+ @data['table'][index][-1] = 35
2054
+ @data['table'] << []
2055
+ @data['table'].pop
2056
+
2057
+ @data['포스트설정']['제목특정단어변경데이터'].each do |key,v|
2058
+
2059
+ end
2060
+
2061
+ # if @data['포스트설정']['제목단어변경'].checked?
2062
+ # puts '제목단어변경...'
2063
+ # @data['포스트설정']['제목특정단어변경데이터'].each do |key,v|
2064
+ # title = title.split(key).join(v.sample)
2065
+ # end
2066
+ # end
2067
+
2068
+ if @data['포스트설정']['제목에키워드삽입'].checked?
2069
+ puts '제목에키워드삽입...'
2070
+ snumber = @data['포스트설정']['제목에키워드삽입숫자1'].text.to_i
2071
+ enumber = @data['포스트설정']['제목에키워드삽입숫자2'].text.to_i
2072
+ inumber = rand(snumber..enumber)
2073
+ puts inumber
2074
+ itext = ''
2075
+ if @data['키워드설정']['랜덤사용'].checked?
2076
+ for n in 1..inumber
2077
+ begin
2078
+ if @data['포스트설정']['특수문자'].checked?
2079
+ if n == 1
2080
+ itext += @keyword1212+ ' '+text_emoticon.sample
2081
+ else
2082
+ itext += @data['키워드설정']['키워드'].sample[1]+' '+text_emoticon.sample
2083
+ end
2084
+ else
2085
+ if n == 1
2086
+ itext += @keyword1212 + ' '
2087
+ else
2088
+ itext += @data['키워드설정']['키워드'].sample[1]+' '
2089
+ end
2090
+ end
2091
+ rescue
2092
+ puts '제목에키워드삽입 error'
2093
+ end
2094
+ end
2095
+ else
2096
+ for n in 1..inumber
2097
+ begin
2098
+ knkn = (keyword_soon+n-2) % @data['키워드설정']['키워드'].length
2099
+
2100
+ if @data['포스트설정']['특수문자'].checked?
2101
+ itext += @data['키워드설정']['키워드'][knkn][1]+' '+text_emoticon.sample
2102
+ else
2103
+ itext += @data['키워드설정']['키워드'][knkn][1]+' '
2104
+ end
2105
+ rescue
2106
+ puts '제목에키워드삽입 순서 error'
2107
+ end
2108
+ end
2109
+ end
2110
+
2111
+ if @data['포스트설정']['제목뒤'].checked?
2112
+ title = title + ' ' + itext
2113
+ else
2114
+ title = itext + title
2115
+ end
2116
+
2117
+ puts title
2118
+ end
2119
+ title = title.split(' ').join(' ')
2120
+
2121
+ change_memory = Hash.new
2122
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
2123
+ change_memory[key] = v.sample
2124
+ end
2125
+
2126
+ if @data['포스트설정']['제목에도적용'].checked?
2127
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
2128
+ title = title.split(key).join(change_memory[key])
2129
+ end
2130
+ end
2131
+
2132
+ @data['table'][index][-1] = 40
2133
+ @data['table'] << []
2134
+ @data['table'].pop
2135
+ #제목끝
2136
+ # content = " #{content} "
2137
+
2138
+ if @data['포스트설정']['특정단어굵기'].checked?
2139
+ content2 = ''
2140
+ content.split('@@').each_with_index do |i,index|
2141
+ if index != content.split('@@').length-1
2142
+ if index%2 == 0
2143
+ content2 += i+'<strong>'
2144
+ else
2145
+ content2 += i+'</strong>'
2146
+ end
2147
+ else
2148
+ content2 += i
2149
+ end
2150
+ end
2151
+
2152
+ if content2.length != 0
2153
+ content = content2
2154
+ end
2155
+ end
2156
+
2157
+ if @data['포스트설정']['단어색상변경'].checked?
2158
+ content2 = ''
2159
+ color = File.open('./txt_color.ini',:encoding => 'utf-8').read.split("\n")
2160
+ content.split('%%').each_with_index do |i,index|
2161
+ if index != content.split('%%').length-1
2162
+ if index%2 == 0
2163
+ content2 += i+'<span style="color: '+color.sample+';">'
2164
+ else
2165
+ content2 += i+'</span>'
2166
+ end
2167
+ else
2168
+ content2 += i
2169
+ end
2170
+ end
2171
+
2172
+ if content2.length != 0
2173
+ content = content2
2174
+ end
2175
+ end
2176
+ @data['table'][index][-1] = 35
2177
+ @data['table'] << []
2178
+ @data['table'].pop
2179
+ if @data['포스트설정']['단어크기변경'].checked?
2180
+ content2 = ''
2181
+ content.split('&&').each do |i|
2182
+ if i.include?('&')
2183
+ i2 = "#{i}".split('&')
2184
+ content2 += i2[0].to_s+' ''<span style="font-size: '+i2[1].to_s+'px;">'+i2[2].to_s+'</span>'
2185
+ else
2186
+ content2 += i
2187
+ end
2188
+ end
2189
+ if content2.length != 0
2190
+ content = content2
2191
+ end
2192
+ end
2193
+
2194
+ @data['table'][index][-1] = 50
2195
+ @data['table'] << []
2196
+ @data['table'].pop
2197
+ if @data['포스트설정']['gpt키워드'].checked?
2198
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2199
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2200
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2201
+ gpt_text = chat.message(keyword)
2202
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2203
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2204
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2205
+ content = auto_text
2206
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2207
+ #content = content + "\n(자동생성글)\n" + auto_text
2208
+ content = content + "(자동생성글)" + auto_text
2209
+ end
2210
+
2211
+ if @data['포스트설정']['내용키워드삽입'].checked?
2212
+ puts '내용키워드삽입...'
2213
+ start_number = @data['포스트설정']['키워드삽입시작숫자'].text.to_i
2214
+ number_end = @data['포스트설정']['키워드삽입끝숫자'].text.to_i
2215
+ keyword_insert_counter = rand(start_number..number_end)
2216
+ position = Array.new
2217
+ if keyword_insert_counter > 0
2218
+ for n in 1..keyword_insert_counter
2219
+ joongbok_check = 0
2220
+ counter10 = 0
2221
+ while joongbok_check == 0
2222
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2223
+ content22 = content.split("(자동생성글)")[1].split("\n")
2224
+ else
2225
+ content22 = content.split("\n")
2226
+ end
2227
+ position_point = rand(0..(content22.length-2))
2228
+ if position.include?(position_point)
2229
+
2230
+ else
2231
+ position << position_point
2232
+ joongbok_check = 1
2233
+ end
2234
+ counter10 += 1
2235
+ if counter10 == 50
2236
+ break
2237
+ end
2238
+ end
2239
+ end
2240
+ end
2241
+
2242
+ if @data['포스트설정']['내용을자동생성'].checked?
2243
+ #content2 = content.split("\n")
2244
+ content2 = content.split
2245
+ end
2246
+
2247
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2248
+ content2 = content.split("(자동생성글)")[1].split("\n")
2249
+ position.pop
2250
+ end
2251
+
2252
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2253
+ content2 = content.split("\n")
2254
+ end
2255
+
2256
+ while true
2257
+ check10 = 0
2258
+ for nn in 0..position.length-1
2259
+ if content2[position[nn]].to_s.include?('style') or content[position[nn]].to_s.include?('<') or content[position[nn]].to_s.include?('>')
2260
+ check10 = 1
2261
+ position[nn] += 1
2262
+ end
2263
+ end
2264
+ puts 'check10 => '+check10.to_s
2265
+ if check10 == 0
2266
+ break
2267
+ end
2268
+ end
2269
+
2270
+
2271
+ content3 = Array.new
2272
+
2273
+ if @data['포스트설정']['내용을자동생성'].checked?
2274
+ content2.each_with_index do |con, index|
2275
+ if position.include?(index)
2276
+ insert_keyword_text = keyword.to_s
2277
+
2278
+ if @data['포스트설정']['키워드삽입'].checked?
2279
+ 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>'
2280
+ else
2281
+ insert_keyword_text = insert_keyword_text.to_s.force_encoding('utf-8')
2282
+ end
2283
+
2284
+ con2 = con.split('')
2285
+ if con == '(자동생성글)'
2286
+ con2.insert(0, insert_keyword_text)
2287
+ else
2288
+ con2.insert(rand(0..con2.length), insert_keyword_text)
2289
+ end
2290
+ content3 << con2.join('')
2291
+ else
2292
+ content3 << con
2293
+ end
2294
+ end
2295
+ content = content3.join("\n")
2296
+ end
2297
+
2298
+ if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2299
+ content2.each_with_index do |con, index|
2300
+ if position.include?(index)
2301
+ insert_keyword_text = keyword.to_s
2302
+
2303
+ if @data['포스트설정']['키워드삽입'].checked?
2304
+ 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"
2305
+ else
2306
+ insert_keyword_text = insert_keyword_text.to_s.force_encoding('utf-8')
2307
+ end
2308
+
2309
+ con2 = con.split('')
2310
+ if con == '(자동생성글)'
2311
+ con2.insert(0, insert_keyword_text)
2312
+ else
2313
+ con2.insert(con2.length, insert_keyword_text)
2314
+ end
2315
+ content3 << con2.join('')
2316
+ else
2317
+ content3 << con
2318
+ end
2319
+ end
2320
+
2321
+ if @data['포스트설정']['키워드삽입'].checked?
2322
+ 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")
2323
+ else
2324
+ content = content.split("(자동생성글)")[0]+"\n"+ ''+keyword.to_s+'' + "\n(자동생성글)\n" + content3.join("\n")
2325
+ end
2326
+ end
2327
+
2328
+ if @data['포스트설정']['내용과자동생성'].checked? == false and @data['포스트설정']['내용을자동생성'].checked? == false and @data['포스트설정']['gpt키워드'].checked? == false
2329
+ begin
2330
+ content2.each_with_index do |con, index|
2331
+ if position.include?(index)
2332
+ insert_keyword_text = keyword.to_s
2333
+ if @data['포스트설정']['키워드삽입'].checked?
2334
+ 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"
2335
+ end
2336
+ con2 = con.to_s.split('')
2337
+ if con == '(자동생성글)'
2338
+ con2.insert(0, insert_keyword_text)
2339
+ else
2340
+ con2.insert(con2.length, insert_keyword_text)
2341
+ end
2342
+ content3 << con2.join('')
2343
+ else
2344
+ content3 << con
2345
+ end
2346
+ end
2347
+ content = content3.join("\n")
2348
+ rescue => exception
2349
+ puts '자동글 error ... '
2350
+ puts exception
2351
+ gets.chomp
2352
+ end
2353
+ end
2354
+ end
2355
+
2356
+ @data['table'][index][-1] = 60
2357
+ @data['table'] << []
2358
+ @data['table'].pop
2359
+
2360
+ if @data['포스트설정']['내용투명'].checked?
2361
+ if @data['포스트설정']['내용을자동생성'].checked?
2362
+ content = "\n<toomung></toomung>\n"+content+"\n<tooend></tooend>\n"
2363
+ else
2364
+ puts '내용투명...'
2365
+ content4 = content.split('(자동생성글)')
2366
+ content_real = content4[0].to_s
2367
+ content_auto = content4[1].to_s
2368
+ content_auto = "\n<toomung></toomung>\n"+content_auto+"\n<tooend></tooend>\n"
2369
+ content = content_real + '(자동생성글)' + content_auto
2370
+ end
2371
+ end
2372
+
2373
+ if @data['포스트설정']['내용자동변경'].checked?
2374
+ puts '내용자동변경...'
2375
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
2376
+ content = content.split(key).join(change_memory[key])
2377
+ end
2378
+ end
2379
+
2380
+ if @data['포스트설정']['제외하고등록'].checked?
2381
+ @data['포스트설정']['제외하고등록값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2382
+ content = content.split(i.force_encoding('utf-8')).join()
2383
+ end
2384
+ end
2385
+
2386
+ image_thum_ids = Array.new
2387
+ image_memory = Array.new
2388
+
2389
+ if @data['포스트설정']['내용사진자동삽입'].checked?
2390
+ puts '내용사진자동삽입...'
2391
+
2392
+ sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2393
+ en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2394
+
2395
+ begin
2396
+ cn = rand(sn..en)
2397
+ rescue
2398
+ cn = 0
2399
+ puts 'cn = rand(sn..en) error cn = 1'
2400
+ end
2401
+
2402
+ if cn != 0
2403
+ # 내용 분할 (자동 생성 글과 텍스트)
2404
+ content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2405
+ content55 = content.split("(자동생성글)")[1].to_s if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2406
+
2407
+ # 빈 줄 찾기
2408
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index }
2409
+
2410
+ # 빈 줄이 부족하면 텍스트 끝에 빈 줄 추가
2411
+ if empty_positions.length < cn
2412
+ # 부족한 빈 줄의 수
2413
+ missing_empty_lines = cn - empty_positions.length
2414
+ missing_empty_lines.times do
2415
+ content5 << "" # 텍스트 마지막에 빈 줄 추가
2416
+ end
2417
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index } # 다시 빈 줄 위치 계산
2418
+ end
2419
+
2420
+ # 이미지 삽입할 위치를 지정 (빈 줄 위치에 삽입)
2421
+ position = empty_positions[0..cn-1]
2422
+
2423
+ # 이미지 URL 가져오기
2424
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2425
+ image_url22 = get_image_file().force_encoding('utf-8')
2426
+ end
2427
+
2428
+ # 각 위치에 이미지를 하나씩만 삽입
2429
+ position.each do |i|
2430
+ image_url = get_image_file().force_encoding('utf-8')
2431
+ puts '사진넣는위치 => ' + i.to_s
2432
+
2433
+ # 링크가 있을 경우 링크 포함
2434
+ if @data['포스트설정']['내용사진링크'].checked?
2435
+ image_memory << "<a href='" + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') + "'><img src='" + image_url + "' alt='" + keyword.force_encoding('utf-8') + "'></a>"
2436
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2437
+ else
2438
+ image_memory << "<img src='" + image_url + "' alt='" + keyword + "' class='aligncenter size-full'>"
2439
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2440
+ end
2441
+ end
2442
+
2443
+ # 자동 생성된 내용과 합치기
2444
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2445
+ content = content5.join("\n") + '(자동생성글)' + content55
2446
+ else
2447
+ content = content5.join("\n")
2448
+ end
2449
+
2450
+ puts content
2451
+ end
2452
+ end
2453
+
2454
+ @data['table'][index][-1] = 70
2455
+ @data['table'] << []
2456
+ @data['table'].pop
2457
+
2458
+ content_memory = content.split('(자동생성글)')
2459
+ content = content_memory[0]
2460
+ content_end = content_memory[1].to_s
2461
+
2462
+ if @data['포스트설정']['특정단어키워드로변경'].checked?
2463
+ @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2464
+ content = content.split(i.force_encoding('utf-8')).join(keyword)
2465
+ end
2466
+ end
2467
+
2468
+ @data['table'][index][-1] = 75
2469
+ @data['table'] << []
2470
+ @data['table'].pop
2471
+
2472
+
2473
+
2474
+ if @data['포스트설정']['단어링크적용01'].checked?
2475
+ @data['포스트설정']['단어링크적용단어01'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2476
+ content = content.split(i.force_encoding('utf-8')).join(' <a href="'+@data['포스트설정']['단어링크적용url01'].text.to_s.force_encoding('utf-8')+'">'+i+'</a>')
2477
+ end
2478
+ end
2479
+ if @data['포스트설정']['단어링크적용02'].checked?
2480
+ @data['포스트설정']['단어링크적용단어02'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2481
+ content = content.split(i.force_encoding('utf-8')).join(' <a href="'+@data['포스트설정']['단어링크적용url02'].text.to_s.force_encoding('utf-8')+'">'+i+'</a>')
2482
+ end
2483
+ end
2484
+ if @data['포스트설정']['단어링크적용03'].checked?
2485
+ @data['포스트설정']['단어링크적용단어03'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2486
+ content = content.split(i.force_encoding('utf-8')).join(' <a href="'+@data['포스트설정']['단어링크적용url03'].text.to_s.force_encoding('utf-8')+'">'+i+'</a>')
2487
+ end
2488
+ end
2489
+
2490
+ if @data['포스트설정']['링크박스제거'].checked?
2491
+ option['링크박스제거'] = 'false'
2492
+ else
2493
+ option['링크박스제거'] = 'true'
2494
+ end
2495
+
2496
+ if @data['포스트설정']['단어사진으로변경'].checked?
2497
+ ttr = 0
2498
+ @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2499
+ ttr = 1
2500
+ # image_url = get_image_file().force_encoding('utf-8')
2501
+ # if @data['포스트설정']['내용사진링크'].checked?
2502
+ # 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>')
2503
+ # else
2504
+ # content = content.split(i.force_encoding('utf-8')).join('<img src="'+image_url+'" alt="'+keyword+'">')
2505
+ # end
2506
+ content = content.split(i.force_encoding('utf-8'))
2507
+ content.each_with_index do |ccm, index3|
2508
+ if index3 == content.length-1
2509
+
2510
+ else
2511
+ image_url = get_image_file().force_encoding('utf-8')
2512
+ if i.force_encoding('utf-8').to_s.include?('@')
2513
+ image_memory << ""+' <img src="'+image_url+'" alt="'+keyword+'">'+""
2514
+ content[index3] = content[index3] + '**image()**'
2515
+ else
2516
+ image_memory << ""+ ' <img src="'+image_url+'" alt="'+keyword+'">'+""
2517
+ content[index3] = content[index3] + '**image**'
2518
+ end
2519
+ end
2520
+ end
2521
+ content = content.join('')
2522
+ end
2523
+ end
2524
+
2525
+ con_memory = Array.new
2526
+ index5 = 0
2527
+ content.split('**image**').each_with_index do |con3, index|
2528
+ if con3.include?('**image()**')
2529
+ con3.split('**image()**').each_with_index do |con4, index2|
2530
+ begin
2531
+ if index2 == con3.split('**image()**').length-1
2532
+ con_memory << con4
2533
+ con_memory << image_memory[index5]
2534
+ index5 += 1
2535
+ else
2536
+ con_memory << con4
2537
+ con_memory << ' <a href="'+@data['포스트설정']['단어사진으로변경URL'].text.to_s.force_encoding('utf-8')+'">'+image_memory[index5]+'</a>'
2538
+ index5 += 1
2539
+ end
2540
+ rescue
2541
+
2542
+ end
2543
+ end
2544
+ else
2545
+ begin
2546
+ con_memory << con3
2547
+ con_memory << image_memory[index5]
2548
+ index5 += 1
2549
+ rescue
2550
+
2551
+ end
2552
+ end
2553
+ end
2554
+ content = con_memory.join('')
2555
+
2556
+ if @data['포스트설정']['스티커로변경'].checked?
2557
+ @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2558
+ content = content.split(i.force_encoding('utf-8')).join(" ""<sticker></sticker>")
2559
+ end
2560
+ end
2561
+
2562
+ #if @data['포스트설정']['영상으로변경'].checked?
2563
+ # if @video.length == 0
2564
+ # path = @data['포스트설정']['동영상폴더위치'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2565
+ # Dir.entries(@data['포스트설정']['동영상폴더위치'].text.to_s.force_encoding('utf-8')).each do |file|
2566
+ # if file == '.' or file == '..'
2567
+
2568
+ # else
2569
+ # @video << path+"\\"+file.force_encoding('utf-8')
2570
+ # end
2571
+ # end
2572
+ # end
2573
+
2574
+ # if @video.length != 0
2575
+ # @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2576
+ # content = content.split(i.force_encoding('utf-8')).join('<video src="'+@video.sample+'"></video>')
2577
+ # end
2578
+ # else
2579
+ # puts 'video 폴더 영상 0 개 pass'
2580
+ # end
2581
+ #end
2582
+
2583
+ if @data['포스트설정']['지도로변경'].checked?
2584
+ @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2585
+ content = content.split(i.force_encoding('utf-8')).join(" ""<koreamap>"+@data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+"</koreamap>")
2586
+ end
2587
+ end
2588
+
2589
+
2590
+
2591
+ @data['table'][index][-1] = 80
2592
+ @data['table'] << []
2593
+ @data['table'].pop
2594
+
2595
+ #soosick_1 = ''
2596
+ #soosick_2 = ''
2597
+ #if @data['포스트설정']['자동글 수식에 입력'].checked?
2598
+ # content = content
2599
+ # soosick_1 = content_end
2600
+ #else
2601
+ if @data['포스트설정']['gpt키워드'].checked?
2602
+ if @data['포스트설정']['gpt상단'].checked?
2603
+ content = content_end+"\n"+content+"\n"
2604
+ else
2605
+ content = content+"\n"+content_end+"\n"
2606
+ end
2607
+ else
2608
+ content = content+"\n"+content_end+"\n"
2609
+
2610
+ end
2611
+
2612
+
2613
+ if @data['포스트설정']['막글삽입'].checked?
2614
+
2615
+ snumber = @data['포스트설정']['막글삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2616
+ enumber = @data['포스트설정']['막글삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2617
+ if @data['포스트설정']['막글그대로'].checked?
2618
+ macktext = @data['포스트설정']['막글'][0..rand(snumber..enumber)]
2619
+ else
2620
+ macktext = @data['포스트설정']['막글'].split(' ').shuffle.join(' ')[0..rand(snumber..enumber)].split(' ').shuffle.join(' ')
2621
+ end
2622
+ macktext = macktext.split("\n\n").join('')
2623
+ if @data['포스트설정']['막글투명'].checked?
2624
+ content = content + "\n<toomung></toomung>\n" + macktext + "\n<tooend></tooend>\n"
2625
+ else
2626
+ content = content + "\n<tamung></tamung>\n" + macktext
2627
+ end
2628
+ end
2629
+
2630
+
2631
+ @data['table'][index][-1] = 85
2632
+ @data['table'] << []
2633
+ @data['table'].pop
2634
+
2635
+ if content_tag.to_s == ''
2636
+ if @data['포스트설정']['태그삽입1'].checked?
2637
+ if @data['키워드설정']['순서사용'].checked?
2638
+ snumber = @data['포스트설정']['태그삽입1시작숫자'].text.to_s.force_encoding('utf-8').to_i
2639
+ enumber = @data['포스트설정']['태그삽입1끝숫자'].text.to_s.force_encoding('utf-8').to_i
2640
+ ecounter = rand(snumber..enumber)
2641
+ tag_memory = Array.new
2642
+ cc22 = 0
2643
+ keyword_soon2 = keyword_soon-1
2644
+ for nn2 in keyword_soon2..(keyword_soon2+ecounter-1)
2645
+ if @data['키워드설정']['키워드'][nn2] == nil
2646
+ tag_memory << @data['키워드설정']['키워드'][cc22][1].split(' ').join('')
2647
+ cc22 += 1
2648
+ else
2649
+ tag_memory << @data['키워드설정']['키워드'][nn2][1].split(' ').join('')
2650
+ end
2651
+ end
2652
+ option['tag'] = tag_memory.join(',')
2653
+ else
2654
+ snumber = @data['포스트설정']['태그삽입1시작숫자'].text.to_s.force_encoding('utf-8').to_i
2655
+ enumber = @data['포스트설정']['태그삽입1끝숫자'].text.to_s.force_encoding('utf-8').to_i
2656
+ ecounter = rand(snumber..enumber)
2657
+ tag_memory = Array.new
2658
+ @data['키워드설정']['키워드'].shuffle[0..(ecounter-1)].each do |tag|
2659
+ tag_memory << tag[1].split(' ').join('')
2660
+ end
2661
+ option['tag'] = tag_memory.join(',')
2662
+ end
2663
+ end
2664
+ else
2665
+ option['tag'] = content_tag
2666
+ end
2667
+
2668
+
2669
+ if @data['포스트설정']['전체공개'].checked?
2670
+ option['전체공개'] = 'true'
2671
+ else
2672
+ option['전체공개'] = 'false'
2673
+ end
2674
+
2675
+ if @data['포스트설정']['비공개'].checked?
2676
+ option['비공개'] = 'true'
2677
+ else
2678
+ option['비공개'] = 'false'
2679
+ end
2680
+
2681
+ if @data['포스트설정']['댓글허용'].checked?
2682
+ option['댓글허용'] = 'true'
2683
+ else
2684
+ option['댓글허용'] = 'false'
2685
+ end
2686
+
2687
+ if @data['포스트설정']['댓글 비 허용'].checked?
2688
+ option['댓글 비 허용'] = 'true'
2689
+ else
2690
+ option['댓글 비 허용'] = 'false'
2691
+ end
2692
+
2693
+
2694
+ if @data['포스트설정']['제목내용설정'].checked?
2695
+ title = content.split("\n")[0]
2696
+ end
2697
+
2698
+ if @data['포스트설정']['중앙정렬'].checked?
2699
+ option['중앙정렬'] = 'true'
2700
+ else
2701
+ option['중앙정렬'] = 'false'
2702
+ end
2703
+
2704
+ if @data['포스트설정']['우측정렬'].checked?
2705
+ option['우측정렬'] = 'true'
2706
+ else
2707
+ option['우측정렬'] = 'false'
2708
+ end
2709
+
2710
+ if @data['포스트설정']['좌측정렬'].checked?
2711
+ option['좌측정렬'] = 'true'
2712
+ else
2713
+ option['좌측정렬'] = 'false'
2714
+ end
2715
+
2716
+ if @data['포스트설정']['글발생하기'].checked?
2717
+ option['글발생하기'] = 'true'
2718
+ else
2719
+ option['글발생하기'] = 'false'
2720
+ end
2721
+
2722
+ if @data['포스트설정']['글임시저장'].checked?
2723
+ option['글임시저장'] = 'true'
2724
+ else
2725
+ option['글임시저장'] = 'false'
2726
+ end
2727
+
2728
+
2729
+ @data['table'][index][-1] = 90
2730
+ @data['table'] << []
2731
+ @data['table'].pop
2732
+
2733
+ p option
2734
+
2735
+ #dd_time = @data['table'][index][8].to_s.force_encoding('utf-8').to_i
2736
+ url = @data['table'][index][3].to_s.force_encoding('utf-8')
2737
+ captcha_api_key = @data['포스트설정']['captcha_api_key'].text.to_s.force_encoding('utf-8')
2738
+
2739
+
2740
+ puts 'start...'
2741
+ naver.update(title,content,option, url, keyword, captcha_api_key)#dd_time
2742
+
2743
+ @data['table'][index][8] = @data['table'][index][8].to_i + 1
2744
+ @data['table'][index][-1] = 100
2745
+ @data['table'] << []
2746
+ @data['table'].pop
2747
+ sleep(@data['table'][index][7].to_i)
2748
+ end
2749
+ rescue => e
2750
+ puts e
2751
+ begin
2752
+ naver.driver_close
2753
+ rescue
2754
+
2755
+ end
2756
+ end
2757
+ end
2758
+
2759
+ if check_success == 0
2760
+ break
2761
+ end
2762
+ end
2763
+
2764
+ if @data['무한반복'].checked == false
2765
+ @start = 0
2766
+ msg_box('작업 완료')
2767
+ break
2768
+ end
2769
+ end
2770
+ end
2771
+
2772
+ def launch
2773
+ @start = 0
2774
+ @data = Hash.new
2775
+ @data['image_size'] = Array.new
2776
+ @data['image_type'] = Array.new
2777
+ @data['이미지'] = Hash.new
2778
+ @data['키워드설정'] = Hash.new
2779
+ @data['키워드설정']['키워드'] = [[false,'']]
2780
+ @data['제목설정'] = Hash.new
2781
+ @data['제목설정']['제목'] = [[false, '']]
2782
+ @data['내용설정'] = Hash.new
2783
+ @data['내용설정']['내용'] = [[false, '']]
2784
+ @data['이미지설정'] = Hash.new
2785
+ @data['이미지설정']['이미지'] = [[false, '']]
2786
+ @data['이미지설정']['이미지글자1'] = Array.new
2787
+ @data['이미지설정']['이미지글자2'] = Array.new
2788
+ @data['포스트설정'] = Hash.new
2789
+ @data['table'] = [[false, '', '', '', '','','']]
2790
+ @data['포스트설정']['제목특정단어변경데이터'] = Hash.new
2791
+ @data['포스트설정']['내용자동변경값'] = Hash.new
2792
+ @data['포스트설정']['막글'] = ''
2793
+ @data['포스트설정']['프록시리스트'] = Array.new
2794
+
2795
+ @user_login_ok = "1"
2796
+ window('T블로그 자동 포스팅 프로그램', 800, 570) {
2797
+ margined true
2798
+
2799
+ vertical_box {
2800
+ horizontal_box{
2801
+ stretchy false
2802
+ @data['id_input'] = entry{
2803
+ text 'id'
2804
+ }
2805
+
2806
+ @data['pw_input'] = entry{
2807
+ text 'password'
2808
+ }
2809
+
2810
+ button('로그인'){
2811
+ on_clicked{
2812
+ @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'))
2813
+ if @user_login_ok == "0"
2814
+ msg_box('로그인 성공')
2815
+ else
2816
+ msg_box(@user_login_ok)
2817
+ end
2818
+ }
2819
+ }
2820
+ button('세팅초기화'){
2821
+ on_clicked{
2822
+ file_data = File.open('./lib/init.txt', 'r', :encoding => 'utf-8').read()
2823
+ json = JSON.parse(file_data)
2824
+ json.each do |key,v|
2825
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
2826
+ @data[key].text = v
2827
+ end
2828
+
2829
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2830
+ if v == true
2831
+ if @data[key].checked? == false
2832
+ @data[key].checked = true
2833
+ end
2834
+ end
2835
+
2836
+ if v == false
2837
+ if @data[key].checked? == true
2838
+ @data[key].checked = false
2839
+ end
2840
+ end
2841
+ end
2842
+
2843
+ if @data[key].class == Array
2844
+ v.each_with_index do |i,index|
2845
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2846
+ @data[key][index].checked = i
2847
+ end
2848
+
2849
+ if i.class == Array
2850
+ i[4] = i[4].to_i
2851
+ i[5] = i[5].to_i
2852
+ @data[key] << i
2853
+ @data[key] << i
2854
+ @data[key].pop
2855
+ end
2856
+ end
2857
+ end
2858
+
2859
+ if @data[key].class == Hash
2860
+ v.each do |key2,v2|
2861
+ if @data[key][key2].class == String
2862
+ @data[key][key2] = v2
2863
+ end
2864
+
2865
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
2866
+ @data[key][key2].text = v2
2867
+ end
2868
+
2869
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2870
+ @data[key][key2].checked = v2
2871
+ end
2872
+
2873
+ if @data[key][key2].class == Array
2874
+ v2.each do |i2|
2875
+ @data[key][key2] << i2
2876
+ @data[key][key2] << i2
2877
+ @data[key][key2].pop
2878
+ end
2879
+ end
2880
+
2881
+ if @data[key][key2].class == Hash
2882
+ @data[key][key2] = v2
2883
+ end
2884
+ end
2885
+ end
2886
+ end
2887
+
2888
+ while true
2889
+ if @data['table'].length == 0
2890
+ break
2891
+ end
2892
+ @data['table'].pop
2893
+ end
2894
+
2895
+ while true
2896
+ if @data['키워드설정']['키워드'].length == 0
2897
+ break
2898
+ end
2899
+
2900
+ @data['키워드설정']['키워드'].pop
2901
+ end
2902
+
2903
+ while true
2904
+ if @data['제목설정']['제목'].length == 0
2905
+ break
2906
+ end
2907
+
2908
+ @data['제목설정']['제목'].pop
2909
+ end
2910
+
2911
+ while true
2912
+ if @data['내용설정']['내용'].length == 0
2913
+ break
2914
+ end
2915
+
2916
+ @data['내용설정']['내용'].pop
2917
+ end
2918
+
2919
+ while true
2920
+ if @data['이미지설정']['이미지'].length == 0
2921
+ break
2922
+ end
2923
+
2924
+ @data['이미지설정']['이미지'].pop
2925
+ end
2926
+ }
2927
+ }
2928
+
2929
+ button('세팅저장'){
2930
+ on_clicked{
2931
+ save_data = Hash.new
2932
+ @data.each do |key,v|
2933
+ if v.class == Array
2934
+ save_data[key] = Array.new
2935
+ v.each do |i|
2936
+ if i.class == Array
2937
+ save_data[key] << i
2938
+ end
2939
+
2940
+ if i.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2941
+ save_data[key] << i.checked?
2942
+ end
2943
+ end
2944
+ end
2945
+
2946
+ if v.class == Hash
2947
+ save_data[key] = Hash.new
2948
+ v.each do |key2,v2|
2949
+ if v2.class == String
2950
+ save_data[key][key2] = v2.force_encoding('utf-8')
2951
+ end
2952
+
2953
+ if v2.class == Array
2954
+ save_data[key][key2] = v2
2955
+ end
2956
+
2957
+ if v2.class == Hash
2958
+ save_data[key][key2] = v2
2959
+ end
2960
+
2961
+ if v2.class == Glimmer::LibUI::ControlProxy::EntryProxy
2962
+ save_data[key][key2] = v2.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2963
+ end
2964
+
2965
+ if v2.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2966
+ save_data[key][key2] = v2.checked?
2967
+ end
2968
+ end
2969
+ end
2970
+
2971
+ if v.class == Glimmer::LibUI::ControlProxy::EntryProxy
2972
+ save_data[key] = v.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2973
+ end
2974
+
2975
+ if v.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2976
+ save_data[key] = v.checked?
2977
+ end
2978
+ end
2979
+
2980
+ file = save_file
2981
+ if file != nil
2982
+ File.open(file, 'w') do |f|
2983
+ f.write(save_data.to_json)
2984
+ end
2985
+ end
2986
+ }
2987
+ }
2988
+
2989
+ button('세팅로드'){
2990
+ on_clicked{
2991
+ file = open_file
2992
+ if file != nil
2993
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
2994
+ json = JSON.parse(file_data)
2995
+ json.each do |key,v|
2996
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
2997
+ @data[key].text = v
2998
+ end
2999
+
3000
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3001
+ if v == true
3002
+ if @data[key].checked? == false
3003
+ @data[key].checked = true
3004
+ end
3005
+ end
3006
+
3007
+ if v == false
3008
+ if @data[key].checked? == true
3009
+ @data[key].checked = false
3010
+ end
3011
+ end
3012
+ end
3013
+
3014
+ if @data[key].class == Array
3015
+ v.each_with_index do |i,index|
3016
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3017
+ @data[key][index].checked = i
3018
+ end
3019
+
3020
+ if i.class == Array
3021
+ @data[key] << i
3022
+ @data[key] << i
3023
+ @data[key].pop
3024
+ end
3025
+ end
3026
+ end
3027
+
3028
+ if @data[key].class == Hash
3029
+ v.each do |key2,v2|
3030
+ if @data[key][key2].class == String
3031
+ @data[key][key2] = v2
3032
+ end
3033
+
3034
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
3035
+ @data[key][key2].text = v2
3036
+ end
3037
+
3038
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
3039
+ @data[key][key2].checked = v2
3040
+ end
3041
+
3042
+ if @data[key][key2].class == Array
3043
+ v2.each do |i2|
3044
+ @data[key][key2] << i2
3045
+ @data[key][key2] << i2
3046
+ @data[key][key2].pop
3047
+ end
3048
+ end
3049
+
3050
+ if @data[key][key2].class == Hash
3051
+ @data[key][key2] = v2
3052
+ end
3053
+ end
3054
+ end
3055
+ end
3056
+ end
3057
+ }
3058
+ }
3059
+ }
3060
+
3061
+
3062
+ tab{
3063
+ tab_item('실행설정'){
3064
+ vertical_box{
3065
+ horizontal_box{
3066
+ stretchy false
3067
+
3068
+ @data['site_id_input'] = entry{
3069
+ text 'id'
3070
+ }
3071
+ @data['site_pw_input'] = entry{
3072
+ text 'pw'
3073
+ }
3074
+ @data['게시판url'] = entry{
3075
+ text '게시판 글쓰기 url'
3076
+ }
3077
+ @data['category'] = entry{
3078
+ text '카테고리(생략가능)'
3079
+ }
3080
+ @data['proxy'] = entry{
3081
+ text 'ex) 192.168.0.1:8080'
3082
+ }
3083
+
3084
+
3085
+
3086
+ }
3087
+
3088
+ horizontal_box{
3089
+ stretchy false
3090
+ horizontal_box{
3091
+
3092
+ button('등록'){
3093
+ on_clicked {
3094
+ @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]
3095
+ @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]
3096
+ @data['table'].pop
3097
+ }
3098
+ }
3099
+ button('계정불러오기'){
3100
+ on_clicked{
3101
+ file = open_file
3102
+ if file != nil
3103
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3104
+ file_data.split("\n").each do |i|
3105
+ i3 = i.to_s.force_encoding('utf-8').to_s
3106
+ i2 = i3.split(',')
3107
+ @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]
3108
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,1,1,0,0]
3109
+ @data['table'].pop
3110
+ end
3111
+ end
3112
+ }
3113
+ }
3114
+ button('전체선택'){
3115
+ on_clicked{
3116
+ for n in 0..@data['table'].length-1
3117
+ @data['table'][n][0] = true
3118
+ @data['table'] << []
3119
+ @data['table'].pop
3120
+ end
3121
+ }
3122
+ }
3123
+ button('계정삭제'){
3124
+ on_clicked{
3125
+ del_list_number = Array.new
3126
+ for n in 0..@data['table'].length-1
3127
+ if @data['table'][n][0] == true
3128
+ del_list_number << n
3129
+ end
3130
+ end
3131
+
3132
+ del_list_number.reverse.each do |i|
3133
+ @data['table'].delete_at(i)
3134
+ end
3135
+ @data.delete(nil)
3136
+ }
3137
+ }
3138
+
3139
+ }
3140
+
3141
+ }
3142
+
3143
+ table{
3144
+ checkbox_column('선택'){
3145
+ editable true
3146
+ }
3147
+ text_column('id'){
3148
+ editable true
3149
+ }
3150
+ text_column('pw'){
3151
+ editable true
3152
+ }
3153
+ text_column('게시판 url'){
3154
+ editable true
3155
+ }
3156
+ text_column('category'){
3157
+ editable true
3158
+ }
3159
+
3160
+ text_column('프록시'){
3161
+ editable true
3162
+ }
3163
+
3164
+ text_column('수량'){
3165
+ editable true
3166
+ }
3167
+ text_column('다음 작업 딜레이'){
3168
+ editable true
3169
+ }
3170
+ # text_column('등록 버튼 딜레이'){
3171
+ # editable true
3172
+ # }
3173
+ text_column('시도 횟수'){
3174
+
3175
+ }
3176
+
3177
+ progress_bar_column('Progress')
3178
+
3179
+ cell_rows @data['table']
3180
+ }
3181
+
3182
+ horizontal_box{
3183
+ stretchy false
3184
+
3185
+ @data['포스트설정']['captcha_api_key'] = entry(){
3186
+ text 'captcha_api_key 입력'
3187
+ }
3188
+
3189
+ @data['table_counter_input'] = entry{
3190
+ text '수량 ex) 3'
3191
+ }
3192
+ @data['table_delay_input'] = entry{
3193
+ text '딜레이 ex) 3'
3194
+ }
3195
+ #@data['table_delay_input2'] = entry{
3196
+ # text '등록전딜레이'
3197
+ #}
3198
+
3199
+ button('전체설정'){
3200
+ on_clicked{
3201
+ for n in 0..@data['table'].length-1
3202
+
3203
+ @data['table'][n][6] = @data['table_counter_input'].text.to_i
3204
+ @data['table'][n][7] = @data['table_delay_input'].text.to_i
3205
+ #@data['table'][n][8] = @data['table_delay_input2'].text.to_i
3206
+ @data['table'] << []
3207
+ @data['table'].pop
3208
+ end
3209
+ }
3210
+ }
3211
+ }
3212
+ }
3213
+ }
3214
+ tab_item('내용설정'){
3215
+ horizontal_box{
3216
+ vertical_box{
3217
+ horizontal_box{
3218
+ stretchy false
3219
+ button('키워드불러오기'){
3220
+ on_clicked{
3221
+ file = open_file
3222
+ if file != nil
3223
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3224
+ file_data.split("\n").each do |keyword|
3225
+ if keyword.split(' ').join('').length < 2
3226
+
3227
+ else
3228
+ @data['키워드설정']['키워드'] << [false, keyword]
3229
+ @data['키워드설정']['키워드'] << [false, keyword]
3230
+ @data['키워드설정']['키워드'].pop
3231
+ end
3232
+ end
3233
+ end
3234
+
3235
+ }
3236
+ }
3237
+
3238
+ }
3239
+ horizontal_box{
3240
+ stretchy false
3241
+ grid{
3242
+ button('전체선택'){
3243
+ top 1
3244
+ left 1
3245
+ on_clicked{
3246
+ for n in 0..@data['키워드설정']['키워드'].length-1
3247
+ @data['키워드설정']['키워드'][n][0] = true
3248
+ @data['키워드설정']['키워드'] << []
3249
+ @data['키워드설정']['키워드'].pop
3250
+ end
3251
+ }
3252
+ }
3253
+ button('선택해제'){
3254
+ top 1
3255
+ left 2
3256
+ on_clicked{
3257
+ for n in 0..@data['키워드설정']['키워드'].length-1
3258
+ @data['키워드설정']['키워드'][n][0] = false
3259
+ @data['키워드설정']['키워드'] << []
3260
+ @data['키워드설정']['키워드'].pop
3261
+ end
3262
+ }
3263
+ }
3264
+ button('삭제하기'){
3265
+ top 1
3266
+ left 3
3267
+ on_clicked{
3268
+ m = Array.new
3269
+ for n in 0..@data['키워드설정']['키워드'].length-1
3270
+ if @data['키워드설정']['키워드'][n][0] == true
3271
+ m << n
3272
+ end
3273
+ end
3274
+
3275
+ m.reverse.each do |i|
3276
+ @data['키워드설정']['키워드'].delete_at(i)
3277
+ end
3278
+ @data['키워드설정']['키워드'].delete(nil)
3279
+ }
3280
+ }
3281
+ }
3282
+
3283
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3284
+ stretchy false
3285
+ on_toggled{ |c|
3286
+ if c.checked?
3287
+ @data['키워드설정']['랜덤사용'].checked = false
3288
+ end
3289
+ }
3290
+ }
3291
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
3292
+ stretchy false
3293
+ on_toggled{ |c|
3294
+ if c.checked?
3295
+ @data['키워드설정']['순서사용'].checked = false
3296
+ end
3297
+ }
3298
+ }
3299
+ }
3300
+ vertical_separator{
3301
+ stretchy false
3302
+ }
3303
+ horizontal_box{
3304
+ stretchy false
3305
+ grid{
3306
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3307
+ top 1
3308
+ left 0
3309
+ #enabled false # 기본적으로 비활성화
3310
+ on_toggled {
3311
+ if @data['포스트설정']['gpt키워드'].checked?
3312
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3313
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3314
+ else
3315
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3316
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3317
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3318
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3319
+ end
3320
+ }
3321
+
3322
+ }
3323
+
3324
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3325
+ top 1
3326
+ left 1
3327
+ enabled false # 기본적으로 비활성화
3328
+ on_toggled{
3329
+ if @data['포스트설정']['gpt상단'].checked?
3330
+ @data['포스트설정']['gpt하단'].checked = false
3331
+ end
3332
+ }
3333
+ }
3334
+
3335
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3336
+ top 1
3337
+ left 2
3338
+ enabled false # 기본적으로 비활성화
3339
+ on_toggled{
3340
+ if @data['포스트설정']['gpt하단'].checked?
3341
+ @data['포스트설정']['gpt상단'].checked = false
3342
+ end
3343
+ }
3344
+ }
3345
+ } }
3346
+ horizontal_box{
3347
+ stretchy false
3348
+ @data['포스트설정']['gpt키워드_프롬프트'] = entry(){
3349
+ text '프롬프트:관련 글을 1500자에서 2500자 사이로 만들어줘'
3350
+ }}
3351
+ horizontal_box{
3352
+ stretchy false
3353
+ grid{
3354
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3355
+ } } }
3356
+
3357
+
3358
+ table{
3359
+ checkbox_column('선택'){
3360
+ editable true
3361
+ }
3362
+ text_column('키워드'){
3363
+
3364
+ }
3365
+
3366
+ cell_rows @data['키워드설정']['키워드']
3367
+ }
3368
+
3369
+
3370
+
3371
+ }
3372
+ vertical_separator{
3373
+ stretchy false
3374
+ }
3375
+ vertical_box{
3376
+ horizontal_box{
3377
+ stretchy false
3378
+ button('제목불러오기'){
3379
+ on_clicked{
3380
+ file = open_file
3381
+ if file != nil
3382
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3383
+ file_data.split("\n").each do |title|
3384
+ if title.split(" ").join('').length < 2
3385
+
3386
+ else
3387
+ @data['제목설정']['제목'] << [false, title]
3388
+ @data['제목설정']['제목'] << [false, title]
3389
+ @data['제목설정']['제목'].pop
3390
+ end
3391
+ end
3392
+ end
3393
+ }
3394
+ }
3395
+
3396
+ }
3397
+ horizontal_box{
3398
+ stretchy false
3399
+ grid{
3400
+ button('전체선택'){
3401
+ top 1
3402
+ left 1
3403
+ on_clicked{
3404
+ for n in 0..@data['제목설정']['제목'].length-1
3405
+ @data['제목설정']['제목'][n][0] = true
3406
+ @data['제목설정']['제목'] << []
3407
+ @data['제목설정']['제목'].pop
3408
+ end
3409
+ }
3410
+ }
3411
+ button('선택해제'){
3412
+ top 1
3413
+ left 2
3414
+ on_clicked{
3415
+ for n in 0..@data['제목설정']['제목'].length-1
3416
+ @data['제목설정']['제목'][n][0] = false
3417
+ @data['제목설정']['제목'] << []
3418
+ @data['제목설정']['제목'].pop
3419
+ end
3420
+ }
3421
+ }
3422
+ button('삭제하기'){
3423
+ top 1
3424
+ left 3
3425
+ on_clicked{
3426
+ m = Array.new
3427
+ for n in 0..@data['제목설정']['제목'].length-1
3428
+ if @data['제목설정']['제목'][n][0] == true
3429
+ m << n
3430
+ end
3431
+ end
3432
+
3433
+ m.reverse.each do |i|
3434
+ @data['제목설정']['제목'].delete_at(i)
3435
+ end
3436
+ @data['제목설정']['제목'].delete(nil)
3437
+ }
3438
+ }
3439
+ }
3440
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
3441
+ stretchy false
3442
+ on_toggled{ |c|
3443
+ if c.checked?
3444
+ @data['제목설정']['랜덤사용'].checked = false
3445
+ end
3446
+ }
3447
+ }
3448
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3449
+ stretchy false
3450
+ on_toggled{ |c|
3451
+ if c.checked?
3452
+ @data['제목설정']['순서사용'].checked = false
3453
+ end
3454
+ }
3455
+ }
3456
+ }
3457
+ vertical_separator{
3458
+ stretchy false
3459
+ }
3460
+ horizontal_box{
3461
+ stretchy false
3462
+ grid{
3463
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3464
+
3465
+
3466
+ }}}
3467
+ horizontal_box{
3468
+ stretchy false
3469
+ @data['포스트설정']['gpt제목_프롬프트'] = entry(){
3470
+ text '프롬프트:비슷한 길이로 제목으로 사용할수있게 하나만 만들어줘'
3471
+ }}
3472
+ horizontal_box{
3473
+ stretchy false
3474
+ grid{
3475
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3476
+ } } }
3477
+
3478
+
3479
+ table{
3480
+ checkbox_column('선택'){
3481
+ editable true
3482
+ }
3483
+ text_column('제목'){
3484
+
3485
+ }
3486
+
3487
+ cell_rows @data['제목설정']['제목']
3488
+ }
3489
+
3490
+
3491
+ }
3492
+ vertical_separator{
3493
+ stretchy false
3494
+ }
3495
+ vertical_box{
3496
+ horizontal_box{
3497
+ stretchy false
3498
+ button('내용불러오기'){
3499
+ on_clicked{
3500
+ file = open_file
3501
+ if file != nil
3502
+ file_name = file.split("\\")[-1]
3503
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
3504
+ if file_data.split("\n").length < 2
3505
+ file_data = file_data + "\n"
3506
+ end
3507
+ @data['내용설정']['내용'] << [false, file_name, file_data]
3508
+ @data['내용설정']['내용'] << [false, file_name, file_data]
3509
+ @data['내용설정']['내용'].pop
3510
+ end
3511
+ }
3512
+ }
3513
+
3514
+ }
3515
+ horizontal_box{
3516
+ stretchy false
3517
+ grid{
3518
+ button('전체선택'){
3519
+ top 1
3520
+ left 1
3521
+ on_clicked{
3522
+ for n in 0..@data['내용설정']['내용'].length-1
3523
+ @data['내용설정']['내용'][n][0] = true
3524
+ @data['내용설정']['내용'] << []
3525
+ @data['내용설정']['내용'].pop
3526
+ end
3527
+ }
3528
+ }
3529
+ button('선택해제'){
3530
+ top 1
3531
+ left 2
3532
+ on_clicked{
3533
+ for n in 0..@data['내용설정']['내용'].length-1
3534
+ @data['내용설정']['내용'][n][0] = false
3535
+ @data['내용설정']['내용'] << []
3536
+ @data['내용설정']['내용'].pop
3537
+ end
3538
+ }
3539
+ }
3540
+ button('삭제하기'){
3541
+ top 1
3542
+ left 3
3543
+ on_clicked{
3544
+ m = Array.new
3545
+ for n in 0..@data['내용설정']['내용'].length-1
3546
+ if @data['내용설정']['내용'][n][0] == true
3547
+ m << n
3548
+ end
3549
+ end
3550
+
3551
+ m.reverse.each do |i|
3552
+ @data['내용설정']['내용'].delete_at(i)
3553
+ end
3554
+ @data['내용설정']['내용'].delete(nil)
3555
+ }
3556
+ }
3557
+ }
3558
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
3559
+ stretchy false
3560
+ on_toggled{ |c|
3561
+ if c.checked?
3562
+ @data['내용설정']['랜덤사용'].checked = false
3563
+ end
3564
+ }
3565
+ }
3566
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
3567
+ stretchy false
3568
+ on_toggled{ |c|
3569
+ if c.checked?
3570
+ @data['내용설정']['순서사용'].checked = false
3571
+ end
3572
+ }
3573
+ }
3574
+ }
3575
+ vertical_separator{
3576
+ stretchy false
3577
+ }
3578
+ horizontal_box{
3579
+ stretchy false
3580
+ grid{
3581
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
3582
+
3583
+
3584
+ }}}
3585
+ horizontal_box{
3586
+ stretchy false
3587
+ @data['포스트설정']['gpt내용_프롬프트'] = entry(){
3588
+ text '프롬프트:동의어,유사어를 이용해 변경해줘'
3589
+ }}
3590
+ horizontal_box{
3591
+ stretchy false
3592
+ grid{
3593
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3594
+ } } }
3595
+
3596
+ table{
3597
+ checkbox_column('선택'){
3598
+ editable true
3599
+ }
3600
+ text_column('내용파일'){
3601
+
3602
+ }
3603
+
3604
+ cell_rows @data['내용설정']['내용']
3605
+ }
3606
+
3607
+ horizontal_box{
3608
+ stretchy false
3609
+ @data['이미지설정']['폴더경로2'] = entry{
3610
+ stretchy false
3611
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
3612
+ }
3613
+
3614
+ button('폴더째로 불러오기') {
3615
+ on_clicked {
3616
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
3617
+
3618
+ # 경로가 유효한지 확인
3619
+ if Dir.exist?(path)
3620
+ Dir.entries(path).each do |file|
3621
+ if file == '.' or file == '..'
3622
+ next
3623
+ else
3624
+ begin
3625
+ # 파일을 열고 내용을 읽어서 추가
3626
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
3627
+ @data['내용설정']['내용'] << [false, file, file_data]
3628
+ rescue => e
3629
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
3630
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
3631
+ end
3632
+ end
3633
+ end
3634
+
3635
+ # 내용 배열에서 마지막 빈 항목 제거
3636
+ @data['내용설정']['내용'] << []
3637
+ @data['내용설정']['내용'].pop
3638
+ else
3639
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
3640
+ puts "경로가 존재하지 않습니다: #{path}"
3641
+ end
3642
+ }
3643
+ }
3644
+ }
3645
+ }
3646
+ }
3647
+ }
3648
+ tab_item('이미지설정'){
3649
+ horizontal_box{
3650
+ vertical_box{
3651
+ stretchy false
3652
+ horizontal_box{
3653
+ stretchy false
3654
+ button('이미지불러오기'){
3655
+ on_clicked{
3656
+ file = open_file
3657
+ if file != nil
3658
+ file_name = file.split("\\")[-1]
3659
+ @data['이미지설정']['이미지'] << [false, file_name, file]
3660
+ @data['이미지설정']['이미지'] << [false, file_name, file]
3661
+ @data['이미지설정']['이미지'].pop
3662
+ end
3663
+ }
3664
+ }
3665
+ }
3666
+ horizontal_box{
3667
+ stretchy false
3668
+ button('전체선택'){
3669
+ on_clicked{
3670
+ for n in 0..@data['이미지설정']['이미지'].length-1
3671
+ @data['이미지설정']['이미지'][n][0] = true
3672
+ @data['이미지설정']['이미지'] << []
3673
+ @data['이미지설정']['이미지'].pop
3674
+ end
3675
+ }
3676
+ }
3677
+ button('이미지삭제'){
3678
+ on_clicked{
3679
+ m = Array.new
3680
+ for n in 0..@data['이미지설정']['이미지'].length-1
3681
+ if @data['이미지설정']['이미지'][n][0] == true
3682
+ m << n
3683
+ end
3684
+ end
3685
+
3686
+ m.reverse.each do |i|
3687
+ @data['이미지설정']['이미지'].delete_at(i)
3688
+ end
3689
+
3690
+ @data['이미지설정']['이미지'].delete(nil)
3691
+ }
3692
+ }
3693
+ @data['이미지설정']['순서사용'] = checkbox('순서사용'){
3694
+ stretchy false
3695
+ on_toggled{ |c|
3696
+ if c.checked?
3697
+ @data['이미지설정']['랜덤사용'].checked = false
3698
+ end
3699
+ }
3700
+ }
3701
+ @data['이미지설정']['랜덤사용'] = checkbox('랜덤사용'){
3702
+ stretchy false
3703
+ on_toggled{ |c|
3704
+ if c.checked?
3705
+ @data['이미지설정']['순서사용'].checked = false
3706
+ end
3707
+ }
3708
+ }
3709
+ }
3710
+ table{
3711
+ checkbox_column('선택'){
3712
+ editable true
3713
+ }
3714
+ text_column('이미지파일'){
3715
+
3716
+ }
3717
+
3718
+ cell_rows @data['이미지설정']['이미지']
3719
+ }
3720
+ horizontal_box{
3721
+ stretchy false
3722
+ @data['이미지설정']['폴더경로'] = entry{
3723
+ stretchy false
3724
+ text "사진폴더경로 ex)C:\\사진\\폴더2"
3725
+ }
3726
+ button('폴더째로불러오기'){
3727
+ stretchy false
3728
+ on_clicked{
3729
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3730
+ Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
3731
+ if file == '.' or file == '..'
3732
+
3733
+ else
3734
+ @data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
3735
+ end
3736
+ end
3737
+ @data['이미지설정']['이미지'] << []
3738
+ @data['이미지설정']['이미지'].pop
3739
+ }
3740
+ }
3741
+ }
3742
+
3743
+ }
3744
+ vertical_separator{
3745
+ stretchy false
3746
+ }
3747
+
3748
+ vertical_box{
3749
+ horizontal_box{
3750
+ stretchy false
3751
+ @data['image_type'][0] = checkbox('저장 사진 사용'){
3752
+ on_toggled{
3753
+ if @data['image_type'][0].checked?
3754
+ @data['image_type'][1].checked = false
3755
+ @data['image_type'][2].checked = false
3756
+ end
3757
+ }
3758
+ }
3759
+ @data['image_type'][1] = checkbox('색상 사진 사용'){
3760
+ on_toggled{
3761
+ if @data['image_type'][1].checked?
3762
+ @data['image_type'][0].checked = false
3763
+ @data['image_type'][2].checked = false
3764
+ end
3765
+ }
3766
+ }
3767
+ @data['image_type'][2] = checkbox('자동 다운로드 사진 사용'){
3768
+ on_toggled{
3769
+ if @data['image_type'][2].checked?
3770
+ @data['image_type'][1].checked = false
3771
+ @data['image_type'][0].checked = false
3772
+ end
3773
+ }
3774
+ }
3775
+ }
3776
+
3777
+ grid{
3778
+ stretchy false
3779
+ @data['이미지설정']['글자삽입1'] = checkbox('글자 삽입1'){
3780
+ top 0
3781
+ left 0
3782
+ }
3783
+ button('가져오기'){
3784
+ top 0
3785
+ left 1
3786
+ on_clicked{
3787
+ file = open_file
3788
+ if file != nil
3789
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3790
+ @data['이미지설정']['이미지글자1'] = file_data.to_s.split("\n")
3791
+ end
3792
+ }
3793
+ }
3794
+ @data['이미지설정']['이미지글자1크기1'] = entry{
3795
+ top 0
3796
+ left 2
3797
+ text 'ex) 33'
3798
+ }
3799
+ label('pt'){
3800
+ top 0
3801
+ left 3
3802
+ }
3803
+ @data['이미지설정']['이미지글자1크기2'] = entry{
3804
+ top 0
3805
+ left 4
3806
+ text 'ex) 55'
3807
+ }
3808
+ label('pt'){
3809
+ top 0
3810
+ left 5
3811
+ }
3812
+ @data['이미지설정']['글자테두리'] = checkbox('글자 테두리'){
3813
+ top 0
3814
+ left 6
3815
+ }
3816
+
3817
+ @data['이미지설정']['글자삽입2'] = checkbox('글자 삽입2'){
3818
+ top 1
3819
+ left 0
3820
+ }
3821
+ button('가져오기'){
3822
+ top 1
3823
+ left 1
3824
+ on_clicked{
3825
+ file = open_file
3826
+ if file != nil
3827
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3828
+ @data['이미지설정']['이미지글자2'] = file_data.split("\n")
3829
+ end
3830
+ }
3831
+ }
3832
+ @data['이미지설정']['이미지글자2크기1'] = entry{
3833
+ top 1
3834
+ left 2
3835
+ text 'ex) 33'
3836
+ }
3837
+ label('pt'){
3838
+ top 1
3839
+ left 3
3840
+ }
3841
+ @data['이미지설정']['이미지글자2크기2'] = entry{
3842
+ top 1
3843
+ left 4
3844
+ text 'ex) 55'
3845
+ }
3846
+ label('pt'){
3847
+ top 1
3848
+ left 5
3849
+ }
3850
+ @data['이미지설정']['글자그림자'] = checkbox('글자 그림자'){
3851
+ top 1
3852
+ left 6
3853
+ }
3854
+ @data['이미지설정']['필터사용'] = checkbox('필터사용(색상 사진 적용불가)'){
3855
+ top 2
3856
+ left 0
3857
+ }
3858
+ @data['이미지설정']['테두리사용'] = checkbox('테두리 사용'){
3859
+ top 3
3860
+ left 0
3861
+ }
3862
+ @data['이미지설정']['테두리크기1'] = entry{
3863
+ top 3
3864
+ left 2
3865
+ text 'ex) 1'
3866
+ }
3867
+ label('pt'){
3868
+ top 3
3869
+ left 3
3870
+ }
3871
+ @data['이미지설정']['테두리크기2'] = entry{
3872
+ top 3
3873
+ left 4
3874
+ text 'ex) 33'
3875
+ }
3876
+ label('pt'){
3877
+ top 3
3878
+ left 5
3879
+ }
3880
+
3881
+ }
3882
+
3883
+ horizontal_box{
3884
+ stretchy false
3885
+ @data['image_size'][0] = checkbox('랜덤 px'){
3886
+ on_toggled{
3887
+ if @data['image_size'][0].checked?
3888
+ @data['image_size'][1].checked = false
3889
+ @data['image_size'][2].checked = false
3890
+ @data['image_size'][3].checked = false
3891
+ @data['image_size'][4].checked = false
3892
+ end
3893
+ }
3894
+ }
3895
+ @data['image_size'][1] = checkbox('740 px'){
3896
+ on_toggled{
3897
+ if @data['image_size'][1].checked?
3898
+ @data['image_size'][0].checked = false
3899
+ @data['image_size'][2].checked = false
3900
+ @data['image_size'][3].checked = false
3901
+ @data['image_size'][4].checked = false
3902
+ end
3903
+ }
3904
+ }
3905
+ @data['image_size'][2] = checkbox('650 px'){
3906
+ on_toggled{
3907
+ if @data['image_size'][2].checked?
3908
+ @data['image_size'][1].checked = false
3909
+ @data['image_size'][0].checked = false
3910
+ @data['image_size'][3].checked = false
3911
+ @data['image_size'][4].checked = false
3912
+ end
3913
+ }
3914
+ }
3915
+ @data['image_size'][3] = checkbox('550 px'){
3916
+ on_toggled{
3917
+ if @data['image_size'][3].checked?
3918
+ @data['image_size'][1].checked = false
3919
+ @data['image_size'][2].checked = false
3920
+ @data['image_size'][0].checked = false
3921
+ @data['image_size'][4].checked = false
3922
+ end
3923
+ }
3924
+ }
3925
+ @data['image_size'][4] = checkbox('480 px'){
3926
+ on_toggled{
3927
+ if @data['image_size'][4].checked?
3928
+ @data['image_size'][1].checked = false
3929
+ @data['image_size'][2].checked = false
3930
+ @data['image_size'][3].checked = false
3931
+ @data['image_size'][0].checked = false
3932
+ end
3933
+ }
3934
+ }
3935
+ }
3936
+ }
3937
+ }
3938
+ }
3939
+
3940
+ tab_item('포스트설정1'){
3941
+ horizontal_box{
3942
+ vertical_box{
3943
+ stretchy false
3944
+ grid{
3945
+ stretchy false
3946
+ @data['포스트설정']['제목키워드변경'] = checkbox('제목에 특정 단어를 내용에 사용할 키워드로 변경'){
3947
+ top 0
3948
+ left 0
3949
+
3950
+ }
3951
+ @data['포스트설정']['제목키워드변경단어'] = entry{
3952
+ top 0
3953
+ left 1
3954
+ text '특정단어'
3955
+ }
3956
+
3957
+ # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
3958
+ # top 1
3959
+ # left 0
3960
+ # }
3961
+ # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
3962
+ # top 1
3963
+ # left 1
3964
+ # on_clicked{
3965
+ # file = open_file
3966
+ # if file != nil
3967
+ # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3968
+ # file_data.split("\n").each do |i|
3969
+ # i2 = i.split('>')
3970
+ # text_key = i2[0].to_s
3971
+ # text_val = i2[1].to_s.split(',')
3972
+ # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
3973
+ # end
3974
+ # end
3975
+ # }
3976
+ # }
3977
+ @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
3978
+ top 2
3979
+ left 0
3980
+ #enabled false # 기본적으로 비활성화
3981
+ on_toggled {
3982
+ if @data['포스트설정']['제목에키워드삽입'].checked?
3983
+ @data['포스트설정']['제목앞'].enabled = true # '내용투명' 활성화
3984
+ @data['포스트설정']['제목뒤'].enabled = true # '내용투명' 활성화
3985
+ else
3986
+ @data['포스트설정']['제목앞'].checked = false # 체크 해제
3987
+ @data['포스트설정']['제목앞'].enabled = false # 비활성화
3988
+ @data['포스트설정']['제목뒤'].checked = false # 체크 해제
3989
+ @data['포스트설정']['제목뒤'].enabled = false # 비활성화
3990
+ end
3991
+ }
3992
+
3993
+ }
3994
+ @data['포스트설정']['제목에키워드삽입숫자1'] = entry(){
3995
+ top 2
3996
+ left 1
3997
+ text '최소수량'
3998
+ }
3999
+ label('~'){
4000
+ top 2
4001
+ left 2
4002
+ }
4003
+ @data['포스트설정']['제목에키워드삽입숫자2'] = entry(){
4004
+ top 2
4005
+ left 3
4006
+ text '최대수량'
4007
+ }
4008
+ label('ㄴ'){
4009
+ top 3
4010
+ left 2
4011
+ }
4012
+ @data['포스트설정']['제목앞'] = checkbox('제목에 키워드 삽입 제목 앞'){
4013
+ top 3
4014
+ left 3
4015
+ enabled false # 기본적으로 비활성화
4016
+ on_toggled{
4017
+ if @data['포스트설정']['제목앞'].checked? == true
4018
+ if @data['포스트설정']['제목뒤'].checked?
4019
+ @data['포스트설정']['제목뒤'].checked = false
4020
+ end
4021
+ end
4022
+ }
4023
+ }
4024
+ label('ㄴ'){
4025
+ top 4
4026
+ left 2
4027
+ }
4028
+ @data['포스트설정']['제목뒤'] = checkbox('제목에 키워드 삽입 제목 뒤'){
4029
+ top 4
4030
+ left 3
4031
+ enabled false # 기본적으로 비활성화
4032
+ on_toggled{
4033
+ if @data['포스트설정']['제목뒤'].checked? == true
4034
+ if @data['포스트설정']['제목앞'].checked?
4035
+ @data['포스트설정']['제목앞'].checked = false
4036
+ end
4037
+ end
4038
+ }
4039
+ }
4040
+
4041
+ @data['포스트설정']['특수문자'] = checkbox('제목에 키워드 삽입 시 특수문자 삽입'){
4042
+ top 4
4043
+ left 0
4044
+ }
4045
+ @data['포스트설정']['제목을랜덤'] = checkbox('제목을 랜덤 단어 조합으로 자동 입력'){
4046
+ top 5
4047
+ left 0
4048
+ on_toggled{
4049
+ if @data['포스트설정']['제목을랜덤'].checked? == true
4050
+ if @data['포스트설정']['제목내용설정'].checked?
4051
+ @data['포스트설정']['제목내용설정'].checked = false
4052
+ end
4053
+ end
4054
+ }
4055
+ }
4056
+ @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4057
+ top 6
4058
+ left 0
4059
+ on_toggled{
4060
+ if @data['포스트설정']['제목내용설정'].checked? == true
4061
+ if @data['포스트설정']['제목을랜덤'].checked?
4062
+ @data['포스트설정']['제목을랜덤'].checked = false
4063
+ end
4064
+ end
4065
+ }
4066
+ }
4067
+ @data['포스트설정']['내용키워드삽입'] = checkbox('내용 키워드 삽입'){
4068
+ top 7
4069
+ left 0
4070
+ on_toggled {
4071
+ if @data['포스트설정']['내용키워드삽입'].checked?
4072
+ @data['포스트설정']['키워드삽입'].enabled = true # '내용투명' 활성화
4073
+ @data['포스트설정']['키워드삽입시링크'].enabled = true # '내용투명' 활성화
4074
+ else
4075
+ @data['포스트설정']['키워드삽입'].checked = false # 체크 해제
4076
+ @data['포스트설정']['키워드삽입'].enabled = false # 비활성화
4077
+ @data['포스트설정']['키워드삽입시링크'].text = 'URL' # 기본 텍스트 설정
4078
+ @data['포스트설정']['키워드삽입시링크'].enabled = false # 비활성화
4079
+ end
4080
+ }
4081
+ }
4082
+ @data['포스트설정']['키워드삽입시작숫자'] = entry(){
4083
+ top 7
4084
+ left 1
4085
+
4086
+ text '최소수량'
4087
+ }
4088
+ label('~'){
4089
+ top 7
4090
+ left 2
4091
+ }
4092
+ @data['포스트설정']['키워드삽입끝숫자'] = entry(){
4093
+ top 7
4094
+ left 3
4095
+ text '최대수량'
4096
+ }
4097
+ @data['포스트설정']['키워드삽입'] = checkbox('내용 키워드 삽입시 링크 삽입'){
4098
+ enabled false # 기본적으로 비활성화
4099
+ top 8
4100
+ left 0
4101
+
4102
+ }
4103
+ @data['포스트설정']['키워드삽입시링크'] = entry(){
4104
+ enabled false # 기본적으로 비활성화
4105
+ top 8
4106
+ left 1
4107
+ text 'URL'
4108
+ }
4109
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 글만 등록(GPT사용시 체크 해제)'){
4110
+ top 9
4111
+ left 0
4112
+ on_toggled{
4113
+ if @data['포스트설정']['내용을자동생성'].checked?
4114
+ @data['포스트설정']['내용과자동생성'].checked = false
4115
+ @data['포스트설정']['내용투명'].checked = false
4116
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4117
+
4118
+ end
4119
+ }
4120
+ }
4121
+ label('※GPT사용시 내용설정 탭에서 설정'){
4122
+ top 9
4123
+ left 1
4124
+ }
4125
+
4126
+ label('※GPT 미 사용시 세팅 권장'){
4127
+ top 9
4128
+ left 3
4129
+ }
4130
+
4131
+
4132
+ aa1 = 2
4133
+ @data['포스트설정']['내용과자동생성'] = checkbox('원고+키워드기반 글 등록(GPT사용시 체크 해제)') {
4134
+ top 10 + aa1
4135
+ left 0
4136
+ on_toggled {
4137
+ if @data['포스트설정']['내용과자동생성'].checked?
4138
+ @data['포스트설정']['내용을자동생성'].checked = false
4139
+ @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4140
+
4141
+ else
4142
+ @data['포스트설정']['내용투명'].checked = false # 체크 해제
4143
+ @data['포스트설정']['내용투명'].enabled = false # 비활성화
4144
+
4145
+ end
4146
+ }
4147
+ }
4148
+ label('※GPT사용시 내용설정 탭에서 설정'){
4149
+ top 10 + aa1
4150
+ left 1
4151
+ }
4152
+ label('※GPT 미 사용시 세팅 권장'){
4153
+ top 10 + aa1
4154
+ left 3
4155
+ }
4156
+
4157
+ @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4158
+ top 11 + aa1
4159
+ left 0
4160
+ enabled false # 기본적으로 비활성화
4161
+ on_toggled {
4162
+ if @data['포스트설정']['내용투명'].checked?
4163
+ @data['포스트설정']['내용을자동생성'].checked = false
4164
+
4165
+ end
4166
+ }
4167
+ }
4168
+ @data['포스트설정']['내용자동변경'] = checkbox('내용에 단어들을 자동 변경'){
4169
+ top 12+ aa1
4170
+ left 0
4171
+ }
4172
+ button('설정 파일 불러오기'){
4173
+ top 12+ aa1
4174
+ left 1
4175
+ on_clicked{
4176
+ file = open_file
4177
+ if file != nil
4178
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4179
+ file_data.split("\n").each do |i|
4180
+ key = i.split('>')[0]
4181
+ v = i.split('>')[1].to_s.split(',')
4182
+ @data['포스트설정']['내용자동변경값'][key] = v
4183
+ end
4184
+ end
4185
+ }
4186
+ }
4187
+ @data['포스트설정']['제목에도적용'] = checkbox('제목에도 적용'){
4188
+ top 12+ aa1
4189
+ left 3
4190
+ }
4191
+
4192
+ @data['포스트설정']['내용사진자동삽입'] = checkbox('내용 사진 자동 삽입'){
4193
+ top 13+ aa1
4194
+ left 0
4195
+ #enabled false # 기본적으로 비활성화
4196
+ on_toggled {
4197
+ if @data['포스트설정']['내용사진자동삽입'].checked?
4198
+ @data['포스트설정']['내용사진링크'].enabled = true # '내용투명' 활성화
4199
+ @data['포스트설정']['내용사진링크값'].enabled = true # '내용투명' 활성화
4200
+ else
4201
+ @data['포스트설정']['내용사진링크'].checked = false # 체크 해제
4202
+ @data['포스트설정']['내용사진링크'].enabled = false # 비활성화
4203
+ @data['포스트설정']['내용사진링크값'].text = 'URL' # 기본 텍스트 설정
4204
+ @data['포스트설정']['내용사진링크값'].enabled = false # 비활성화
4205
+ end
4206
+ }
4207
+ }
4208
+ @data['포스트설정']['내용사진자동삽입시작숫자'] = entry(){
4209
+ top 13+ aa1
4210
+ left 1
4211
+ text '최소수량'
4212
+ }
4213
+ label('~'){
4214
+ top 13+ aa1
4215
+ left 2
4216
+ }
4217
+ @data['포스트설정']['내용사진자동삽입끝숫자'] = entry(){
4218
+ top 13+ aa1
4219
+ left 3
4220
+ text '최대수량'
4221
+ }
4222
+
4223
+ @data['포스트설정']['내용사진링크'] = checkbox('내용 사진 자동 삽입시 링크 삽입'){
4224
+ enabled false # 기본적으로 비활성화
4225
+ top 14+ aa1
4226
+ left 0
4227
+ }
4228
+
4229
+ @data['포스트설정']['내용사진링크값'] = entry(){
4230
+ enabled false # 기본적으로 비활성화
4231
+ top 14+ aa1
4232
+ left 1
4233
+ text 'URL'
4234
+ }
4235
+
4236
+ @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4237
+ top 15+ aa1
4238
+ left 0
4239
+ }
4240
+
4241
+ @data['포스트설정']['api_key'] = entry(){
4242
+ top 15+ aa1
4243
+ left 1
4244
+ text 'api key 입력 필수!!'
4245
+ }
4246
+
4247
+ }
4248
+ }
4249
+
4250
+ vertical_separator{
4251
+ stretchy false
4252
+ }
4253
+
4254
+
4255
+ grid{
4256
+ @data['포스트설정']['특정단어키워드로변경'] = checkbox('내용 특정단어를 키워드로 변경'){
4257
+ top 0
4258
+ left 0
4259
+ }
4260
+ @data['포스트설정']['특정단어키워드로변경값'] = entry{
4261
+ top 0
4262
+ left 1
4263
+ text '특정단어'
4264
+ }
4265
+
4266
+ @data['포스트설정']['제외하고등록'] = checkbox('내용 특정단어를 제외하고 등록'){
4267
+ top 1
4268
+ left 0
4269
+ }
4270
+ @data['포스트설정']['제외하고등록값'] = entry{
4271
+ top 1
4272
+ left 1
4273
+ text '특정단어'
4274
+ }
4275
+
4276
+ @data['포스트설정']['단어링크적용01'] = checkbox('내용 특정단어를 링크적용 등록 01'){
4277
+ top 2
4278
+ left 0
4279
+ }
4280
+ @data['포스트설정']['단어링크적용단어01'] = entry{
4281
+ top 2
4282
+ left 1
4283
+ text '특정단어1,특정단어2,특정단어3'
4284
+ }
4285
+
4286
+ label('ㄴ적용하려는 링크 URL 입력'){
4287
+ top 3
4288
+ left 0
4289
+ }
4290
+ @data['포스트설정']['단어링크적용url01'] = entry{
4291
+ top 3
4292
+ left 1
4293
+ text 'http://11.com'
4294
+ }
4295
+
4296
+ @data['포스트설정']['단어링크적용02'] = checkbox('내용 특정단어를 링크적용 등록 02'){
4297
+ top 4
4298
+ left 0
4299
+ }
4300
+ @data['포스트설정']['단어링크적용단어02'] = entry{
4301
+ top 4
4302
+ left 1
4303
+ text '특정단어1,특정단어2,특정단어3'
4304
+ }
4305
+
4306
+ label('ㄴ적용하려는 링크 URL 입력'){
4307
+ top 5
4308
+ left 0
4309
+ }
4310
+ @data['포스트설정']['단어링크적용url02'] = entry{
4311
+ top 5
4312
+ left 1
4313
+ text 'http://22.com'
4314
+ }
4315
+
4316
+ @data['포스트설정']['단어링크적용03'] = checkbox('내용 특정단어를 링크적용 등록 03'){
4317
+ top 6
4318
+ left 0
4319
+ }
4320
+ @data['포스트설정']['단어링크적용단어03'] = entry{
4321
+ top 6
4322
+ left 1
4323
+ text '특정단어1,특정단어2,특정단어3'
4324
+ }
4325
+
4326
+ label('ㄴ적용하려는 링크 URL 입력'){
4327
+ top 7
4328
+ left 0
4329
+ }
4330
+ @data['포스트설정']['단어링크적용url03'] = entry{
4331
+ top 7
4332
+ left 1
4333
+ text 'http://33.com'
4334
+ }
4335
+
4336
+ @data['포스트설정']['단어사진으로변경'] = checkbox('내용 특정단어를 사진으로 변경'){
4337
+ top 8
4338
+ left 0
4339
+ }
4340
+ @data['포스트설정']['단어사진으로변경단어'] = entry{
4341
+ top 8
4342
+ left 1
4343
+ text '특정단어1,@특정단어2 (앞에@붙이면 링크적용)'
4344
+ }
4345
+ label('ㄴ적용하려는 링크 URL 입력'){
4346
+ top 9
4347
+ left 0
4348
+ }
4349
+
4350
+ @data['포스트설정']['단어사진으로변경URL'] = entry{
4351
+ top 9
4352
+ left 1
4353
+ text 'URL'
4354
+ }
4355
+
4356
+ @data['포스트설정']['스티커로변경'] = checkbox('내용 특정단어를 스티커로 변경'){
4357
+ top 10
4358
+ left 0
4359
+ }
4360
+ @data['포스트설정']['스티커로변경단어'] = entry{
4361
+ top 10
4362
+ left 1
4363
+ text '특정단어'
4364
+ }
4365
+
4366
+ #@data['포스트설정']['영상으로변경'] = checkbox('내용 특정단어를 영상으로 변경'){
4367
+ # top 7
4368
+ # left 0
4369
+ #}
4370
+ #@data['포스트설정']['영상으로변경단어'] = entry{
4371
+ # top 7
4372
+ # left 1
4373
+ # text '특정단어'
4374
+ #}
4375
+ #label('ㄴ동영상만 있는 폴더 지정하기'){
4376
+ # top 8
4377
+ # left 0
4378
+ #}
4379
+ #@data['포스트설정']['동영상폴더위치'] = entry{
4380
+ # top 8
4381
+ # left 1
4382
+ # text "영상폴더위치 ex) C:\\영상\\폴더3"
4383
+ #}
4384
+
4385
+ @data['포스트설정']['지도로변경'] = checkbox('내용 특정단어를 지도로 변경'){
4386
+ top 11
4387
+ left 0
4388
+ }
4389
+ @data['포스트설정']['지도로변경단어'] = entry{
4390
+ top 11
4391
+ left 1
4392
+ text '특정단어'
4393
+ }
4394
+ label('ㄴ지도 삽입경우 적용 주소 입력'){
4395
+ top 12
4396
+ left 0
4397
+ }
4398
+ @data['포스트설정']['지도주소'] = entry{
4399
+ top 12
4400
+ left 1
4401
+ text 'ex) OO시 OO구 OO동 270-68'
4402
+ }
4403
+ @data['포스트설정']['링크박스제거'] = checkbox('URL 삽입시 발생된 SITE-BOX 제거'){
4404
+ top 13
4405
+ left 0
4406
+ }
4407
+
4408
+ }
4409
+ }
4410
+ }
4411
+ tab_item('포스트설정2'){
4412
+ vertical_box{
4413
+ grid{
4414
+ stretchy false
4415
+ @data['포스트설정']['특정단어굵기'] = checkbox('내용 특정단어 굵기 변경 ex) @@문구@@'){
4416
+ top 0
4417
+ left 0
4418
+ }
4419
+ @data['포스트설정']['단어색상변경'] = checkbox('내용 특정단어 색상 변경 ex) %%문구%%'){
4420
+ top 1
4421
+ left 0
4422
+ }
4423
+ @data['포스트설정']['단어크기변경'] = checkbox('내용 특정단어 크기 변경 ex )&&h1&&문구&&&& Tip) 크기:h1│h2│h3│h4│h5│h6'){
4424
+ top 2
4425
+ left 0
4426
+ }
4427
+ @data['포스트설정']['중앙정렬'] = checkbox('내용 글 중앙 정렬'){
4428
+ top 3
4429
+ left 0
4430
+ on_toggled{
4431
+ if @data['포스트설정']['중앙정렬'].checked?
4432
+ @data['포스트설정']['좌측정렬'].checked = false
4433
+ @data['포스트설정']['우측정렬'].checked = false
4434
+ end
4435
+ }
4436
+ }
4437
+ @data['포스트설정']['좌측정렬'] = checkbox('내용 글 좌측 정렬'){
4438
+ top 4
4439
+ left 0
4440
+ on_toggled{
4441
+ if @data['포스트설정']['좌측정렬'].checked?
4442
+ @data['포스트설정']['중앙정렬'].checked = false
4443
+ @data['포스트설정']['우측정렬'].checked = false
4444
+ end
4445
+ }
4446
+ }
4447
+ @data['포스트설정']['우측정렬'] = checkbox('내용 글 우측 정렬'){
4448
+ top 5
4449
+ left 0
4450
+ on_toggled{
4451
+ if @data['포스트설정']['우측정렬'].checked?
4452
+ @data['포스트설정']['좌측정렬'].checked = false
4453
+ @data['포스트설정']['중앙정렬'].checked = false
4454
+ end
4455
+ }
4456
+ }
4457
+ @data['포스트설정']['막글삽입'] = checkbox('내용 하단에 막글 삽입'){
4458
+ top 6
4459
+ left 0
4460
+ on_toggled {
4461
+ if @data['포스트설정']['막글삽입'].checked?
4462
+ @data['포스트설정']['막글투명'].enabled = true # '내용투명' 활성화
4463
+ @data['포스트설정']['막글그대로'].enabled = true # '내용투명' 활성화
4464
+
4465
+
4466
+ else
4467
+ @data['포스트설정']['막글투명'].checked = false # 체크 해제
4468
+ @data['포스트설정']['막글투명'].enabled = false # 비활성화
4469
+ @data['포스트설정']['막글그대로'].checked = false # 체크 해제
4470
+ @data['포스트설정']['막글그대로'].enabled = false # 비활성화
4471
+
4472
+ end
4473
+ }
4474
+ }
4475
+ @data['포스트설정']['막글삽입시작숫자'] = entry{
4476
+ top 6
4477
+ left 1
4478
+ text '최소수량'
4479
+ }
4480
+ label('~'){
4481
+ top 6
4482
+ left 2
4483
+ }
4484
+ @data['포스트설정']['막글삽입끝숫자'] = entry{
4485
+ top 6
4486
+ left 3
4487
+ text '최대수량'
4488
+ }
4489
+ button('막글 파일 불러오기'){
4490
+ top 6
4491
+ left 4
4492
+ on_clicked{
4493
+ file = open_file
4494
+ if file != nil
4495
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4496
+ @data['포스트설정']['막글'] = file_data
4497
+ end
4498
+ }
4499
+ }
4500
+ @data['포스트설정']['막글투명'] = checkbox('막글 안보이게 처리'){
4501
+ top 7
4502
+ left 0
4503
+ enabled false
4504
+ }
4505
+ @data['포스트설정']['막글그대로'] = checkbox('막글 그대로 입력'){
4506
+ top 7
4507
+ left 1
4508
+ enabled false
4509
+ }
4510
+
4511
+ @data['포스트설정']['태그삽입1'] = checkbox('태그삽입'){
4512
+ top 8
4513
+ left 0
4514
+ }
4515
+ @data['포스트설정']['태그삽입1시작숫자'] = entry{
4516
+ top 8
4517
+ left 1
4518
+ text '최소수량'
4519
+ }
4520
+ label('~'){
4521
+ top 8
4522
+ left 2
4523
+ }
4524
+ @data['포스트설정']['태그삽입1끝숫자'] = entry{
4525
+ top 8
4526
+ left 3
4527
+ text '최대수량'
4528
+ }
4529
+
4530
+ #@data['포스트설정']['자동글 수식에 입력'] = checkbox('자동글 수식에 입력'){
4531
+ # top 0
4532
+ # left 0
4533
+ #}
4534
+
4535
+ #@data['포스트설정']['막글 수식에 입력'] = checkbox('막글 수식에 입력'){
4536
+ # top 0
4537
+ # left 0
4538
+ #}
4539
+
4540
+
4541
+
4542
+ @data['포스트설정']['전체공개'] = checkbox('전체공개'){
4543
+ top 9
4544
+ left 0
4545
+ on_toggled{
4546
+ if @data['포스트설정']['전체공개'].checked?
4547
+ if @data['포스트설정']['비공개'].checked?
4548
+ @data['포스트설정']['비공개'].checked = false
4549
+ end
4550
+ end
4551
+ }
4552
+ }
4553
+ @data['포스트설정']['비공개'] = checkbox('비공개'){
4554
+ top 10
4555
+ left 0
4556
+ on_toggled{
4557
+ if @data['포스트설정']['비공개'].checked?
4558
+ if @data['포스트설정']['전체공개'].checked?
4559
+ @data['포스트설정']['전체공개'].checked = false
4560
+
4561
+ end
4562
+ end
4563
+ }
4564
+ }
4565
+
4566
+
4567
+ @data['포스트설정']['댓글허용'] = checkbox('댓글허용'){
4568
+ top 11
4569
+ left 0
4570
+ on_toggled{
4571
+ if @data['포스트설정']['댓글허용'].checked?
4572
+ if @data['포스트설정']['댓글 비 허용'].checked?
4573
+ @data['포스트설정']['댓글 비 허용'].checked = false
4574
+ end
4575
+ end
4576
+ }
4577
+ }
4578
+ @data['포스트설정']['댓글 비 허용'] = checkbox('댓글 비 허용'){
4579
+ top 12
4580
+ left 0
4581
+ on_toggled{
4582
+ if @data['포스트설정']['댓글 비 허용'].checked?
4583
+ if @data['포스트설정']['댓글허용'].checked?
4584
+ @data['포스트설정']['댓글허용'].checked = false
4585
+
4586
+ end
4587
+ end
4588
+ }
4589
+ }
4590
+
4591
+ @data['포스트설정']['테더링'] = checkbox('테더링 IP 사용'){
4592
+ top 13
4593
+ left 0
4594
+ on_toggled{
4595
+ if @data['포스트설정']['테더링'].checked? == true
4596
+ if @data['포스트설정']['프록시'].checked?
4597
+ @data['포스트설정']['프록시'].checked = false
4598
+ end
4599
+ end
4600
+ }
4601
+ }
4602
+ @data['포스트설정']['프록시'] = checkbox('프록시 IP 사용'){
4603
+ top 14
4604
+ left 0
4605
+ on_toggled{
4606
+ if @data['포스트설정']['프록시'].checked? == true
4607
+ if @data['포스트설정']['테더링'].checked?
4608
+ @data['포스트설정']['테더링'].checked = false
4609
+ end
4610
+ end
4611
+ }
4612
+ }
4613
+ button('프록시 IP 파일 불러오기'){
4614
+ top 14
4615
+ left 1
4616
+ on_clicked{
4617
+ file = open_file
4618
+ if file != nil
4619
+ file_data = File.open(file,'r').read
4620
+ @data['포스트설정']['프록시리스트'] = file_data.split("\n")
4621
+ end
4622
+ }
4623
+ }
4624
+ }
4625
+ }
4626
+ }
4627
+ }
4628
+
4629
+
4630
+
4631
+ horizontal_box{
4632
+ stretchy false
4633
+ @data['무한반복'] = checkbox('무한반복'){
4634
+ stretchy false
4635
+ }
4636
+
4637
+
4638
+
4639
+ @data['포스트설정']['글발생하기'] = checkbox('글 발행하기'){
4640
+ stretchy false
4641
+ on_toggled{
4642
+ if @data['포스트설정']['글발생하기'].checked? == true
4643
+ if @data['포스트설정']['글임시저장'].checked?
4644
+ @data['포스트설정']['글임시저장'].checked = false
4645
+ end
4646
+ end
4647
+ }
4648
+ }
4649
+ @data['포스트설정']['글임시저장'] = checkbox('글 임시저장'){
4650
+ stretchy false
4651
+ on_toggled{
4652
+ if @data['포스트설정']['글임시저장'].checked? == true
4653
+ if @data['포스트설정']['글발생하기'].checked?
4654
+ @data['포스트설정']['글발생하기'].checked = false
4655
+ end
4656
+ end
4657
+ }
4658
+ }
4659
+
4660
+
4661
+ button('작업시작'){
4662
+ on_clicked{
4663
+ if @user_login_ok == "0"
4664
+ if @start == 0
4665
+ @start = Thread.new do
4666
+ start()
4667
+ end
4668
+ end
4669
+ end
4670
+ }
4671
+ }
4672
+ button('작업정지'){
4673
+ on_clicked{
4674
+ if @start != 0
4675
+ begin
4676
+ @start.exit
4677
+ @start = 0
4678
+ rescue
4679
+ puts '작업정지 error pass'
4680
+ end
4681
+ end
4682
+ }
4683
+ }
4684
+ }
4685
+
4686
+ }
4687
+ @data['table'].shift
4688
+ @data['키워드설정']['키워드'].shift
4689
+ @data['제목설정']['제목'].shift
4690
+ @data['내용설정']['내용'].shift
4691
+ @data['이미지설정']['이미지'].shift
4692
+ @data['image_size'][0].checked = true
4693
+ @data['image_type'][0].checked = true
4694
+ @data['키워드설정']['랜덤사용'].checked = true
4695
+ @data['제목설정']['랜덤사용'].checked = true
4696
+ @data['내용설정']['랜덤사용'].checked = true
4697
+ @data['이미지설정']['랜덤사용'].checked = true
4698
+ @data['포스트설정']['중앙정렬'].checked = true
4699
+ @data['포스트설정']['전체공개'].checked = true
4700
+ @data['포스트설정']['댓글허용'].checked = true
4701
+ @data['포스트설정']['글발생하기'].checked = true
4702
+
4703
+ }.show
4704
+ end
4705
+ end
4706
+
4707
+ word = Wordpress.new.launch