nblog_duo 111.117.779 → 111.117.799
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.
- checksums.yaml +4 -4
- data/lib/nblog_duo.rb +94 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 940713ad87c1465d1d61e78b4c8a26909bedfa07c8702d8aebde43ebe3213753
|
4
|
+
data.tar.gz: aed59cefb0316a53eb68d47ac630983f87caec7b25399fe050dd6ba1fc5695f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e62cfaa81e78c58fbc336297e70c1c81f4015a52a94680e252500f651763892ccbb9a26bc438840bf704baf552a1f4f2633c5c2fc60d4ecff1e1eab9d502849d
|
7
|
+
data.tar.gz: 99fc13abe707cb4b1ebdf45c68ed009dc37910ecb4ca94325c143f4f100f641e6a7d7a54beb2cb90b7aa9eb12d0863e4e72e569f00a3fdaff4d09af41c53de11
|
data/lib/nblog_duo.rb
CHANGED
@@ -18,6 +18,7 @@ require 'digest'
|
|
18
18
|
require 'auto_click'
|
19
19
|
require 'rainbow/refinement'
|
20
20
|
require 'httpclient'
|
21
|
+
require 'win32ole'
|
21
22
|
include AutoClickMethods
|
22
23
|
using Rainbow
|
23
24
|
include Glimmer
|
@@ -242,8 +243,38 @@ end
|
|
242
243
|
class Naver
|
243
244
|
def initialize
|
244
245
|
@seed = 1
|
246
|
+
kill_selenium_chrome #기존 창 모두 닫는 명령
|
247
|
+
sleep(1)
|
245
248
|
end
|
246
249
|
|
250
|
+
def kill_selenium_chrome #기존 창 모두 닫는 코드
|
251
|
+
wmi = WIN32OLE.connect("winmgmts://")
|
252
|
+
chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
|
253
|
+
|
254
|
+
chrome_procs.each do |proc|
|
255
|
+
cmd = proc.CommandLine
|
256
|
+
if cmd && cmd.include?("user-data-dir=C:/naver_cookie")
|
257
|
+
puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
|
258
|
+
begin
|
259
|
+
proc.Terminate
|
260
|
+
rescue
|
261
|
+
#puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# chromedriver도 같이 종료
|
267
|
+
chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
|
268
|
+
chromedrivers.each do |proc|
|
269
|
+
puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
|
270
|
+
begin
|
271
|
+
proc.Terminate
|
272
|
+
rescue
|
273
|
+
#puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
247
278
|
|
248
279
|
def chrome_setup(user_id, proxy)
|
249
280
|
naver_cookie_dir = "C:/naver_cookie"
|
@@ -2358,40 +2389,84 @@ class Wordpress
|
|
2358
2389
|
img.write('./image/memory.png')
|
2359
2390
|
end
|
2360
2391
|
|
2392
|
+
def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
|
2393
|
+
size = initial_size
|
2394
|
+
draw.font = font_path
|
2395
|
+
|
2396
|
+
loop do
|
2397
|
+
draw.pointsize = size
|
2398
|
+
words = text.chars # 글자 단위로 자름 (한국어 기준)
|
2399
|
+
lines = []
|
2400
|
+
line = ""
|
2401
|
+
|
2402
|
+
words.each do |char|
|
2403
|
+
test_line = line + char
|
2404
|
+
metrics = draw.get_type_metrics(test_line)
|
2405
|
+
if metrics.width > max_width
|
2406
|
+
lines << line
|
2407
|
+
line = char
|
2408
|
+
else
|
2409
|
+
line = test_line
|
2410
|
+
end
|
2411
|
+
end
|
2412
|
+
lines << line unless line.empty?
|
2413
|
+
|
2414
|
+
line_height = draw.get_type_metrics("가").height
|
2415
|
+
total_height = line_height * lines.size
|
2416
|
+
|
2417
|
+
# 세로 초과 안 하면 성공
|
2418
|
+
if total_height <= max_height || size <= 10
|
2419
|
+
return [lines.join("\n"), size]
|
2420
|
+
else
|
2421
|
+
size -= 2
|
2422
|
+
end
|
2423
|
+
end
|
2424
|
+
end
|
2425
|
+
|
2426
|
+
|
2361
2427
|
def image_text(text1, text2)
|
2362
2428
|
begin
|
2363
2429
|
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
2364
|
-
|
2365
|
-
|
2366
|
-
text = Magick::Draw.new
|
2430
|
+
font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
|
2431
|
+
font2 = './fonts/' + font_files.sample
|
2367
2432
|
color2 = color.sample
|
2368
|
-
|
2369
|
-
|
2433
|
+
|
2434
|
+
img = Magick::Image.read('./image/memory.png').first
|
2435
|
+
draw = Magick::Draw.new
|
2436
|
+
|
2437
|
+
raw_message = "#{text1}\n#{text2}".strip
|
2438
|
+
max_width = img.columns * 0.85
|
2439
|
+
max_height = img.rows * 0.6
|
2440
|
+
|
2370
2441
|
begin
|
2371
2442
|
size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
|
2372
2443
|
rescue
|
2373
2444
|
size = 30
|
2374
2445
|
end
|
2446
|
+
|
2447
|
+
wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
|
2448
|
+
|
2375
2449
|
if @data['이미지설정']['글자그림자'].checked?
|
2376
|
-
img.annotate(
|
2377
|
-
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2450
|
+
img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
|
2451
|
+
draw.gravity = Magick::CenterGravity
|
2452
|
+
draw.pointsize = adjusted_size
|
2453
|
+
draw.fill = '#000000'
|
2454
|
+
draw.font = font2
|
2381
2455
|
end
|
2382
2456
|
end
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2457
|
+
|
2458
|
+
draw2 = Magick::Draw.new
|
2459
|
+
img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
|
2460
|
+
draw2.gravity = Magick::CenterGravity
|
2461
|
+
draw2.pointsize = adjusted_size
|
2462
|
+
draw2.fill = color2
|
2463
|
+
draw2.font = font2
|
2387
2464
|
if @data['이미지설정']['글자테두리'].checked?
|
2388
|
-
|
2389
|
-
|
2465
|
+
draw2.stroke_width = 2
|
2466
|
+
draw2.stroke = '#000000'
|
2390
2467
|
end
|
2391
|
-
text.fill = color2
|
2392
|
-
text.font = font2
|
2393
2468
|
end
|
2394
|
-
|
2469
|
+
|
2395
2470
|
img.write('./image/memory.png')
|
2396
2471
|
rescue
|
2397
2472
|
puts '이미지 폰트 불러오기 오류 재시도...'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nblog_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 111.117.
|
4
|
+
version: 111.117.799
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: File to Clipboard gem
|
13
13
|
email: mymin26@naver.com
|