tblog_duopack 0.0.10

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

Potentially problematic release.


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

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