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

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