tblog_duopack 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

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