cafe_basics_duo 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_basics_duo.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: c473b00e756bcba3cb0b76ab0ee1ddc196f3319dc7ba299afc2806fd06ab3d48
|
4
|
+
data.tar.gz: 4b2aeea289d103f695795bd56d96aadb0395849ff705ae2b3591603e20dba450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917d23972fe6ac3fa9d6dfa56802440dc16dae3bd02b981611b4ad2b5d1a30d772b9aaf017219ad90d86b902f028d268ce9fafa9f2d62c6b6691cf7cf2b444b9
|
7
|
+
data.tar.gz: c5f74ba2b30f6b11ed80c990f3a2c62de1797db3c6923de033c52b23e4209bdaf02c45963023066adcd68525f4d3c0f3a22ed270eeb7c87f2743e6180f9be384
|
data/lib/cafe_basics_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"
|
@@ -2145,52 +2176,106 @@ class Wordpress
|
|
2145
2176
|
img = Magick::Image.read('./image/memory.png').first
|
2146
2177
|
width = img.columns
|
2147
2178
|
height = img.rows
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2179
|
+
|
2180
|
+
# '원본'이 선택된 경우, 리사이징을 하지 않고 원본 이미지를 그대로 반환
|
2181
|
+
if w == 'original'
|
2182
|
+
return img # 원본 이미지 그대로 반환
|
2183
|
+
else
|
2184
|
+
begin
|
2185
|
+
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
2186
|
+
# 비율을 맞추어 리사이징
|
2187
|
+
img.resize!(w, w * (height.to_f / width.to_f))
|
2188
|
+
else
|
2189
|
+
# 정사각형으로 리사이징
|
2190
|
+
img.resize!(w, w)
|
2191
|
+
end
|
2192
|
+
rescue
|
2193
|
+
img.resize!(w, w) # 예외 처리 시에도 리사이징
|
2153
2194
|
end
|
2154
|
-
rescue
|
2155
|
-
img.resize!(w, w)
|
2156
2195
|
end
|
2196
|
+
|
2197
|
+
# 리사이징된 이미지 저장
|
2157
2198
|
img.write('./image/memory.png')
|
2158
2199
|
end
|
2159
2200
|
|
2201
|
+
def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
|
2202
|
+
size = initial_size
|
2203
|
+
draw.font = font_path
|
2204
|
+
|
2205
|
+
loop do
|
2206
|
+
draw.pointsize = size
|
2207
|
+
words = text.chars # 글자 단위로 자름 (한국어 기준)
|
2208
|
+
lines = []
|
2209
|
+
line = ""
|
2210
|
+
|
2211
|
+
words.each do |char|
|
2212
|
+
test_line = line + char
|
2213
|
+
metrics = draw.get_type_metrics(test_line)
|
2214
|
+
if metrics.width > max_width
|
2215
|
+
lines << line
|
2216
|
+
line = char
|
2217
|
+
else
|
2218
|
+
line = test_line
|
2219
|
+
end
|
2220
|
+
end
|
2221
|
+
lines << line unless line.empty?
|
2222
|
+
|
2223
|
+
line_height = draw.get_type_metrics("가").height
|
2224
|
+
total_height = line_height * lines.size
|
2225
|
+
|
2226
|
+
# 세로 초과 안 하면 성공
|
2227
|
+
if total_height <= max_height || size <= 10
|
2228
|
+
return [lines.join("\n"), size]
|
2229
|
+
else
|
2230
|
+
size -= 2
|
2231
|
+
end
|
2232
|
+
end
|
2233
|
+
end
|
2234
|
+
|
2235
|
+
|
2160
2236
|
def image_text(text1, text2)
|
2161
2237
|
begin
|
2162
2238
|
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
2163
|
-
|
2164
|
-
|
2165
|
-
text = Magick::Draw.new
|
2239
|
+
font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
|
2240
|
+
font2 = './fonts/' + font_files.sample
|
2166
2241
|
color2 = color.sample
|
2167
|
-
|
2168
|
-
|
2242
|
+
|
2243
|
+
img = Magick::Image.read('./image/memory.png').first
|
2244
|
+
draw = Magick::Draw.new
|
2245
|
+
|
2246
|
+
raw_message = "#{text1}\n#{text2}".strip
|
2247
|
+
max_width = img.columns * 0.85
|
2248
|
+
max_height = img.rows * 0.6
|
2249
|
+
|
2169
2250
|
begin
|
2170
2251
|
size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
|
2171
2252
|
rescue
|
2172
2253
|
size = 30
|
2173
2254
|
end
|
2255
|
+
|
2256
|
+
wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
|
2257
|
+
|
2174
2258
|
if @data['이미지설정']['글자그림자'].checked?
|
2175
|
-
img.annotate(
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2259
|
+
img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
|
2260
|
+
draw.gravity = Magick::CenterGravity
|
2261
|
+
draw.pointsize = adjusted_size
|
2262
|
+
draw.fill = '#000000'
|
2263
|
+
draw.font = font2
|
2180
2264
|
end
|
2181
2265
|
end
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2266
|
+
|
2267
|
+
draw2 = Magick::Draw.new
|
2268
|
+
img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
|
2269
|
+
draw2.gravity = Magick::CenterGravity
|
2270
|
+
draw2.pointsize = adjusted_size
|
2271
|
+
draw2.fill = color2
|
2272
|
+
draw2.font = font2
|
2186
2273
|
if @data['이미지설정']['글자테두리'].checked?
|
2187
|
-
|
2188
|
-
|
2274
|
+
draw2.stroke_width = 2
|
2275
|
+
draw2.stroke = '#000000'
|
2189
2276
|
end
|
2190
|
-
text.fill = color2
|
2191
|
-
text.font = font2
|
2192
2277
|
end
|
2193
|
-
|
2278
|
+
|
2194
2279
|
img.write('./image/memory.png')
|
2195
2280
|
rescue
|
2196
2281
|
puts '이미지 폰트 불러오기 오류 재시도...'
|
@@ -2224,23 +2309,30 @@ class Wordpress
|
|
2224
2309
|
else
|
2225
2310
|
auto_image()
|
2226
2311
|
end
|
2227
|
-
|
2228
|
-
|
2312
|
+
|
2313
|
+
# '원본'을 포함한 이미지 크기 옵션 추가
|
2314
|
+
image_size = [480, 740, 650, 550, 480, 'original']
|
2229
2315
|
size = 0
|
2230
|
-
|
2316
|
+
|
2317
|
+
for n in 0..5 # 0부터 5까지 반복, '원본' 옵션까지 포함
|
2231
2318
|
if @data['image_size'][n].checked?
|
2232
|
-
if n ==
|
2233
|
-
size =
|
2319
|
+
if n == 5 # '원본'이 선택되었을 경우
|
2320
|
+
size = 'original'
|
2321
|
+
elsif n == 0
|
2322
|
+
size = image_size.sample # 랜덤 선택
|
2234
2323
|
else
|
2235
2324
|
size = image_size[n]
|
2236
2325
|
end
|
2237
2326
|
end
|
2238
2327
|
end
|
2328
|
+
|
2329
|
+
# '원본'이 선택되지 않았다면 기본 값 설정
|
2239
2330
|
if size == 0
|
2240
2331
|
size = 480
|
2241
2332
|
end
|
2333
|
+
|
2334
|
+
change_image_size(size) # 크기 변경 함수 호출
|
2242
2335
|
|
2243
|
-
change_image_size(size)
|
2244
2336
|
|
2245
2337
|
if @data['이미지설정']['필터사용'].checked?
|
2246
2338
|
image_filter()
|
@@ -2248,33 +2340,33 @@ class Wordpress
|
|
2248
2340
|
|
2249
2341
|
if @data['이미지설정']['글자삽입1'].checked?
|
2250
2342
|
if @data['이미지설정']['이미지글자1'].length == 0
|
2251
|
-
|
2252
|
-
else
|
2253
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
2254
|
-
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2343
|
+
image_text_path1 = ''
|
2255
2344
|
else
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2345
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2346
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2347
|
+
else
|
2348
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2349
|
+
@image_text_soon1 += 1
|
2350
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2351
|
+
@image_text_soon1 = 0
|
2352
|
+
end
|
2353
|
+
end
|
2262
2354
|
end
|
2263
2355
|
end
|
2264
2356
|
|
2265
2357
|
if @data['이미지설정']['글자삽입2'].checked?
|
2266
2358
|
if @data['이미지설정']['이미지글자2'].length == 0
|
2267
|
-
|
2359
|
+
image_text_path2 = ''
|
2268
2360
|
else
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2361
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2362
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2363
|
+
else
|
2364
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2365
|
+
@image_text_soon2 += 1
|
2366
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2367
|
+
@image_text_soon2 = 0
|
2368
|
+
end
|
2369
|
+
end
|
2278
2370
|
end
|
2279
2371
|
end
|
2280
2372
|
|
@@ -4644,6 +4736,7 @@ class Wordpress
|
|
4644
4736
|
@data['image_size'][2].checked = false
|
4645
4737
|
@data['image_size'][3].checked = false
|
4646
4738
|
@data['image_size'][4].checked = false
|
4739
|
+
@data['image_size'][5].checked = false
|
4647
4740
|
end
|
4648
4741
|
}
|
4649
4742
|
}
|
@@ -4654,6 +4747,7 @@ class Wordpress
|
|
4654
4747
|
@data['image_size'][2].checked = false
|
4655
4748
|
@data['image_size'][3].checked = false
|
4656
4749
|
@data['image_size'][4].checked = false
|
4750
|
+
@data['image_size'][5].checked = false
|
4657
4751
|
end
|
4658
4752
|
}
|
4659
4753
|
}
|
@@ -4664,6 +4758,7 @@ class Wordpress
|
|
4664
4758
|
@data['image_size'][0].checked = false
|
4665
4759
|
@data['image_size'][3].checked = false
|
4666
4760
|
@data['image_size'][4].checked = false
|
4761
|
+
@data['image_size'][5].checked = false
|
4667
4762
|
end
|
4668
4763
|
}
|
4669
4764
|
}
|
@@ -4674,6 +4769,7 @@ class Wordpress
|
|
4674
4769
|
@data['image_size'][2].checked = false
|
4675
4770
|
@data['image_size'][0].checked = false
|
4676
4771
|
@data['image_size'][4].checked = false
|
4772
|
+
@data['image_size'][5].checked = false
|
4677
4773
|
end
|
4678
4774
|
}
|
4679
4775
|
}
|
@@ -4684,6 +4780,18 @@ class Wordpress
|
|
4684
4780
|
@data['image_size'][2].checked = false
|
4685
4781
|
@data['image_size'][3].checked = false
|
4686
4782
|
@data['image_size'][0].checked = false
|
4783
|
+
@data['image_size'][5].checked = false
|
4784
|
+
end
|
4785
|
+
}
|
4786
|
+
}
|
4787
|
+
@data['image_size'][5] = checkbox('원본 px'){
|
4788
|
+
on_toggled{
|
4789
|
+
if @data['image_size'][5].checked?
|
4790
|
+
@data['image_size'][1].checked = false
|
4791
|
+
@data['image_size'][2].checked = false
|
4792
|
+
@data['image_size'][3].checked = false
|
4793
|
+
@data['image_size'][0].checked = false
|
4794
|
+
@data['image_size'][4].checked = false
|
4687
4795
|
end
|
4688
4796
|
}
|
4689
4797
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics_duo
|
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
|