nblog_zon 0.0.90 → 0.0.97

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nblog_zon.rb +70 -37
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e208063d329d0dc5a9e20016e840f517fc3f0bd508a4e379f58b98abec66b8df
4
- data.tar.gz: 3955241a2aff489f03158dd001ec62b37bde0cf738fe8038ec776a01af5fed0d
3
+ metadata.gz: 16f9f1a599f5774852560e49d6531c41d82e4fb827bac290a35d048b320d329c
4
+ data.tar.gz: b304537fa34dedaf079eccb1f072b77217b39d2a9fdf07c5b5a9e32b3c1b972e
5
5
  SHA512:
6
- metadata.gz: 12b7fa2e387a9e10b0c1bba982110a4e0ea2789836f4bd4b7b854a8f85712aa74d3c269d62bb25c2dd56b3e31c017eb560be4b4a5b7dcd2b341e40c64018956e
7
- data.tar.gz: 128712b118b9b6afe4bef58ce45a6846e1d5f3ed56ae4df8d07da9de9f963ab35406c93214b56489c3f9da84c2ca38693b88e4cadb9a6d3c6f85505a4dd47dc9
6
+ metadata.gz: 2bc5079abc8b298c56b5a61d83d2359419321894838e6d8a8d75ee1490482f9c157db72d42cd82464c37c30311c63da9aead376c5d97cffc1dbae2f52d516e95
7
+ data.tar.gz: 8b06f4e5dba913e77b9d18b4e40bcdba491326411cbf4ccbf34eee570bcfe3b21745b8f12a6b3075f359cafb354ad11d1815598651dc098cd1abc77436ad6d06
data/lib/nblog_zon.rb CHANGED
@@ -179,8 +179,8 @@ class Chat_content
179
179
  end
180
180
 
181
181
  def message(content)
182
- puts 'Sending request to GPT...(내용 변형 중...)'
183
182
  puts '주의:GPT 특성상 원고 길이가 공백 포함 4천자를 넘기면 오류가 발생할 수 있습니다.'
183
+ puts 'Sending request to GPT...(내용 변형 중...)'
184
184
  # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
185
185
  thread = Thread.new do
186
186
  while true
@@ -246,9 +246,13 @@ class Naver
246
246
  naver_cookie_dir = "C:/naver_cookie"
247
247
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
248
248
  if proxy == ''
249
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
249
+
250
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --no-first-run --no-default-browser-check --disable-sync})
251
+
250
252
  else
251
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" "https://naver.com/" --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s}})
253
+
254
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync})
255
+
252
256
  end
253
257
  end
254
258
  def chrome_start(proxy, user_id)
@@ -260,6 +264,9 @@ class Naver
260
264
  options = Selenium::WebDriver::Chrome::Options.new
261
265
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
262
266
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
267
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
268
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
269
+ options.add_argument('--no-default-browser-check')
263
270
  options.page_load_strategy = :normal
264
271
  options.timeouts = {page_load: 20_000}
265
272
  options.page_load_strategy = 'none'
@@ -285,6 +292,9 @@ class Naver
285
292
  options = Selenium::WebDriver::Chrome::Options.new
286
293
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
287
294
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
295
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
296
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
297
+ options.add_argument('--no-default-browser-check')
288
298
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
289
299
  options.page_load_strategy = :normal
290
300
  options.timeouts = {page_load: 20_000}
@@ -309,6 +319,9 @@ class Naver
309
319
  options = Selenium::WebDriver::Chrome::Options.new
310
320
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
311
321
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
322
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
323
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
324
+ options.add_argument('--no-default-browser-check')
312
325
  options.page_load_strategy = :normal
313
326
  options.timeouts = {page_load: 20_000}
314
327
  options.page_load_strategy = 'none'
@@ -373,13 +386,20 @@ class Naver
373
386
  puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
374
387
  sleep(2.5)
375
388
  rescue
376
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
377
- #요소가 나타날 때까지 3초 동안 기다립니다.
378
- wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
379
- sleep(1.5)
380
- @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
381
- check_cookie_login = 0
382
- sleep(1)
389
+ begin
390
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
391
+ # 요소가 나타날 때까지 기다립니다.
392
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
393
+ sleep(1.5)
394
+
395
+ # 요소가 있으면 클릭
396
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
397
+ check_cookie_login = 0
398
+ sleep(1)
399
+ rescue
400
+ @driver.quit
401
+ return 0
402
+ end
383
403
  end
384
404
 
385
405
  if check_cookie_login == 0
@@ -414,8 +434,8 @@ class Naver
414
434
  puts "Failed to close tab: #{e.message}"
415
435
  end
416
436
  end
417
- return 0
418
437
  @driver.quit
438
+ return 0
419
439
  end
420
440
 
421
441
  else
@@ -438,9 +458,9 @@ class Naver
438
458
  puts "Failed to close tab: #{e.message}"
439
459
  end
440
460
  end
441
- return 0
442
461
  @driver.quit
443
- end
462
+ return 0
463
+ end
444
464
  end
445
465
 
446
466
  def create_id
@@ -756,8 +776,9 @@ class Naver
756
776
  puts "Failed to close tab: #{e.message}"
757
777
  end
758
778
  end
759
- return 0
760
779
  @driver.quit
780
+ return 0
781
+
761
782
  end
762
783
 
763
784
  ele = @driver.find_element(:xpath, '//*[@draggable="false"]')
@@ -1662,8 +1683,9 @@ class Naver
1662
1683
  puts "Failed to close tab: #{e.message}"
1663
1684
  end
1664
1685
  end
1665
- return 0
1666
1686
  @driver.quit
1687
+ return 0
1688
+
1667
1689
  end
1668
1690
 
1669
1691
 
@@ -2367,7 +2389,7 @@ class Wordpress
2367
2389
  puts 'Tethering IP change...'
2368
2390
 
2369
2391
  stdout, stderr, status = Open3.capture3('./adb devices')
2370
-
2392
+
2371
2393
  if status.success?
2372
2394
  device_id = stdout.split("\n")[1].split("\t")[0]
2373
2395
  puts device_id
@@ -2375,42 +2397,53 @@ class Wordpress
2375
2397
  # ADB 서버 초기화
2376
2398
  puts 'adb kill-server'
2377
2399
  Open3.capture3('./adb kill-server')
2378
- sleep(3)
2400
+ sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
2379
2401
 
2380
2402
  # 다시 ADB 서버 실행
2381
2403
  puts 'adb start-server'
2382
2404
  Open3.capture3('./adb start-server')
2383
- sleep(3)
2405
+ sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
2384
2406
 
2385
2407
  # 데이터를 끄고 켜기
2386
2408
  puts 'adb -s ' + device_id + ' shell svc data disable'
2387
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2388
- sleep(3)
2409
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2410
+ puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
2411
+ sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
2389
2412
  puts 'adb -s ' + device_id + ' shell svc data enable'
2390
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2391
- sleep(3)
2413
+ stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2414
+ puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
2415
+ sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
2392
2416
  puts 'adb ok'
2393
2417
  sleep(8)
2394
-
2418
+
2419
+ # IP 변경 확인을 위한 람다 함수
2395
2420
  robot_ip = lambda do
2396
- http = HTTP.get('https://www.findip.kr/')
2397
- noko = Nokogiri::HTML(http.to_s)
2398
- if noko.xpath('/html/body/header/h2').text != @my_ip
2399
- @my_ip = noko.xpath('/html/body/header/h2').text
2421
+ begin
2422
+ # IP 변경 확인
2423
+ http = HTTP.get('https://www.findip.kr/')
2424
+ noko = Nokogiri::HTML(http.to_s)
2425
+
2426
+ current_ip = noko.xpath('/html/body/header/h2').text.strip
2427
+ if current_ip != @my_ip
2428
+ @my_ip = current_ip
2400
2429
  puts "IP 변경됨[ #{@my_ip} ]"
2401
- else
2402
- puts @my_ip
2403
- puts '제시도...'
2404
- sleep(3)
2405
- robot_ip[]
2430
+ else
2431
+ puts "현재 IP: #{@my_ip}"
2432
+ puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
2433
+ sleep(5) # 여유롭게 대기 시간 증가
2434
+ robot_ip[] # 재시도
2435
+ end
2436
+ rescue HTTP::ConnectionError => e
2437
+ puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
2438
+ sleep(5) # 재시도 간 여유 시간 추가
2439
+ retry # 재시도
2406
2440
  end
2407
- end
2408
- robot_ip[]
2409
-
2441
+ end
2442
+ robot_ip[] # IP 확인 시작
2410
2443
  else
2411
- puts 'adb error pass'
2444
+ puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
2412
2445
  end
2413
- end
2446
+ end
2414
2447
 
2415
2448
 
2416
2449
  check_success = 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.90
4
+ version: 0.0.97
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-17 00:00:00.000000000 Z
11
+ date: 2025-02-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: rnjstnswp123@naver.com