cafe_buy 0.1.37 → 0.1.39
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/cafe_buy.rb +160 -52
- 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: 4e3f6e7ff4507602e98f00a16611632c63ccffd7ee933f19b9343af7c7b21228
|
4
|
+
data.tar.gz: 6fd0fdc57626f0617dc02f75e741db2f6e42d178fbce6733fa203dc503b1c80f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 591fd98593f42a8f0789a244d89536a898657943e950dc4c05b0fd7bb592929377da1205385c7fbb631db2e71066c5f2aadff3605281cf26aa2fbfab34d17291
|
7
|
+
data.tar.gz: 980f2722c2428dd183d2489ad7216ed2ce1e8e3cbc3f3f0986e076728e7311ef689d8042c60b430068caeb7362e18b1cef218b12aae0b008a192fb0ce56af0b3
|
data/lib/cafe_buy.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"
|
@@ -2415,52 +2446,106 @@ class Wordpress
|
|
2415
2446
|
img = Magick::Image.read('./image/memory.png').first
|
2416
2447
|
width = img.columns
|
2417
2448
|
height = img.rows
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2449
|
+
|
2450
|
+
# '원본'이 선택된 경우, 리사이징을 하지 않고 원본 이미지를 그대로 반환
|
2451
|
+
if w == 'original'
|
2452
|
+
return img # 원본 이미지 그대로 반환
|
2453
|
+
else
|
2454
|
+
begin
|
2455
|
+
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
2456
|
+
# 비율을 맞추어 리사이징
|
2457
|
+
img.resize!(w, w * (height.to_f / width.to_f))
|
2458
|
+
else
|
2459
|
+
# 정사각형으로 리사이징
|
2460
|
+
img.resize!(w, w)
|
2461
|
+
end
|
2462
|
+
rescue
|
2463
|
+
img.resize!(w, w) # 예외 처리 시에도 리사이징
|
2423
2464
|
end
|
2424
|
-
rescue
|
2425
|
-
img.resize!(w, w)
|
2426
2465
|
end
|
2466
|
+
|
2467
|
+
# 리사이징된 이미지 저장
|
2427
2468
|
img.write('./image/memory.png')
|
2428
2469
|
end
|
2429
2470
|
|
2471
|
+
def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
|
2472
|
+
size = initial_size
|
2473
|
+
draw.font = font_path
|
2474
|
+
|
2475
|
+
loop do
|
2476
|
+
draw.pointsize = size
|
2477
|
+
words = text.chars # 글자 단위로 자름 (한국어 기준)
|
2478
|
+
lines = []
|
2479
|
+
line = ""
|
2480
|
+
|
2481
|
+
words.each do |char|
|
2482
|
+
test_line = line + char
|
2483
|
+
metrics = draw.get_type_metrics(test_line)
|
2484
|
+
if metrics.width > max_width
|
2485
|
+
lines << line
|
2486
|
+
line = char
|
2487
|
+
else
|
2488
|
+
line = test_line
|
2489
|
+
end
|
2490
|
+
end
|
2491
|
+
lines << line unless line.empty?
|
2492
|
+
|
2493
|
+
line_height = draw.get_type_metrics("가").height
|
2494
|
+
total_height = line_height * lines.size
|
2495
|
+
|
2496
|
+
# 세로 초과 안 하면 성공
|
2497
|
+
if total_height <= max_height || size <= 10
|
2498
|
+
return [lines.join("\n"), size]
|
2499
|
+
else
|
2500
|
+
size -= 2
|
2501
|
+
end
|
2502
|
+
end
|
2503
|
+
end
|
2504
|
+
|
2505
|
+
|
2430
2506
|
def image_text(text1, text2)
|
2431
2507
|
begin
|
2432
2508
|
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
2433
|
-
|
2434
|
-
|
2435
|
-
text = Magick::Draw.new
|
2509
|
+
font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
|
2510
|
+
font2 = './fonts/' + font_files.sample
|
2436
2511
|
color2 = color.sample
|
2437
|
-
|
2438
|
-
|
2512
|
+
|
2513
|
+
img = Magick::Image.read('./image/memory.png').first
|
2514
|
+
draw = Magick::Draw.new
|
2515
|
+
|
2516
|
+
raw_message = "#{text1}\n#{text2}".strip
|
2517
|
+
max_width = img.columns * 0.85
|
2518
|
+
max_height = img.rows * 0.6
|
2519
|
+
|
2439
2520
|
begin
|
2440
2521
|
size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
|
2441
2522
|
rescue
|
2442
2523
|
size = 30
|
2443
2524
|
end
|
2525
|
+
|
2526
|
+
wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
|
2527
|
+
|
2444
2528
|
if @data['이미지설정']['글자그림자'].checked?
|
2445
|
-
img.annotate(
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2529
|
+
img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
|
2530
|
+
draw.gravity = Magick::CenterGravity
|
2531
|
+
draw.pointsize = adjusted_size
|
2532
|
+
draw.fill = '#000000'
|
2533
|
+
draw.font = font2
|
2450
2534
|
end
|
2451
2535
|
end
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2536
|
+
|
2537
|
+
draw2 = Magick::Draw.new
|
2538
|
+
img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
|
2539
|
+
draw2.gravity = Magick::CenterGravity
|
2540
|
+
draw2.pointsize = adjusted_size
|
2541
|
+
draw2.fill = color2
|
2542
|
+
draw2.font = font2
|
2456
2543
|
if @data['이미지설정']['글자테두리'].checked?
|
2457
|
-
|
2458
|
-
|
2544
|
+
draw2.stroke_width = 2
|
2545
|
+
draw2.stroke = '#000000'
|
2459
2546
|
end
|
2460
|
-
text.fill = color2
|
2461
|
-
text.font = font2
|
2462
2547
|
end
|
2463
|
-
|
2548
|
+
|
2464
2549
|
img.write('./image/memory.png')
|
2465
2550
|
rescue
|
2466
2551
|
puts '이미지 폰트 불러오기 오류 재시도...'
|
@@ -2494,23 +2579,30 @@ class Wordpress
|
|
2494
2579
|
else
|
2495
2580
|
auto_image()
|
2496
2581
|
end
|
2497
|
-
|
2498
|
-
|
2582
|
+
|
2583
|
+
# '원본'을 포함한 이미지 크기 옵션 추가
|
2584
|
+
image_size = [480, 740, 650, 550, 480, 'original']
|
2499
2585
|
size = 0
|
2500
|
-
|
2586
|
+
|
2587
|
+
for n in 0..5 # 0부터 5까지 반복, '원본' 옵션까지 포함
|
2501
2588
|
if @data['image_size'][n].checked?
|
2502
|
-
if n ==
|
2503
|
-
size =
|
2589
|
+
if n == 5 # '원본'이 선택되었을 경우
|
2590
|
+
size = 'original'
|
2591
|
+
elsif n == 0
|
2592
|
+
size = image_size.sample # 랜덤 선택
|
2504
2593
|
else
|
2505
2594
|
size = image_size[n]
|
2506
2595
|
end
|
2507
2596
|
end
|
2508
2597
|
end
|
2598
|
+
|
2599
|
+
# '원본'이 선택되지 않았다면 기본 값 설정
|
2509
2600
|
if size == 0
|
2510
2601
|
size = 480
|
2511
2602
|
end
|
2603
|
+
|
2604
|
+
change_image_size(size) # 크기 변경 함수 호출
|
2512
2605
|
|
2513
|
-
change_image_size(size)
|
2514
2606
|
|
2515
2607
|
if @data['이미지설정']['필터사용'].checked?
|
2516
2608
|
image_filter()
|
@@ -2518,33 +2610,33 @@ class Wordpress
|
|
2518
2610
|
|
2519
2611
|
if @data['이미지설정']['글자삽입1'].checked?
|
2520
2612
|
if @data['이미지설정']['이미지글자1'].length == 0
|
2521
|
-
|
2522
|
-
else
|
2523
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
2524
|
-
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2613
|
+
image_text_path1 = ''
|
2525
2614
|
else
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2615
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2616
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2617
|
+
else
|
2618
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2619
|
+
@image_text_soon1 += 1
|
2620
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2621
|
+
@image_text_soon1 = 0
|
2622
|
+
end
|
2623
|
+
end
|
2532
2624
|
end
|
2533
2625
|
end
|
2534
2626
|
|
2535
2627
|
if @data['이미지설정']['글자삽입2'].checked?
|
2536
2628
|
if @data['이미지설정']['이미지글자2'].length == 0
|
2537
|
-
|
2629
|
+
image_text_path2 = ''
|
2538
2630
|
else
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2631
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2632
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2633
|
+
else
|
2634
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2635
|
+
@image_text_soon2 += 1
|
2636
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2637
|
+
@image_text_soon2 = 0
|
2638
|
+
end
|
2639
|
+
end
|
2548
2640
|
end
|
2549
2641
|
end
|
2550
2642
|
|
@@ -4955,6 +5047,7 @@ class Wordpress
|
|
4955
5047
|
@data['image_size'][2].checked = false
|
4956
5048
|
@data['image_size'][3].checked = false
|
4957
5049
|
@data['image_size'][4].checked = false
|
5050
|
+
@data['image_size'][5].checked = false
|
4958
5051
|
end
|
4959
5052
|
}
|
4960
5053
|
}
|
@@ -4965,6 +5058,7 @@ class Wordpress
|
|
4965
5058
|
@data['image_size'][2].checked = false
|
4966
5059
|
@data['image_size'][3].checked = false
|
4967
5060
|
@data['image_size'][4].checked = false
|
5061
|
+
@data['image_size'][5].checked = false
|
4968
5062
|
end
|
4969
5063
|
}
|
4970
5064
|
}
|
@@ -4975,6 +5069,7 @@ class Wordpress
|
|
4975
5069
|
@data['image_size'][0].checked = false
|
4976
5070
|
@data['image_size'][3].checked = false
|
4977
5071
|
@data['image_size'][4].checked = false
|
5072
|
+
@data['image_size'][5].checked = false
|
4978
5073
|
end
|
4979
5074
|
}
|
4980
5075
|
}
|
@@ -4985,6 +5080,7 @@ class Wordpress
|
|
4985
5080
|
@data['image_size'][2].checked = false
|
4986
5081
|
@data['image_size'][0].checked = false
|
4987
5082
|
@data['image_size'][4].checked = false
|
5083
|
+
@data['image_size'][5].checked = false
|
4988
5084
|
end
|
4989
5085
|
}
|
4990
5086
|
}
|
@@ -4995,6 +5091,18 @@ class Wordpress
|
|
4995
5091
|
@data['image_size'][2].checked = false
|
4996
5092
|
@data['image_size'][3].checked = false
|
4997
5093
|
@data['image_size'][0].checked = false
|
5094
|
+
@data['image_size'][5].checked = false
|
5095
|
+
end
|
5096
|
+
}
|
5097
|
+
}
|
5098
|
+
@data['image_size'][5] = checkbox('원본 px'){
|
5099
|
+
on_toggled{
|
5100
|
+
if @data['image_size'][5].checked?
|
5101
|
+
@data['image_size'][1].checked = false
|
5102
|
+
@data['image_size'][2].checked = false
|
5103
|
+
@data['image_size'][3].checked = false
|
5104
|
+
@data['image_size'][0].checked = false
|
5105
|
+
@data['image_size'][4].checked = false
|
4998
5106
|
end
|
4999
5107
|
}
|
5000
5108
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_buy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.39
|
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
|