duo_blog_comment 0.0.57 → 0.0.61

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/duo_blog_comment.rb +1228 -369
  3. metadata +2 -2
@@ -580,7 +580,7 @@ class Naver
580
580
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
581
581
  sleep(1)
582
582
 
583
- # 수집된 URL을 저장할 배열
583
+ # 수집된 URL을 저장할 배열
584
584
  collected_urls = []
585
585
 
586
586
  # 현재 페이지에서 수집할 링크 개수
@@ -615,7 +615,6 @@ class Naver
615
615
  remaining_count -= 1
616
616
  end
617
617
  end
618
- sleep(1)
619
618
  end
620
619
 
621
620
  # 수집된 개수가 요구한 수에 도달하면 종료
@@ -1058,374 +1057,1168 @@ class Naver
1058
1057
  else
1059
1058
  end
1060
1059
 
1061
- @content_soon ||= 0 # 초기 한 번만 0으로 세팅
1062
-
1063
- if @data['내용설정']['내용'].nil? || @data['내용설정']['내용'].empty?
1064
- content = ''
1065
- else
1066
- if @data.dig('내용설정', '랜덤사용')&.respond_to?(:checked?) && @data['내용설정']['랜덤사용'].checked?
1067
- content = @data['내용설정']['내용'].sample[2]
1068
- else
1069
- content = @data['내용설정']['내용'][@content_soon][2]
1070
- @content_soon += 1
1071
- @content_soon = 0 if @content_soon >= @data['내용설정']['내용'].length
1072
- end
1073
- end
1074
-
1075
- # 디엠 자동 변경이 체크된 경우 content를 변환
1076
- if @data['포스트설정']['내용자동변경'].checked?
1077
- change_memory = {}
1078
- @data['포스트설정']['내용자동변경값'].each do |key, v|
1079
- change_memory[key] = v.sample
1080
- end
1081
- @data['포스트설정']['내용자동변경값'].each do |key, _|
1082
- if content.include?(key)
1083
- content = content.gsub(key, change_memory[key]) # gsub을 사용하여 내용 치환
1084
- else
1085
- end
1086
- end
1087
- end
1088
-
1089
- begin #댓글 작업 >> 시작
1090
- # 댓글 쓰기 버튼 클릭
1091
- begin
1092
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1093
- wait.until { @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]') }
1094
- element = @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]')
1095
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1096
- sleep(1)
1097
- @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]').click
1098
- sleep(1)
1099
- rescue
1060
+ if option['re_coment'] == 'true'
1061
+ puts "대 댓글 진행합니다.".red
1100
1062
  begin
1101
1063
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1102
- wait.until { @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']") }
1103
- element = @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']")
1064
+ wait.until { @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]') }
1065
+ element = @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]')
1104
1066
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1105
1067
  sleep(1)
1106
- @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']").click
1068
+ @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]').click
1107
1069
  sleep(1)
1108
- rescue => e
1109
- puts "댓글 작성 필드가 존재 하지않습니다."
1070
+ rescue
1071
+ begin
1072
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1073
+ wait.until { @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']") }
1074
+ element = @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']")
1075
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1076
+ sleep(1)
1077
+ @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']").click
1078
+ sleep(1)
1079
+ rescue => e
1080
+ puts "댓글 작성 필드가 존재 하지않습니다."
1081
+ end
1110
1082
  end
1111
- end
1112
1083
 
1113
- if option['댓글패스'] == 'true'
1114
- # class="u_cbox_work_sub" 요소 확인 class="u_cbox_work_sub"
1115
- begin
1116
- work_sub_element = @driver.find_elements(:xpath, '//*[@class="u_cbox_work_sub"]')
1117
- if work_sub_element.any?
1118
- puts "이 전에 작성 한 댓글 발견!!.해당 글에 댓글을 작성하지 않습니다"
1119
- raise '댓글 패스' # 예외를 발생시켜 가장 아래의 rescue로 이동
1120
- end
1121
- rescue => e
1122
- raise e # 예외를 바깥쪽으로 전파
1084
+ if option['댓글패스'] == 'true'
1085
+ # class="u_cbox_work_sub" 요소 확인 class="u_cbox_work_sub"
1086
+ begin
1087
+ work_sub_element = @driver.find_elements(:xpath, '//*[@class="u_cbox_work_sub"]')
1088
+ if work_sub_element.any?
1089
+ puts "이 전에 작성 한 댓글 발견!!.해당 글에 댓글을 작성하지 않습니다"
1090
+ raise '댓글 패스' # 예외를 발생시켜 가장 아래의 rescue로 이동
1091
+ end
1092
+ rescue => e
1093
+ raise e # 예외를 바깥쪽으로 전파
1094
+ end
1095
+ else
1096
+ # 여기에 다른 코드 추가 가능
1123
1097
  end
1124
- else
1125
- # 여기에 다른 코드 추가 가능
1126
- end
1098
+ if @data['포스트설정']['전체대댓글'].checked? # 전체 대댓글 처리 ────────── 01
1099
+ begin
1100
+
1101
+ # 1. 댓글 영역 전체를 로드하기 위한 스크롤 함수
1102
+ def scroll_to_load_all_comments
1103
+ container = @driver.find_element(css: '.u_cbox')
1104
+ last_height = @driver.execute_script("return arguments[0].scrollHeight;", container)
1105
+
1106
+ loop do
1107
+ @driver.execute_script("arguments[0].scrollTo(0, arguments[0].scrollHeight);", container)
1108
+ sleep(1.5)
1109
+ new_height = @driver.execute_script("return arguments[0].scrollHeight;", container)
1110
+ break if new_height == last_height
1111
+ last_height = new_height
1112
+ end
1113
+ end
1127
1114
 
1128
- begin
1129
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1130
- wait.until { @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]') }
1131
- element = @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]')
1132
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1133
- sleep(1)
1134
- rescue
1135
- end
1115
+ # 호출
1116
+ scroll_to_load_all_comments
1117
+ puts "댓글 전체 로딩 완료"
1118
+
1119
+ # 2. 댓글 ID 수집 (replyLevel:1 기준)
1120
+ comment_items = @driver.find_elements(:css, 'li')
1121
+ original_comment_ids = comment_items.select do |item|
1122
+ item.attribute('data-info').to_s.include?("replyLevel:1")
1123
+ end.map do |item|
1124
+ match = item.attribute('class').to_s.match(/comment_(\d+)/)
1125
+ match ? match[1] : nil
1126
+ end.compact
1127
+
1128
+ puts "총 원댓글 수: #{original_comment_ids.size}"
1129
+
1130
+ # 3. 각 댓글에 대해 대댓글 작성 반복
1131
+ original_comment_ids.each_with_index do |comment_id, index|
1132
+
1133
+ if @data['포스트설정']['순서사용2'].checked?
1134
+ @content_soon ||= 0 # 초기 한 번만 0으로 세팅
1135
+
1136
+ if @data['내용설정']['내용'].nil? || @data['내용설정']['내용'].empty?
1137
+ content = ''
1138
+ else
1139
+ if @data.dig('내용설정', '랜덤사용')&.respond_to?(:checked?) && @data['내용설정']['랜덤사용'].checked?
1140
+ content = @data['내용설정']['내용'].sample[2]
1141
+ else
1142
+ content = @data['내용설정']['내용'][@content_soon][2]
1143
+ @content_soon += 1
1144
+ @content_soon = 0 if @content_soon >= @data['내용설정']['내용'].length
1145
+ end
1146
+ end
1147
+ else
1148
+ end
1149
+
1150
+ # 디엠 자동 변경이 체크된 경우 content를 변환
1151
+ if @data['포스트설정']['내용자동변경'].checked?
1152
+ change_memory = {}
1153
+ @data['포스트설정']['내용자동변경값'].each do |key, v|
1154
+ change_memory[key] = v.sample
1155
+ end
1156
+ @data['포스트설정']['내용자동변경값'].each do |key, _|
1157
+ if content.include?(key)
1158
+ content = content.gsub(key, change_memory[key]) # gsub을 사용하여 내용 치환
1159
+ else
1160
+ end
1161
+ end
1162
+ end
1136
1163
 
1137
- if option['ChatGPT사용'] == 'true'
1138
- pcol1 = @driver.find_element(:css, 'div.pcol1').text
1139
- sleep(1)
1140
-
1141
- puts "ChatGPT로 댓글을 만드는 중입니다."
1142
- @api_key = api_key
1143
- url = 'https://api.openai.com/v1/chat/completions'
1144
- headers = {
1145
- 'Content-Type' => 'application/json',
1146
- 'Authorization' => 'Bearer ' + @api_key
1147
- }
1148
- data = {
1149
- 'model' => 'gpt-3.5-turbo',
1150
- 'messages' => [
1151
- { "role" => "system", "content" => "해당 제목에 알맞은 댓글을 짧게 한 개만 만들어줘" },
1152
- { "role" => "user", "content" => pcol1 } # pcol1 직접 사용
1153
- ]
1154
- }
1155
-
1164
+ if option['ChatGPT사용'] == 'true'
1165
+ pcol1 = @driver.find_element(:css, 'div.pcol1').text
1166
+ sleep(1)
1167
+
1168
+ puts "ChatGPT로 댓글을 만드는 중입니다."
1169
+ @api_key = api_key
1170
+ url = 'https://api.openai.com/v1/chat/completions'
1171
+ headers = {
1172
+ 'Content-Type' => 'application/json',
1173
+ 'Authorization' => 'Bearer ' + @api_key
1174
+ }
1175
+ data = {
1176
+ 'model' => 'gpt-3.5-turbo',
1177
+ 'messages' => [
1178
+ { "role" => "system", "content" => "해당 제목에 알맞은 댓글을 짧게 한 개만 만들어줘" },
1179
+ { "role" => "user", "content" => pcol1 } # pcol1 직접 사용
1180
+ ]
1181
+ }
1182
+
1183
+ begin
1184
+ req = HTTP.headers(headers).post(url, json: data)
1185
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
1186
+ response = JSON.parse(req.body.to_s)
1187
+ puts "API Response: #{response}" # 전체 응답 출력
1188
+
1189
+ if req.status == 429
1190
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
1191
+ end
1192
+
1193
+ # 응답 데이터에서 안전하게 값 추출
1194
+ raw_content = response.dig('choices', 0, 'message', 'content') || "댓글 생성을 실패했습니다." # 응답이 없을 경우 기본 메시지 설정
1195
+ content = raw_content.gsub(/\. /, ".\n") # 줄바꿈 추가
1196
+
1197
+ rescue => e
1198
+ puts "Error: #{e.message}"
1199
+ content = "오류가 발생했습니다."
1200
+ end
1201
+
1202
+
1203
+ else
1204
+
1205
+ end
1206
+
1207
+
1208
+ puts "─ 대댓글 #{index + 1} 처리 시작 (댓글 ID: #{comment_id})"
1209
+
1210
+ begin
1211
+ # 댓글 요소 재탐색 (Stale 요소 방지)
1212
+ comment_items = @driver.find_elements(:css, 'li')
1213
+ item = comment_items.find { |el| el.attribute('class').include?("comment_#{comment_id}") }
1214
+
1215
+ unless item
1216
+ puts "대댓글 #{index + 1}: 대상 댓글을 찾지 못했습니다."
1217
+ next
1218
+ end
1219
+
1220
+ # 답글 버튼 클릭
1221
+ reply_button = item.find_elements(:css, 'a.u_cbox_btn_reply').find do |a|
1222
+ a.attribute('data-action') == 'reply#toggle'
1223
+ end
1224
+
1225
+ if reply_button
1226
+ @driver.execute_script("arguments[0].click();", reply_button)
1227
+ sleep(1)
1228
+ else
1229
+ puts "대댓글 #{index + 1}: 답글 버튼 없음"
1230
+ next
1231
+ end
1232
+
1233
+ # label 클릭 → textarea 활성화
1234
+ label = item.find_elements(:tag_name, 'label').find do |l|
1235
+ l.attribute('for').to_s.include?("__reply_textarea_#{comment_id}")
1236
+ end
1237
+
1238
+ unless label
1239
+ puts "대댓글 #{index + 1}: label 미발견"
1240
+ next
1241
+ end
1242
+
1243
+ @driver.execute_script("arguments[0].click();", label)
1244
+ sleep(0.5)
1245
+ textarea_id = label.attribute('for')
1246
+ textarea = item.find_element(:id, textarea_id)
1247
+
1248
+ if textarea
1249
+ @driver.execute_script("arguments[0].innerText = arguments[1];", textarea, content)
1250
+ sleep(1)
1251
+ else
1252
+ puts "대댓글 #{index + 1}: textarea 미발견"
1253
+ next
1254
+ end
1255
+
1256
+ if option['이모티콘자동삽입'] == 'true'
1257
+
1258
+ sleep(1)
1259
+ # '이모티콘' 버튼 클릭
1260
+ @driver.find_element(:xpath, '//*[@type="button" and @class="u_cbox_btn_upload_sticker"]').click
1261
+ sleep(1)
1262
+
1263
+ actions = [
1264
+ lambda {
1265
+ begin
1266
+ @driver.find_element(:xpath, '//*[@data-param="motion2d_01"]').click
1267
+ sleep(2)
1268
+
1269
+ random_number = (1..24).to_a.sample
1270
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion2d_01"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion2d_01-'+random_number.to_s+'"]').click
1271
+ sleep(2)
1272
+
1273
+ rescue
1274
+ end
1275
+ },
1276
+ lambda {
1277
+
1278
+ begin
1279
+ @driver.find_element(:xpath, '//*[@data-param="motion3d_02"]').click
1280
+ sleep(2)
1281
+
1282
+ random_number = (1..24).to_a.sample
1283
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion3d_02"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion3d_02-'+random_number.to_s+'"]').click
1284
+ sleep(1)
1285
+ @driver.action.key_down(:enter).key_up(:enter).perform
1286
+ sleep(2)
1287
+
1288
+
1289
+ rescue
1290
+ end
1291
+ },
1292
+ lambda {
1293
+
1294
+ begin
1295
+ @driver.find_element(:xpath, '//*[@data-param="cafe_004"]').click
1296
+ sleep(2)
1297
+
1298
+ random_number = (1..28).to_a.sample
1299
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_004"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_004-'+random_number.to_s+'"]').click
1300
+ sleep(2)
1301
+
1302
+ rescue
1303
+ end
1304
+ },
1305
+ lambda {
1306
+
1307
+ begin
1308
+ @driver.find_element(:xpath, '//*[@data-param="cafe_005"]').click
1309
+ sleep(2)
1310
+
1311
+ random_number = (1..26).to_a.sample
1312
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_005"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_005-'+random_number.to_s+'"]').click
1313
+ sleep(2)
1314
+
1315
+ rescue
1316
+ end
1317
+ },
1318
+ lambda {
1319
+
1320
+ begin
1321
+ @driver.find_element(:xpath, '//*[@data-param="cafe_001"]').click
1322
+ sleep(2)
1323
+
1324
+ random_number = (1..24).to_a.sample
1325
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_001"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_001-'+random_number.to_s+'"]').click
1326
+ sleep(1)
1327
+ @driver.action.key_down(:enter).key_up(:enter).perform
1328
+ sleep(2)
1329
+
1330
+ rescue
1331
+ end
1332
+ },
1333
+ lambda {
1334
+
1335
+ begin
1336
+ @driver.find_element(:xpath, '//*[@data-param="cafe_002"]').click
1337
+ sleep(2)
1338
+
1339
+ random_number = (1..24).to_a.sample
1340
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_002"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_002-'+random_number.to_s+'"]').click
1341
+ sleep(1)
1342
+ @driver.action.key_down(:enter).key_up(:enter).perform
1343
+ sleep(2)
1344
+ rescue
1345
+ end
1346
+ }
1347
+ ]
1348
+ actions.sample.call
1349
+
1350
+
1351
+ elsif option['이미지자동삽입'] == 'true'
1352
+ begin
1353
+ sleep(1)
1354
+ @image = image
1355
+ image_path = image
1356
+ #클립보드에 복사
1357
+ file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
1358
+ # send_keys로 파일 경로를 입력하여 이미지 업로드
1359
+ file_input.send_keys(image_path)
1360
+ sleep(1)
1361
+ rescue
1362
+ end
1363
+ end
1364
+ sleep(1)
1365
+ if option['비공개댓글'] == 'true'
1366
+ begin
1367
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_label"]').click
1368
+ sleep(1)
1369
+ rescue
1370
+ begin
1371
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_check"]').click
1372
+ sleep(1)
1373
+ rescue
1374
+ begin
1375
+ @driver.find_element(:xpath, '//*[@class="u_cbox_txt_secret"]').click
1376
+ sleep(1)
1377
+ rescue
1378
+ end
1379
+ end
1380
+ end
1381
+ else
1382
+ # 여기에 다른 코드 추가 가능
1383
+ end
1384
+
1385
+
1386
+ # 등록 버튼 클릭
1387
+ register_btn = item.find_elements(:css, 'button.u_cbox_btn_upload').find do |btn|
1388
+ btn.attribute('data-action').to_s.include?('write#request') &&
1389
+ btn.displayed? && btn.enabled?
1390
+ end
1391
+
1392
+ if register_btn
1393
+ @driver.execute_script("arguments[0].click();", register_btn)
1394
+ sleep(2)
1395
+ puts "대댓글 #{index + 1} 등록 완료"
1396
+ else
1397
+ puts "대댓글 #{index + 1}: 등록 버튼 미발견"
1398
+ end
1399
+
1400
+ rescue => e
1401
+ puts "대댓글 #{index + 1} 처리 중 오류: #{e.message}"
1402
+ next
1403
+ end
1404
+ end
1405
+
1406
+ posting_url = @driver.current_url
1407
+ puts "#{posting_url} [대 댓글 진행 완료 !!]".cyan
1408
+ sleep(2)
1409
+ begin
1410
+ @driver.switch_to.alert
1411
+ sleep(1)
1412
+ error_text = @driver.switch_to.alert.text
1413
+ sleep(1)
1414
+ @driver.switch_to.alert.accept
1415
+ puts (error_text).red
1416
+ posting_url = @driver.current_url
1417
+
1418
+ File.open('./log/posting_log.txt', 'a') do |ff|
1419
+ ff.write('[')
1420
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1421
+ ff.write(']')
1422
+ ff.write(' ')
1423
+ ff.write('【등록실패:')
1424
+ ff.write(error_text)
1425
+ ff.write('】')
1426
+ ff.write(' ')
1427
+ ff.write(posting_url)
1428
+ ff.close()
1429
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
1430
+ end
1431
+
1432
+ rescue
1433
+ #@driver.execute_script("document.body.style.zoom = '1.00'")
1434
+ sleep(1)
1435
+ posting_url = @driver.current_url
1436
+
1437
+ File.open('./log/posting_log.txt', 'a') do |ff|
1438
+ ff.write('[')
1439
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1440
+ ff.write(']')
1441
+ ff.write(' ')
1442
+ ff.write('【등록성공확인】')
1443
+ ff.write(' ')
1444
+ ff.write(posting_url)
1445
+ ff.write("\n")
1446
+ ff.close()
1447
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
1448
+ end
1449
+ end
1450
+
1451
+
1452
+ rescue => e
1453
+ puts "전체 처리 중 예외 발생: #{e.message}"
1454
+ end
1455
+
1456
+
1457
+ elsif @data['포스트설정']['지정대댓글'].checked? # 지정 (숫자/) 대댓글 처리 ───── 02
1156
1458
  begin
1157
- req = HTTP.headers(headers).post(url, json: data)
1158
- puts "HTTP Status: #{req.status}" # 상태 코드 확인
1159
- response = JSON.parse(req.body.to_s)
1160
- puts "API Response: #{response}" # 전체 응답 출력
1161
-
1162
- if req.status == 429
1163
- return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
1164
- end
1165
-
1166
- # 응답 데이터에서 안전하게 값 추출
1167
- raw_answer = response.dig('choices', 0, 'message', 'content') || "댓글 생성을 실패했습니다." # 응답이 없을 경우 기본 메시지 설정
1168
- answer = raw_answer.gsub(/\. /, ".\n") # 줄바꿈 추가
1169
-
1170
- rescue => e
1171
- puts "Error: #{e.message}"
1172
- answer = "오류가 발생했습니다."
1173
- end
1174
-
1175
- # 댓글 입력
1176
- @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1177
- sleep(1)
1178
- Clipboard.copy(answer)
1179
- sleep(1)
1180
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1181
- sleep(1)
1182
- else
1459
+ targets = @data['포스트설정']['nik_or_number'].text.to_s.force_encoding('utf-8').split(',').map(&:strip)
1460
+
1461
+ # 댓글 전체 로드 함수
1462
+ def scroll_to_load_all_comments
1463
+ container = @driver.find_element(css: '.u_cbox')
1464
+ last_height = @driver.execute_script("return arguments[0].scrollHeight;", container)
1465
+
1466
+ loop do
1467
+ @driver.execute_script("arguments[0].scrollTo(0, arguments[0].scrollHeight);", container)
1468
+ sleep(1.5)
1469
+ new_height = @driver.execute_script("return arguments[0].scrollHeight;", container)
1470
+ break if new_height == last_height
1471
+ last_height = new_height
1472
+ end
1473
+ end
1474
+
1475
+ scroll_to_load_all_comments
1476
+ puts "전체 댓글 스크롤 로딩 완료"
1477
+
1478
+ # 전체 댓글 요소 (초기 수집용)
1479
+ initial_comment_items = @driver.find_elements(:css, 'li')
1480
+
1481
+ # replyLevel:1인 원댓글 ID 추출
1482
+ original_comment_ids = initial_comment_items.select do |item|
1483
+ item.attribute('data-info').to_s.include?("replyLevel:1")
1484
+ end.map do |item|
1485
+ match = item.attribute('class').to_s.match(/comment_(\d+)/)
1486
+ match ? match[1] : nil
1487
+ end.compact
1488
+
1489
+ puts "총 원댓글 수: #{original_comment_ids.size}"
1490
+
1491
+ # 각 타겟 처리
1492
+ targets.each do |target|
1493
+ comment_ids_to_reply = []
1494
+
1495
+ # ✅ 매 반복마다 fresh한 comment_items 확보 (stale 방지)
1496
+ comment_items = @driver.find_elements(:css, 'li')
1497
+
1498
+ if target.match?(/^\d+$/)
1499
+ # 숫자 인덱스 처리
1500
+ index = target.to_i - 1
1501
+
1502
+ if comment_id = original_comment_ids[index]
1503
+ puts "#{index + 1}번째 댓글 (ID: #{comment_id}) 대댓글 작성 시작"
1504
+ comment_ids_to_reply = [comment_id]
1505
+ else
1506
+ puts "지정된 index(#{index + 1})에 해당하는 댓글 ID가 없습니다"
1507
+ next
1508
+ end
1509
+
1510
+ else # 지정 (닉네임/) 대댓글 처리 ───── 03
1511
+ puts "닉네임 '#{target}'에 해당하는 댓글들 찾는 중..."
1512
+
1513
+ matched_items = comment_items.select do |item|
1514
+ nick_span = item.find_elements(:css, '.u_cbox_nick').find { |el| el.text.strip == target }
1515
+ nick_span && item.attribute('data-info').to_s.include?("replyLevel:1")
1516
+ end
1517
+
1518
+ if matched_items.empty?
1519
+ puts "닉네임 '#{target}'에 해당하는 원댓글을 찾지 못했습니다"
1520
+ next
1521
+ end
1522
+
1523
+ # 👇 가장 마지막(최신) 댓글 1개만 선택
1524
+ last_matched_item = matched_items.last
1525
+ match = last_matched_item.attribute('class').to_s.match(/comment_(\d+)/)
1526
+ comment_id = match ? match[1] : nil
1527
+
1528
+ unless comment_id
1529
+ puts "닉네임 '#{target}'의 댓글 ID 추출 실패"
1530
+ next
1531
+ end
1532
+
1533
+ puts "닉네임 '#{target}'의 가장 마지막 댓글 (ID: #{comment_id}) 대댓글 작성 시작"
1534
+ comment_ids_to_reply = [comment_id]
1535
+ end
1536
+
1537
+ # 대댓글 작성 루프 (사실 1개만 처리)
1538
+ comment_ids_to_reply.each do |comment_id|
1539
+ begin
1540
+ if @data['포스트설정']['순서사용2'].checked?
1541
+ @content_soon ||= 0 # 초기 한 번만 0으로 세팅
1542
+
1543
+ if @data['내용설정']['내용'].nil? || @data['내용설정']['내용'].empty?
1544
+ content = ''
1545
+ else
1546
+ if @data.dig('내용설정', '랜덤사용')&.respond_to?(:checked?) && @data['내용설정']['랜덤사용'].checked?
1547
+ content = @data['내용설정']['내용'].sample[2]
1548
+ else
1549
+ content = @data['내용설정']['내용'][@content_soon][2]
1550
+ @content_soon += 1
1551
+ @content_soon = 0 if @content_soon >= @data['내용설정']['내용'].length
1552
+ end
1553
+ end
1554
+ else
1555
+ end
1556
+
1557
+ # 디엠 자동 변경이 체크된 경우 content를 변환
1558
+ if @data['포스트설정']['내용자동변경'].checked?
1559
+ change_memory = {}
1560
+ @data['포스트설정']['내용자동변경값'].each do |key, v|
1561
+ change_memory[key] = v.sample
1562
+ end
1563
+ @data['포스트설정']['내용자동변경값'].each do |key, _|
1564
+ if content.include?(key)
1565
+ content = content.gsub(key, change_memory[key]) # gsub을 사용하여 내용 치환
1566
+ else
1567
+ end
1568
+ end
1569
+ end
1570
+
1571
+ if option['ChatGPT사용'] == 'true'
1572
+ pcol1 = @driver.find_element(:css, 'div.pcol1').text
1573
+ sleep(1)
1574
+
1575
+ puts "ChatGPT로 댓글을 만드는 중입니다."
1576
+ @api_key = api_key
1577
+ url = 'https://api.openai.com/v1/chat/completions'
1578
+ headers = {
1579
+ 'Content-Type' => 'application/json',
1580
+ 'Authorization' => 'Bearer ' + @api_key
1581
+ }
1582
+ data = {
1583
+ 'model' => 'gpt-3.5-turbo',
1584
+ 'messages' => [
1585
+ { "role" => "system", "content" => "해당 제목에 알맞은 댓글을 짧게 한 개만 만들어줘" },
1586
+ { "role" => "user", "content" => pcol1 } # pcol1 직접 사용
1587
+ ]
1588
+ }
1589
+
1590
+ begin
1591
+ req = HTTP.headers(headers).post(url, json: data)
1592
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
1593
+ response = JSON.parse(req.body.to_s)
1594
+ puts "API Response: #{response}" # 전체 응답 출력
1595
+
1596
+ if req.status == 429
1597
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
1598
+ end
1599
+
1600
+ # 응답 데이터에서 안전하게 값 추출
1601
+ raw_content = response.dig('choices', 0, 'message', 'content') || "댓글 생성을 실패했습니다." # 응답이 없을 경우 기본 메시지 설정
1602
+ content = raw_content.gsub(/\. /, ".\n") # 줄바꿈 추가
1603
+
1604
+ rescue => e
1605
+ puts "Error: #{e.message}"
1606
+ content = "오류가 발생했습니다."
1607
+ end
1608
+
1609
+
1610
+ else
1611
+
1612
+ end
1613
+
1614
+
1615
+ # ✅ 다시 fresh한 comment_items 확보 (stale 방지)
1616
+ comment_items = @driver.find_elements(:css, 'li')
1617
+ item = comment_items.find { |el| el.attribute('class').include?("comment_#{comment_id}") }
1618
+
1619
+ unless item
1620
+ puts "댓글 요소를 찾지 못했습니다 (ID: #{comment_id})"
1621
+ next
1622
+ end
1623
+
1624
+ reply_button = item.find_elements(:css, 'a.u_cbox_btn_reply').find do |a|
1625
+ a.attribute('data-action') == 'reply#toggle'
1626
+ end
1627
+
1628
+ if reply_button
1629
+ @driver.execute_script("arguments[0].click();", reply_button)
1630
+ sleep(1)
1631
+ else
1632
+ puts "답글 버튼 없음"
1633
+ next
1634
+ end
1635
+
1636
+ label = item.find_elements(:tag_name, 'label').find do |l|
1637
+ l.attribute('for').to_s.include?("__reply_textarea_#{comment_id}")
1638
+ end
1639
+
1640
+ unless label
1641
+ puts "label 요소를 찾지 못함"
1642
+ next
1643
+ end
1644
+
1645
+ @driver.execute_script("arguments[0].click();", label)
1646
+ sleep(0.5)
1647
+
1648
+ textarea_id = label.attribute('for')
1649
+ textarea = item.find_element(:id, textarea_id)
1650
+
1651
+ if textarea
1652
+ @driver.execute_script("arguments[0].innerText = arguments[1];", textarea, content)
1653
+ sleep(1)
1654
+ else
1655
+ puts "textarea 요소를 찾지 못함"
1656
+ next
1657
+ end
1658
+
1659
+
1660
+ if option['이모티콘자동삽입'] == 'true'
1661
+
1662
+ sleep(1)
1663
+ # '이모티콘' 버튼 클릭
1664
+ @driver.find_element(:xpath, '//*[@type="button" and @class="u_cbox_btn_upload_sticker"]').click
1665
+ sleep(1)
1666
+
1667
+ actions = [
1668
+ lambda {
1669
+ begin
1670
+ @driver.find_element(:xpath, '//*[@data-param="motion2d_01"]').click
1671
+ sleep(2)
1672
+
1673
+ random_number = (1..24).to_a.sample
1674
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion2d_01"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion2d_01-'+random_number.to_s+'"]').click
1675
+ sleep(2)
1676
+
1677
+ rescue
1678
+ end
1679
+ },
1680
+ lambda {
1681
+
1682
+ begin
1683
+ @driver.find_element(:xpath, '//*[@data-param="motion3d_02"]').click
1684
+ sleep(2)
1685
+
1686
+ random_number = (1..24).to_a.sample
1687
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion3d_02"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion3d_02-'+random_number.to_s+'"]').click
1688
+ sleep(1)
1689
+ @driver.action.key_down(:enter).key_up(:enter).perform
1690
+ sleep(2)
1691
+
1692
+
1693
+ rescue
1694
+ end
1695
+ },
1696
+ lambda {
1697
+
1698
+ begin
1699
+ @driver.find_element(:xpath, '//*[@data-param="cafe_004"]').click
1700
+ sleep(2)
1701
+
1702
+ random_number = (1..28).to_a.sample
1703
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_004"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_004-'+random_number.to_s+'"]').click
1704
+ sleep(2)
1705
+
1706
+ rescue
1707
+ end
1708
+ },
1709
+ lambda {
1710
+
1711
+ begin
1712
+ @driver.find_element(:xpath, '//*[@data-param="cafe_005"]').click
1713
+ sleep(2)
1714
+
1715
+ random_number = (1..26).to_a.sample
1716
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_005"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_005-'+random_number.to_s+'"]').click
1717
+ sleep(2)
1718
+
1719
+ rescue
1720
+ end
1721
+ },
1722
+ lambda {
1723
+
1724
+ begin
1725
+ @driver.find_element(:xpath, '//*[@data-param="cafe_001"]').click
1726
+ sleep(2)
1727
+
1728
+ random_number = (1..24).to_a.sample
1729
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_001"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_001-'+random_number.to_s+'"]').click
1730
+ sleep(1)
1731
+ @driver.action.key_down(:enter).key_up(:enter).perform
1732
+ sleep(2)
1733
+
1734
+ rescue
1735
+ end
1736
+ },
1737
+ lambda {
1738
+
1739
+ begin
1740
+ @driver.find_element(:xpath, '//*[@data-param="cafe_002"]').click
1741
+ sleep(2)
1742
+
1743
+ random_number = (1..24).to_a.sample
1744
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_002"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_002-'+random_number.to_s+'"]').click
1745
+ sleep(1)
1746
+ @driver.action.key_down(:enter).key_up(:enter).perform
1747
+ sleep(2)
1748
+ rescue
1749
+ end
1750
+ }
1751
+ ]
1752
+ actions.sample.call
1753
+
1754
+
1755
+ elsif option['이미지자동삽입'] == 'true'
1756
+ begin
1757
+ sleep(1)
1758
+ @image = image
1759
+ image_path = image
1760
+ #클립보드에 복사
1761
+ file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
1762
+ # send_keys로 파일 경로를 입력하여 이미지 업로드
1763
+ file_input.send_keys(image_path)
1764
+ sleep(1)
1765
+ rescue
1766
+ end
1767
+ end
1768
+ sleep(1)
1769
+ if option['비공개댓글'] == 'true'
1770
+ begin
1771
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_label"]').click
1772
+ sleep(1)
1773
+ rescue
1774
+ begin
1775
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_check"]').click
1776
+ sleep(1)
1777
+ rescue
1778
+ begin
1779
+ @driver.find_element(:xpath, '//*[@class="u_cbox_txt_secret"]').click
1780
+ sleep(1)
1781
+ rescue
1782
+ end
1783
+ end
1784
+ end
1785
+ else
1786
+ # 여기에 다른 코드 추가 가능
1787
+ end
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+ register_btn = item.find_elements(:css, 'button.u_cbox_btn_upload').find do |btn|
1795
+ btn.attribute('data-action').to_s.include?('write#request') &&
1796
+ btn.displayed? && btn.enabled?
1797
+ end
1798
+
1799
+ if register_btn
1800
+ @driver.execute_script("arguments[0].click();", register_btn)
1801
+ sleep(2)
1802
+ puts "댓글 (ID: #{comment_id}) 대댓글 등록 완료"
1803
+ else
1804
+ puts "등록 버튼 찾지 못함"
1805
+ end
1806
+
1807
+ rescue => e
1808
+ puts " 처리 중 오류 발생: #{e.message}"
1809
+ next
1810
+ end
1811
+ end
1812
+ end
1813
+
1814
+ posting_url = @driver.current_url
1815
+ puts "#{posting_url} [대 댓글 진행 완료 !!]".cyan
1816
+ sleep(2)
1183
1817
  begin
1184
- Clipboard.copy(content)
1185
- puts (content)
1186
- @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1818
+ @driver.switch_to.alert
1187
1819
  sleep(1)
1188
- @driver.action.send_keys(content).perform
1189
- #@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1190
- rescue
1191
- end
1192
- end
1193
-
1194
- # 이모티콘 자동 삽입
1195
- if option['이모티콘자동삽입'] == 'true'
1820
+ error_text = @driver.switch_to.alert.text
1821
+ sleep(1)
1822
+ @driver.switch_to.alert.accept
1823
+ puts (error_text).red
1824
+ posting_url = @driver.current_url
1825
+
1826
+ File.open('./log/posting_log.txt', 'a') do |ff|
1827
+ ff.write('[')
1828
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1829
+ ff.write(']')
1830
+ ff.write(' ')
1831
+ ff.write('【등록실패:')
1832
+ ff.write(error_text)
1833
+ ff.write('】')
1834
+ ff.write(' ')
1835
+ ff.write(posting_url)
1836
+ ff.close()
1837
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
1838
+ end
1196
1839
 
1197
- sleep(1)
1198
- # '이모티콘' 버튼 클릭
1199
- @driver.find_element(:xpath, '//*[@data-action="write#beforeToggleSticker"]').click
1200
- sleep(1)
1201
-
1202
- actions = [
1203
- lambda {
1204
- begin
1205
- @driver.find_element(:xpath, '//*[@data-param="motion2d_01"]').click
1206
- sleep(2)
1207
-
1208
- random_number = (1..24).to_a.sample
1209
- @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion2d_01"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion2d_01-'+random_number.to_s+'"]').click
1210
- sleep(2)
1211
-
1212
- rescue
1840
+ rescue
1841
+ #@driver.execute_script("document.body.style.zoom = '1.00'")
1842
+ sleep(1)
1843
+ posting_url = @driver.current_url
1844
+
1845
+ File.open('./log/posting_log.txt', 'a') do |ff|
1846
+ ff.write('[')
1847
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1848
+ ff.write(']')
1849
+ ff.write(' ')
1850
+ ff.write('【등록성공확인】')
1851
+ ff.write(' ')
1852
+ ff.write(posting_url)
1853
+ ff.write("\n")
1854
+ ff.close()
1855
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
1856
+ end
1857
+ end
1858
+
1859
+ rescue => e
1860
+ puts "전체 처리 중 예외 발생: #{e.message}"
1213
1861
  end
1214
- },
1215
- lambda {
1862
+ end
1216
1863
 
1864
+ elsif option['re_coment'] =='false'
1865
+ if @data['포스트설정']['순서사용2'].checked?
1866
+ @content_soon ||= 0 # 초기 한 번만 0으로 세팅
1867
+
1868
+ if @data['내용설정']['내용'].nil? || @data['내용설정']['내용'].empty?
1869
+ content = ''
1870
+ else
1871
+ if @data.dig('내용설정', '랜덤사용')&.respond_to?(:checked?) && @data['내용설정']['랜덤사용'].checked?
1872
+ content = @data['내용설정']['내용'].sample[2]
1873
+ else
1874
+ content = @data['내용설정']['내용'][@content_soon][2]
1875
+ @content_soon += 1
1876
+ @content_soon = 0 if @content_soon >= @data['내용설정']['내용'].length
1877
+ end
1878
+ end
1879
+ else
1880
+ end
1881
+
1882
+ # 디엠 자동 변경이 체크된 경우 content를 변환
1883
+ if @data['포스트설정']['내용자동변경'].checked?
1884
+ change_memory = {}
1885
+ @data['포스트설정']['내용자동변경값'].each do |key, v|
1886
+ change_memory[key] = v.sample
1887
+ end
1888
+ @data['포스트설정']['내용자동변경값'].each do |key, _|
1889
+ if content.include?(key)
1890
+ content = content.gsub(key, change_memory[key]) # gsub을 사용하여 내용 치환
1891
+ else
1892
+ end
1893
+ end
1894
+ end
1895
+ begin #댓글 작업 >> 시작─────────────────────────────────────────────────────────────────────────────────────────>>>>>>일반 댓글
1896
+ # 댓글 쓰기 버튼 클릭
1217
1897
  begin
1218
- @driver.find_element(:xpath, '//*[@data-param="motion3d_02"]').click
1219
- sleep(2)
1220
-
1221
- random_number = (1..24).to_a.sample
1222
- @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion3d_02"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion3d_02-'+random_number.to_s+'"]').click
1898
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1899
+ wait.until { @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]') }
1900
+ element = @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]')
1901
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1223
1902
  sleep(1)
1224
- @driver.action.key_down(:enter).key_up(:enter).perform
1225
- sleep(2)
1226
-
1227
-
1228
- rescue
1903
+ @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]').click
1904
+ sleep(1)
1905
+ rescue
1906
+ begin
1907
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1908
+ wait.until { @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']") }
1909
+ element = @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']")
1910
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1911
+ sleep(1)
1912
+ @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']").click
1913
+ sleep(1)
1914
+ rescue => e
1915
+ puts "댓글 작성 필드가 존재 하지않습니다."
1916
+ end
1229
1917
  end
1230
- },
1231
- lambda {
1232
1918
 
1233
- begin
1234
- @driver.find_element(:xpath, '//*[@data-param="cafe_004"]').click
1235
- sleep(2)
1236
-
1237
- random_number = (1..28).to_a.sample
1238
- @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_004"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_004-'+random_number.to_s+'"]').click
1239
- sleep(2)
1240
-
1241
- rescue
1919
+ if option['댓글패스'] == 'true'
1920
+ # class="u_cbox_work_sub" 요소 확인 class="u_cbox_work_sub"
1921
+ begin
1922
+ work_sub_element = @driver.find_elements(:xpath, '//*[@class="u_cbox_work_sub"]')
1923
+ if work_sub_element.any?
1924
+ puts "이 전에 작성 한 댓글 발견!!.해당 글에 댓글을 작성하지 않습니다"
1925
+ raise '댓글 패스' # 예외를 발생시켜 가장 아래의 rescue로 이동
1926
+ end
1927
+ rescue => e
1928
+ raise e # 예외를 바깥쪽으로 전파
1929
+ end
1930
+ else
1931
+ # 여기에 다른 코드 추가 가능
1242
1932
  end
1243
- },
1244
- lambda {
1245
1933
 
1246
1934
  begin
1247
- @driver.find_element(:xpath, '//*[@data-param="cafe_005"]').click
1248
- sleep(2)
1249
-
1250
- random_number = (1..26).to_a.sample
1251
- @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_005"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_005-'+random_number.to_s+'"]').click
1252
- sleep(2)
1253
-
1254
- rescue
1935
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1936
+ wait.until { @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]') }
1937
+ element = @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]')
1938
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1939
+ sleep(1)
1940
+ rescue
1255
1941
  end
1256
- },
1257
- lambda {
1258
-
1259
- begin
1260
- @driver.find_element(:xpath, '//*[@data-param="cafe_001"]').click
1261
- sleep(2)
1262
1942
 
1263
- random_number = (1..24).to_a.sample
1264
- @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_001"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_001-'+random_number.to_s+'"]').click
1943
+ if option['ChatGPT사용'] == 'true'
1944
+ pcol1 = @driver.find_element(:css, 'div.pcol1').text
1265
1945
  sleep(1)
1266
- @driver.action.key_down(:enter).key_up(:enter).perform
1267
- sleep(2)
1268
1946
 
1269
- rescue
1270
- end
1271
- },
1272
- lambda {
1273
-
1274
- begin
1275
- @driver.find_element(:xpath, '//*[@data-param="cafe_002"]').click
1276
- sleep(2)
1277
-
1278
- random_number = (1..24).to_a.sample
1279
- @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_002"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_002-'+random_number.to_s+'"]').click
1947
+ puts "ChatGPT로 댓글을 만드는 중입니다."
1948
+ @api_key = api_key
1949
+ url = 'https://api.openai.com/v1/chat/completions'
1950
+ headers = {
1951
+ 'Content-Type' => 'application/json',
1952
+ 'Authorization' => 'Bearer ' + @api_key
1953
+ }
1954
+ data = {
1955
+ 'model' => 'gpt-3.5-turbo',
1956
+ 'messages' => [
1957
+ { "role" => "system", "content" => "해당 제목에 알맞은 댓글을 짧게 한 개만 만들어줘" },
1958
+ { "role" => "user", "content" => pcol1 } # pcol1 직접 사용
1959
+ ]
1960
+ }
1961
+
1962
+ begin
1963
+ req = HTTP.headers(headers).post(url, json: data)
1964
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
1965
+ response = JSON.parse(req.body.to_s)
1966
+ puts "API Response: #{response}" # 전체 응답 출력
1967
+
1968
+ if req.status == 429
1969
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
1970
+ end
1971
+
1972
+ # 응답 데이터에서 안전하게 값 추출
1973
+ raw_content = response.dig('choices', 0, 'message', 'content') || "댓글 생성을 실패했습니다." # 응답이 없을 경우 기본 메시지 설정
1974
+ content = raw_content.gsub(/\. /, ".\n") # 줄바꿈 추가
1975
+
1976
+ rescue => e
1977
+ puts "Error: #{e.message}"
1978
+ content = "오류가 발생했습니다."
1979
+ end
1980
+
1981
+ # 댓글 입력
1982
+ @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1280
1983
  sleep(1)
1281
- @driver.action.key_down(:enter).key_up(:enter).perform
1282
- sleep(2)
1283
- rescue
1284
- end
1285
- }
1286
- ]
1287
- actions.sample.call
1288
-
1289
-
1290
- elsif option['이미지자동삽입'] == 'true'
1291
- begin
1292
- sleep(1)
1293
- @image = image
1294
- image_path = image
1295
- #클립보드에 복사
1296
- file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
1297
- # send_keys로 파일 경로를 입력하여 이미지 업로드
1298
- file_input.send_keys(image_path)
1299
- sleep(1)
1300
- rescue
1301
- end
1302
- end
1303
- sleep(1)
1304
- if option['비공개댓글'] == 'true'
1305
- begin
1306
- @driver.find_element(:xpath, '//*[@class="u_cbox_secret_label"]').click
1307
- sleep(1)
1308
- rescue
1309
- begin
1310
- @driver.find_element(:xpath, '//*[@class="u_cbox_secret_check"]').click
1984
+ Clipboard.copy(content)
1985
+ sleep(0.5)
1986
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1987
+ sleep(1)
1988
+ else
1989
+ begin
1990
+ Clipboard.copy(content)
1991
+ puts (content)
1992
+ @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1993
+ sleep(1)
1994
+ @driver.action.send_keys(content).perform
1995
+ #@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1996
+ rescue
1997
+ end
1998
+ end
1999
+
2000
+ # 이모티콘 자동 삽입
2001
+ if option['이모티콘자동삽입'] == 'true'
2002
+
1311
2003
  sleep(1)
1312
- rescue
2004
+ # '이모티콘' 버튼 클릭
2005
+ @driver.find_element(:xpath, '//*[@data-action="write#beforeToggleSticker"]').click
2006
+ sleep(1)
2007
+
2008
+ actions = [
2009
+ lambda {
1313
2010
  begin
1314
- @driver.find_element(:xpath, '//*[@class="u_cbox_txt_secret"]').click
2011
+ @driver.find_element(:xpath, '//*[@data-param="motion2d_01"]').click
2012
+ sleep(2)
2013
+
2014
+ random_number = (1..24).to_a.sample
2015
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion2d_01"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion2d_01-'+random_number.to_s+'"]').click
2016
+ sleep(2)
2017
+
2018
+ rescue
2019
+ end
2020
+ },
2021
+ lambda {
2022
+
2023
+ begin
2024
+ @driver.find_element(:xpath, '//*[@data-param="motion3d_02"]').click
2025
+ sleep(2)
2026
+
2027
+ random_number = (1..24).to_a.sample
2028
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion3d_02"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion3d_02-'+random_number.to_s+'"]').click
1315
2029
  sleep(1)
2030
+ @driver.action.key_down(:enter).key_up(:enter).perform
2031
+ sleep(2)
2032
+
2033
+
1316
2034
  rescue
1317
- end
1318
- end
1319
- end
1320
- else
1321
- # 여기에 다른 코드 추가 가능
1322
- end
2035
+ end
2036
+ },
2037
+ lambda {
1323
2038
 
2039
+ begin
2040
+ @driver.find_element(:xpath, '//*[@data-param="cafe_004"]').click
2041
+ sleep(2)
2042
+
2043
+ random_number = (1..28).to_a.sample
2044
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_004"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_004-'+random_number.to_s+'"]').click
2045
+ sleep(2)
2046
+
2047
+ rescue
2048
+ end
2049
+ },
2050
+ lambda {
1324
2051
 
1325
- begin
1326
- element = @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]')
1327
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1328
- sleep(2)
1329
- @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]').click #등록버튼
1330
- rescue
1331
- begin
1332
- element = @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]')
1333
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1334
- sleep(2)
1335
- @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]').click #등록버튼
1336
- rescue
1337
- begin
1338
- element = @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]')
1339
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1340
- sleep(2)
1341
- @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]').click #등록버튼
1342
- rescue
2052
+ begin
2053
+ @driver.find_element(:xpath, '//*[@data-param="cafe_005"]').click
2054
+ sleep(2)
2055
+
2056
+ random_number = (1..26).to_a.sample
2057
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_005"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_005-'+random_number.to_s+'"]').click
2058
+ sleep(2)
2059
+
2060
+ rescue
2061
+ end
2062
+ },
2063
+ lambda {
2064
+
2065
+ begin
2066
+ @driver.find_element(:xpath, '//*[@data-param="cafe_001"]').click
2067
+ sleep(2)
2068
+
2069
+ random_number = (1..24).to_a.sample
2070
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_001"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_001-'+random_number.to_s+'"]').click
2071
+ sleep(1)
2072
+ @driver.action.key_down(:enter).key_up(:enter).perform
2073
+ sleep(2)
2074
+
2075
+ rescue
2076
+ end
2077
+ },
2078
+ lambda {
2079
+
2080
+ begin
2081
+ @driver.find_element(:xpath, '//*[@data-param="cafe_002"]').click
2082
+ sleep(2)
2083
+
2084
+ random_number = (1..24).to_a.sample
2085
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_002"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_002-'+random_number.to_s+'"]').click
2086
+ sleep(1)
2087
+ @driver.action.key_down(:enter).key_up(:enter).perform
2088
+ sleep(2)
2089
+ rescue
2090
+ end
2091
+ }
2092
+ ]
2093
+ actions.sample.call
2094
+
2095
+
2096
+ elsif option['이미지자동삽입'] == 'true'
2097
+ begin
2098
+ sleep(1)
2099
+ @image = image
2100
+ image_path = image
2101
+ #클립보드에 복사
2102
+ file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
2103
+ # send_keys로 파일 경로를 입력하여 이미지 업로드
2104
+ file_input.send_keys(image_path)
2105
+ sleep(1)
2106
+ rescue
2107
+ end
2108
+ end
2109
+ sleep(1)
2110
+ if option['비공개댓글'] == 'true'
2111
+ begin
2112
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_label"]').click
2113
+ sleep(1)
2114
+ rescue
2115
+ begin
2116
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_check"]').click
2117
+ sleep(1)
2118
+ rescue
2119
+ begin
2120
+ @driver.find_element(:xpath, '//*[@class="u_cbox_txt_secret"]').click
2121
+ sleep(1)
2122
+ rescue
2123
+ end
2124
+ end
2125
+ end
2126
+ else
2127
+ # 여기에 다른 코드 추가 가능
1343
2128
  end
2129
+
1344
2130
  begin
1345
- element = @driver.find_element(:xpath, '//*[@data-log="RPC.write"]')
2131
+ element = @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]')
2132
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
2133
+ sleep(2)
2134
+ @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]').click #등록버튼
2135
+ rescue
2136
+ begin
2137
+ element = @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]')
1346
2138
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1347
2139
  sleep(2)
1348
- @driver.find_element(:xpath, '//*[@data-log="RPC.write"]').click #등록버튼
1349
- rescue
2140
+ @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]').click #등록버튼
2141
+ rescue
2142
+ begin
2143
+ element = @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]')
2144
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
2145
+ sleep(2)
2146
+ @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]').click #등록버튼
2147
+ rescue
2148
+ begin
2149
+ element = @driver.find_element(:xpath, '//*[@data-log="RPC.write"]')
2150
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
2151
+ sleep(2)
2152
+ @driver.find_element(:xpath, '//*[@data-log="RPC.write"]').click #등록버튼
2153
+ rescue
2154
+ end
2155
+ end
2156
+ end
1350
2157
  end
1351
- end
1352
- end
1353
- posting_url = @driver.current_url
1354
- puts "#{posting_url} [댓글 작성 완료 !!]".cyan
1355
-
1356
- begin
1357
- sleep(counts_delay)
1358
- rescue
1359
- end
1360
-
1361
- sleep(2)
1362
- begin
1363
- @driver.switch_to.alert
1364
- sleep(1)
1365
- error_text = @driver.switch_to.alert.text
1366
- sleep(1)
1367
- @driver.switch_to.alert.accept
1368
- puts (error_text).red
1369
- posting_url = @driver.current_url
2158
+ posting_url = @driver.current_url
2159
+ puts "#{posting_url} [댓글 진행 완료 !!]".cyan
1370
2160
 
1371
- File.open('./log/posting_log.txt', 'a') do |ff|
1372
- ff.write('[')
1373
- ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1374
- ff.write(']')
1375
- ff.write(' ')
1376
- ff.write('【등록실패:')
1377
- ff.write(error_text)
1378
- ff.write('】')
1379
- ff.write(' ')
1380
- ff.write(posting_url)
1381
- ff.close()
1382
- puts '-[√] 로그 파일 생성 완료.......'.yellow
1383
- end
1384
-
1385
- rescue
1386
- #@driver.execute_script("document.body.style.zoom = '1.00'")
1387
- sleep(1)
1388
- posting_url = @driver.current_url
2161
+ sleep(2)
2162
+ begin
2163
+ @driver.switch_to.alert
2164
+ sleep(1)
2165
+ error_text = @driver.switch_to.alert.text
2166
+ sleep(1)
2167
+ @driver.switch_to.alert.accept
2168
+ puts (error_text).red
2169
+ posting_url = @driver.current_url
2170
+
2171
+ File.open('./log/posting_log.txt', 'a') do |ff|
2172
+ ff.write('[')
2173
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
2174
+ ff.write(']')
2175
+ ff.write(' ')
2176
+ ff.write('【등록실패:')
2177
+ ff.write(error_text)
2178
+ ff.write('】')
2179
+ ff.write(' ')
2180
+ ff.write(posting_url)
2181
+ ff.close()
2182
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
2183
+ end
1389
2184
 
1390
- File.open('./log/posting_log.txt', 'a') do |ff|
1391
- ff.write('[')
1392
- ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1393
- ff.write(']')
1394
- ff.write(' ')
1395
- ff.write('【등록성공확인】')
1396
- ff.write(' ')
1397
- ff.write(posting_url)
1398
- ff.write("\n")
1399
- ff.close()
1400
- puts '-[√] 로그 파일 생성 완료.......'.yellow
1401
- end
1402
- end
2185
+ rescue
2186
+ #@driver.execute_script("document.body.style.zoom = '1.00'")
2187
+ sleep(1)
2188
+ posting_url = @driver.current_url
2189
+
2190
+ File.open('./log/posting_log.txt', 'a') do |ff|
2191
+ ff.write('[')
2192
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
2193
+ ff.write(']')
2194
+ ff.write(' ')
2195
+ ff.write('【등록성공확인】')
2196
+ ff.write(' ')
2197
+ ff.write(posting_url)
2198
+ ff.write("\n")
2199
+ ff.close()
2200
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
2201
+ end
2202
+ end
1403
2203
 
1404
- def sleep_with_progress(sleep_delay)
1405
- print "[설정 딜레이 진행 중] "
1406
- steps = (sleep_delay.to_f / 0.5).to_i
1407
- steps.times do
1408
- print "."
1409
- STDOUT.flush
1410
- sleep(1)
1411
- end
1412
- puts "\n"
1413
- end
1414
- sleep_with_progress(sleep_delay)
1415
-
1416
- rescue
1417
-
1418
- end #댓글 작업 >> 끝
1419
-
1420
-
1421
-
2204
+ def sleep_with_progress(sleep_delay)
2205
+ print "[설정 딜레이 진행 중] "
2206
+ steps = (sleep_delay.to_f / 0.5).to_i
2207
+ steps.times do
2208
+ print "."
2209
+ STDOUT.flush
2210
+ sleep(1)
2211
+ end
2212
+ puts "\n"
2213
+ end
2214
+ sleep_with_progress(sleep_delay)
1422
2215
 
1423
- end
1424
-
2216
+ rescue
2217
+
2218
+ end #댓글 작업 >> 끝─────────────────────────────────────────────────────────────────────────────────────────>>>>>>일반 댓글
2219
+ end
2220
+ end
1425
2221
 
1426
-
1427
-
1428
-
1429
2222
  begin
1430
2223
  @driver.window_handles.each do |handle|
1431
2224
  @driver.switch_to.window(handle)
@@ -1441,15 +2234,10 @@ class Naver
1441
2234
 
1442
2235
  end
1443
2236
 
1444
-
1445
-
1446
-
1447
-
1448
-
1449
2237
  end
1450
2238
  end
1451
2239
 
1452
- class Wordpress
2240
+ class Wordpress
1453
2241
  include Glimmer
1454
2242
 
1455
2243
  def login_check2(user_id, user_pw)
@@ -1563,7 +2351,7 @@ class Wordpress
1563
2351
  # 상태 표시 퍼샌테이지 아래 [7]넘버는 게이지바에 맞게 넘버를 넣어줘야 작동됨
1564
2352
  while true
1565
2353
  for n in 0..@data['table'].length-1
1566
- @data['table'][n][8] = 0
2354
+ @data['table'][n][9] = 0
1567
2355
  end
1568
2356
 
1569
2357
  while true
@@ -1585,6 +2373,18 @@ class Wordpress
1585
2373
  option['category'] = ''
1586
2374
  end
1587
2375
 
2376
+ if table[5] == true
2377
+ option['re_coment'] = 'true'
2378
+ if @data['포스트설정']['전체대댓글'].checked?
2379
+
2380
+ elsif @data['포스트설정']['지정대댓글'].checked?
2381
+ nik_or_number = @data['포스트설정']['nik_or_number'].text.to_s.force_encoding('utf-8')
2382
+ puts nik_or_number
2383
+ else
2384
+ end
2385
+ else
2386
+ option['re_coment'] = 'false'
2387
+ end
1588
2388
 
1589
2389
  option['proxy'] = ''
1590
2390
  if @data['포스트설정']['프록시'].checked?
@@ -1595,7 +2395,7 @@ class Wordpress
1595
2395
  end
1596
2396
  end
1597
2397
 
1598
- if table[7].to_i > table[8].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
2398
+ if table[8].to_i > table[9].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1599
2399
  #if table[6].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1600
2400
 
1601
2401
  if @data['포스트설정']['테더링'].checked?
@@ -1770,6 +2570,16 @@ class Wordpress
1770
2570
  @data['table'] << []
1771
2571
  @data['table'].pop
1772
2572
 
2573
+
2574
+ if @data['포스트설정']['순서사용2'].checked?
2575
+ option['순서사용2'] = 'true'
2576
+ else
2577
+ option['순서사용2'] = 'false'
2578
+ end
2579
+ @data['table'][index][-1] = 35
2580
+ @data['table'] << []
2581
+ @data['table'].pop
2582
+
1773
2583
 
1774
2584
 
1775
2585
  #네이버로그인
@@ -1949,15 +2759,15 @@ class Wordpress
1949
2759
  # p option
1950
2760
 
1951
2761
  # 댓글 설정 수 카운트
1952
- counts_number = @data['table'][index][6].to_i
1953
- sleep_delay = @data['table'][index][5].to_i
2762
+ counts_number = @data['table'][index][7].to_i
2763
+ sleep_delay = @data['table'][index][6].to_i
1954
2764
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
1955
2765
  naver.update(content,image,option,counts_number,keyword,blog_url,api_key,sleep_delay)
1956
2766
 
1957
2767
 
1958
2768
 
1959
2769
  #완료했으니 수량 카운터
1960
- @data['table'][index][8] = @data['table'][index][8].to_i + 1
2770
+ @data['table'][index][9] = @data['table'][index][9].to_i + 1
1961
2771
  @data['table'][index][-1] = 100
1962
2772
  @data['table'] << []
1963
2773
  @data['table'].pop
@@ -2335,8 +3145,8 @@ class Wordpress
2335
3145
  button('    댓글 등록 ID 추가    '){
2336
3146
 
2337
3147
  on_clicked {
2338
- @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text, 1, 2, 1,0,0]
2339
- @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text, 1, 2, 1,0,0]
3148
+ @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text,false, 1, 2, 1,0,0]
3149
+ @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text,false, 1, 2, 1,0,0]
2340
3150
  @data['table'].pop
2341
3151
  }
2342
3152
  }
@@ -2349,8 +3159,8 @@ class Wordpress
2349
3159
  file_data.split("\n").each do |i|
2350
3160
  i3 = i.to_s.force_encoding('utf-8').to_s
2351
3161
  i2 = i3.split(',')
2352
- @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s, 1,2,1,0,0]
2353
- @data['table'] << [false, i2[0].to_s, i2[1].to_s, 1,2,1,0,0]
3162
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,['1', 'true'].include?(i2[4].to_s.strip.downcase), 1,2,1,0,0]
3163
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s, false, 1,2,1,0,0]
2354
3164
  @data['table'].pop
2355
3165
  end
2356
3166
  end
@@ -2378,8 +3188,12 @@ class Wordpress
2378
3188
  text_column('프록시'){
2379
3189
  editable true
2380
3190
  }
3191
+
3192
+ checkbox_column('대댓글작업') {
3193
+ editable true
3194
+ }
2381
3195
 
2382
- text_column('딜레이'){
3196
+ text_column('딜레이'){
2383
3197
  editable true
2384
3198
  }
2385
3199
 
@@ -2472,9 +3286,9 @@ class Wordpress
2472
3286
  table_counter_again = @data['table_counter_again'].text.to_i
2473
3287
  # @data['table']의 각 항목을 업데이트
2474
3288
  @data['table'].map! do |row|
2475
- row[5] = table_delay_input
2476
- row[6] = table_counter_input
2477
- row[7] = table_counter_again
3289
+ row[6] = table_delay_input
3290
+ row[7] = table_counter_input
3291
+ row[8] = table_counter_again
2478
3292
  row # 수정된 row를 반환
2479
3293
  end
2480
3294
  }
@@ -2972,11 +3786,21 @@ class Wordpress
2972
3786
 
2973
3787
  horizontal_box{
2974
3788
  stretchy false
2975
- @data['내용설정']['순서사용'] = checkbox('순서사용'){
3789
+ @data['내용설정']['순서사용'] = checkbox('계정마다 순서사용'){
3790
+ stretchy false
3791
+ on_toggled{ |c|
3792
+ if c.checked?
3793
+ @data['내용설정']['랜덤사용'].checked = false
3794
+ @data['포스트설정']['순서사용2'].checked = false
3795
+ end
3796
+ }
3797
+ }
3798
+ @data['포스트설정']['순서사용2'] = checkbox('게시글마다 순서사용'){
2976
3799
  stretchy false
2977
3800
  on_toggled{ |c|
2978
3801
  if c.checked?
2979
3802
  @data['내용설정']['랜덤사용'].checked = false
3803
+ @data['내용설정']['순서사용'].checked = false
2980
3804
  end
2981
3805
  }
2982
3806
  }
@@ -2985,6 +3809,7 @@ class Wordpress
2985
3809
  on_toggled{ |c|
2986
3810
  if c.checked?
2987
3811
  @data['내용설정']['순서사용'].checked = false
3812
+ @data['포스트설정']['순서사용2'].checked = false
2988
3813
  end
2989
3814
  }
2990
3815
  }
@@ -3190,9 +4015,14 @@ class Wordpress
3190
4015
  @data['포스트설정']['블로그무작위'].checked = false
3191
4016
  end
3192
4017
  }
3193
- }
4018
+ }
4019
+ }
4020
+ }
3194
4021
 
3195
- @data['포스트설정']['이웃추가'] = checkbox('이웃추가'){
4022
+ horizontal_box{
4023
+ stretchy false
4024
+ grid{
4025
+ @data['포스트설정']['이웃추가'] = checkbox('이웃추가       '){
3196
4026
  top 2
3197
4027
  left 0
3198
4028
 
@@ -3202,7 +4032,7 @@ class Wordpress
3202
4032
  end
3203
4033
  }
3204
4034
  }
3205
- @data['포스트설정']['서로이웃추가'] = checkbox('서로이웃추가'){
4035
+ @data['포스트설정']['서로이웃추가'] = checkbox('서로이웃추가     '){
3206
4036
  top 2
3207
4037
  left 1
3208
4038
 
@@ -3212,7 +4042,7 @@ class Wordpress
3212
4042
  end
3213
4043
  }
3214
4044
  }
3215
- @data['포스트설정']['공유하기'] = checkbox('공유하기'){
4045
+ @data['포스트설정']['공유하기'] = checkbox('공유하기       '){
3216
4046
  top 2
3217
4047
  left 2
3218
4048
 
@@ -3222,7 +4052,7 @@ class Wordpress
3222
4052
  end
3223
4053
  }
3224
4054
  }
3225
- @data['포스트설정']['공유하기비공개'] = checkbox('비공개 공유하기'){
4055
+ @data['포스트설정']['공유하기비공개'] = checkbox('비공개 공유하기     '){
3226
4056
  top 2
3227
4057
  left 3
3228
4058
 
@@ -3231,9 +4061,25 @@ class Wordpress
3231
4061
  @data['포스트설정']['공유하기'].checked = false
3232
4062
  end
3233
4063
  }
3234
- }
3235
-
3236
- }}
4064
+ }
4065
+ @data['포스트설정']['댓글패스'] = checkbox('🔙이미 작성한 댓글이 있는 경우 패스     '){
4066
+ top 2
4067
+ left 4
4068
+
4069
+ on_toggled{
4070
+
4071
+ }
4072
+ }
4073
+ @data['포스트설정']['비공개댓글'] = checkbox('비공개 댓글'){
4074
+ top 2
4075
+ left 5
4076
+
4077
+ on_toggled{
4078
+
4079
+ }
4080
+ }
4081
+ }
4082
+ }
3237
4083
 
3238
4084
 
3239
4085
 
@@ -3263,32 +4109,45 @@ class Wordpress
3263
4109
  }
3264
4110
  }
3265
4111
  @data['포스트설정']['이미지자동삽입'] = checkbox('📂이미지 자동 삽입   '){
4112
+ top 1
4113
+ left 2
4114
+ on_toggled{
4115
+ if @data['포스트설정']['이미지자동삽입'].checked?
4116
+ # @data['포스트설정']['저장내용발송1'].checked = false
4117
+ # @data['포스트설정']['저장내용발송2'].checked = false
4118
+ @data['포스트설정']['이모티콘자동삽입'].checked = false
4119
+ end
4120
+ }
4121
+ }
4122
+ @data['포스트설정']['전체대댓글'] = checkbox('대 댓글 전체 타겟(옵션1) '){
3266
4123
  top 1
3267
- left 2
4124
+ left 3
3268
4125
  on_toggled{
3269
- if @data['포스트설정']['이미지자동삽입'].checked?
3270
- # @data['포스트설정']['저장내용발송1'].checked = false
3271
- # @data['포스트설정']['저장내용발송2'].checked = false
3272
- @data['포스트설정']['이모티콘자동삽입'].checked = false
4126
+ if @data['포스트설정']['전체대댓글'].checked?
4127
+ @data['포스트설정']['지정대댓글'].checked = false
3273
4128
  end
3274
4129
  }
3275
4130
  }
3276
- @data['포스트설정']['비공개댓글'] = checkbox('🔒비공개 댓글   '){
3277
- top 1
3278
- left 3
3279
- on_toggled{
3280
-
3281
- }
3282
- }
3283
- @data['포스트설정']['댓글패스'] = checkbox('🔙이미 작성한 댓글이 있는 경우 패스'){
4131
+ @data['포스트설정']['지정대댓글'] = checkbox(' 댓글 지정 타겟(옵션2)'){
3284
4132
  top 1
3285
4133
  left 4
3286
4134
  on_toggled{
3287
-
4135
+ if @data['포스트설정']['지정대댓글'].checked?
4136
+ @data['포스트설정']['전체대댓글'].checked = false
4137
+ end
3288
4138
  }
3289
4139
  }
4140
+ @data['포스트설정']['nik_or_number'] = entry(){
4141
+ top 1
4142
+ left 5
4143
+ text '예)마루 or 예)1(댓글넘버)'
4144
+ }
4145
+ label('콤마로 추가 가능 예)마루,강쥐 or 예)1,3'){
4146
+ top 1
4147
+ left 6
4148
+ }
4149
+ }
3290
4150
  }
3291
- }
3292
4151
 
3293
4152
 
3294
4153
  vertical_separator{