duo_blog_comment 0.0.59 → 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 +1206 -371
  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,377 +1057,1168 @@ class Naver
1058
1057
  else
1059
1058
  end
1060
1059
 
1061
- if @data['포스트설정']['순서사용2'].checked?
1062
- @content_soon ||= 0 # 초기 한 번만 0으로 세팅
1063
-
1064
- if @data['내용설정']['내용'].nil? || @data['내용설정']['내용'].empty?
1065
- content = ''
1066
- else
1067
- if @data.dig('내용설정', '랜덤사용')&.respond_to?(:checked?) && @data['내용설정']['랜덤사용'].checked?
1068
- content = @data['내용설정']['내용'].sample[2]
1069
- else
1070
- content = @data['내용설정']['내용'][@content_soon][2]
1071
- @content_soon += 1
1072
- @content_soon = 0 if @content_soon >= @data['내용설정']['내용'].length
1073
- end
1074
- end
1075
- else
1076
- end
1077
-
1078
- # 디엠 자동 변경이 체크된 경우 content를 변환
1079
- if @data['포스트설정']['내용자동변경'].checked?
1080
- change_memory = {}
1081
- @data['포스트설정']['내용자동변경값'].each do |key, v|
1082
- change_memory[key] = v.sample
1083
- end
1084
- @data['포스트설정']['내용자동변경값'].each do |key, _|
1085
- if content.include?(key)
1086
- content = content.gsub(key, change_memory[key]) # gsub을 사용하여 내용 치환
1087
- else
1088
- end
1089
- end
1090
- end
1091
-
1092
- begin #댓글 작업 >> 시작
1093
- # 댓글 쓰기 버튼 클릭
1094
- begin
1095
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1096
- wait.until { @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]') }
1097
- element = @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]')
1098
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1099
- sleep(1)
1100
- @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]').click
1101
- sleep(1)
1102
- rescue
1060
+ if option['re_coment'] == 'true'
1061
+ puts "대 댓글 진행합니다.".red
1103
1062
  begin
1104
1063
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1105
- wait.until { @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']") }
1106
- 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"]')
1107
1066
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1108
1067
  sleep(1)
1109
- @driver.find_element(xpath: "//span[@class='btn_arr']//span[@class='blind']").click
1068
+ @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]').click
1110
1069
  sleep(1)
1111
- rescue => e
1112
- 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
1113
1082
  end
1114
- end
1115
1083
 
1116
- if option['댓글패스'] == 'true'
1117
- # class="u_cbox_work_sub" 요소 확인 class="u_cbox_work_sub"
1118
- begin
1119
- work_sub_element = @driver.find_elements(:xpath, '//*[@class="u_cbox_work_sub"]')
1120
- if work_sub_element.any?
1121
- puts "이 전에 작성 한 댓글 발견!!.해당 글에 댓글을 작성하지 않습니다"
1122
- raise '댓글 패스' # 예외를 발생시켜 가장 아래의 rescue로 이동
1123
- end
1124
- rescue => e
1125
- 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
+ # 여기에 다른 코드 추가 가능
1126
1097
  end
1127
- else
1128
- # 여기에 다른 코드 추가 가능
1129
- 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
1130
1114
 
1131
- begin
1132
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1133
- wait.until { @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]') }
1134
- element = @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]')
1135
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1136
- sleep(1)
1137
- rescue
1138
- 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
1139
1163
 
1140
- if option['ChatGPT사용'] == 'true'
1141
- pcol1 = @driver.find_element(:css, 'div.pcol1').text
1142
- sleep(1)
1143
-
1144
- puts "ChatGPT로 댓글을 만드는 중입니다."
1145
- @api_key = api_key
1146
- url = 'https://api.openai.com/v1/chat/completions'
1147
- headers = {
1148
- 'Content-Type' => 'application/json',
1149
- 'Authorization' => 'Bearer ' + @api_key
1150
- }
1151
- data = {
1152
- 'model' => 'gpt-3.5-turbo',
1153
- 'messages' => [
1154
- { "role" => "system", "content" => "해당 제목에 알맞은 댓글을 짧게 한 개만 만들어줘" },
1155
- { "role" => "user", "content" => pcol1 } # pcol1 직접 사용
1156
- ]
1157
- }
1158
-
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
1159
1458
  begin
1160
- req = HTTP.headers(headers).post(url, json: data)
1161
- puts "HTTP Status: #{req.status}" # 상태 코드 확인
1162
- response = JSON.parse(req.body.to_s)
1163
- puts "API Response: #{response}" # 전체 응답 출력
1164
-
1165
- if req.status == 429
1166
- return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
1167
- end
1168
-
1169
- # 응답 데이터에서 안전하게 값 추출
1170
- raw_answer = response.dig('choices', 0, 'message', 'content') || "댓글 생성을 실패했습니다." # 응답이 없을 경우 기본 메시지 설정
1171
- answer = raw_answer.gsub(/\. /, ".\n") # 줄바꿈 추가
1172
-
1173
- rescue => e
1174
- puts "Error: #{e.message}"
1175
- answer = "오류가 발생했습니다."
1176
- end
1177
-
1178
- # 댓글 입력
1179
- @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1180
- sleep(1)
1181
- Clipboard.copy(answer)
1182
- sleep(1)
1183
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1184
- sleep(1)
1185
- 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)
1186
1817
  begin
1187
- Clipboard.copy(content)
1188
- puts (content)
1189
- @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1818
+ @driver.switch_to.alert
1819
+ sleep(1)
1820
+ error_text = @driver.switch_to.alert.text
1190
1821
  sleep(1)
1191
- @driver.action.send_keys(content).perform
1192
- #@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
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
1839
+
1193
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}"
1194
1861
  end
1195
- end
1196
-
1197
- # 이모티콘 자동 삽입
1198
- if option['이모티콘자동삽입'] == 'true'
1199
-
1200
- sleep(1)
1201
- # '이모티콘' 버튼 클릭
1202
- @driver.find_element(:xpath, '//*[@data-action="write#beforeToggleSticker"]').click
1203
- sleep(1)
1204
-
1205
- actions = [
1206
- lambda {
1207
- begin
1208
- @driver.find_element(:xpath, '//*[@data-param="motion2d_01"]').click
1209
- sleep(2)
1210
-
1211
- random_number = (1..24).to_a.sample
1212
- @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
1213
- sleep(2)
1214
-
1215
- rescue
1862
+ end
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
1216
1892
  end
1217
- },
1218
- lambda {
1219
-
1893
+ end
1894
+ end
1895
+ begin #댓글 작업 >> 시작─────────────────────────────────────────────────────────────────────────────────────────>>>>>>일반 댓글
1896
+ # 댓글 쓰기 버튼 클릭
1220
1897
  begin
1221
- @driver.find_element(:xpath, '//*[@data-param="motion3d_02"]').click
1222
- sleep(2)
1223
-
1224
- random_number = (1..24).to_a.sample
1225
- @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) # 크롤 이동
1226
1902
  sleep(1)
1227
- @driver.action.key_down(:enter).key_up(:enter).perform
1228
- sleep(2)
1229
-
1230
-
1231
- 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
1232
1917
  end
1233
- },
1234
- lambda {
1235
1918
 
1236
- begin
1237
- @driver.find_element(:xpath, '//*[@data-param="cafe_004"]').click
1238
- sleep(2)
1239
-
1240
- random_number = (1..28).to_a.sample
1241
- @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
1242
- sleep(2)
1243
-
1244
- 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
+ # 여기에 다른 코드 추가 가능
1245
1932
  end
1246
- },
1247
- lambda {
1248
1933
 
1249
1934
  begin
1250
- @driver.find_element(:xpath, '//*[@data-param="cafe_005"]').click
1251
- sleep(2)
1252
-
1253
- random_number = (1..26).to_a.sample
1254
- @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
1255
- sleep(2)
1256
-
1257
- 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
1258
1941
  end
1259
- },
1260
- lambda {
1261
-
1262
- begin
1263
- @driver.find_element(:xpath, '//*[@data-param="cafe_001"]').click
1264
- sleep(2)
1265
1942
 
1266
- random_number = (1..24).to_a.sample
1267
- @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
1268
1945
  sleep(1)
1269
- @driver.action.key_down(:enter).key_up(:enter).perform
1270
- sleep(2)
1271
1946
 
1272
- rescue
1273
- end
1274
- },
1275
- lambda {
1276
-
1277
- begin
1278
- @driver.find_element(:xpath, '//*[@data-param="cafe_002"]').click
1279
- sleep(2)
1280
-
1281
- random_number = (1..24).to_a.sample
1282
- @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
1283
1983
  sleep(1)
1284
- @driver.action.key_down(:enter).key_up(:enter).perform
1285
- sleep(2)
1286
- rescue
1287
- end
1288
- }
1289
- ]
1290
- actions.sample.call
1291
-
1292
-
1293
- elsif option['이미지자동삽입'] == 'true'
1294
- begin
1295
- sleep(1)
1296
- @image = image
1297
- image_path = image
1298
- #클립보드에 복사
1299
- file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
1300
- # send_keys로 파일 경로를 입력하여 이미지 업로드
1301
- file_input.send_keys(image_path)
1302
- sleep(1)
1303
- rescue
1304
- end
1305
- end
1306
- sleep(1)
1307
- if option['비공개댓글'] == 'true'
1308
- begin
1309
- @driver.find_element(:xpath, '//*[@class="u_cbox_secret_label"]').click
1310
- sleep(1)
1311
- rescue
1312
- begin
1313
- @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
+
1314
2003
  sleep(1)
1315
- rescue
2004
+ # '이모티콘' 버튼 클릭
2005
+ @driver.find_element(:xpath, '//*[@data-action="write#beforeToggleSticker"]').click
2006
+ sleep(1)
2007
+
2008
+ actions = [
2009
+ lambda {
2010
+ begin
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
+
1316
2023
  begin
1317
- @driver.find_element(:xpath, '//*[@class="u_cbox_txt_secret"]').click
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
1318
2029
  sleep(1)
2030
+ @driver.action.key_down(:enter).key_up(:enter).perform
2031
+ sleep(2)
2032
+
2033
+
1319
2034
  rescue
1320
- end
1321
- end
1322
- end
1323
- else
1324
- # 여기에 다른 코드 추가 가능
1325
- end
2035
+ end
2036
+ },
2037
+ lambda {
1326
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 {
1327
2051
 
1328
- begin
1329
- element = @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]')
1330
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1331
- sleep(2)
1332
- @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]').click #등록버튼
1333
- rescue
1334
- begin
1335
- element = @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]')
1336
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1337
- sleep(2)
1338
- @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]').click #등록버튼
1339
- rescue
1340
- begin
1341
- element = @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]')
1342
- @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1343
- sleep(2)
1344
- @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]').click #등록버튼
1345
- 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
+ # 여기에 다른 코드 추가 가능
1346
2128
  end
2129
+
1347
2130
  begin
1348
- 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"]')
1349
2138
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1350
2139
  sleep(2)
1351
- @driver.find_element(:xpath, '//*[@data-log="RPC.write"]').click #등록버튼
1352
- 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
1353
2157
  end
1354
- end
1355
- end
1356
- posting_url = @driver.current_url
1357
- puts "#{posting_url} [댓글 작성 완료 !!]".cyan
1358
-
1359
- begin
1360
- sleep(counts_delay)
1361
- rescue
1362
- end
1363
-
1364
- sleep(2)
1365
- begin
1366
- @driver.switch_to.alert
1367
- sleep(1)
1368
- error_text = @driver.switch_to.alert.text
1369
- sleep(1)
1370
- @driver.switch_to.alert.accept
1371
- puts (error_text).red
1372
- posting_url = @driver.current_url
2158
+ posting_url = @driver.current_url
2159
+ puts "#{posting_url} [댓글 진행 완료 !!]".cyan
1373
2160
 
1374
- File.open('./log/posting_log.txt', 'a') do |ff|
1375
- ff.write('[')
1376
- ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1377
- ff.write(']')
1378
- ff.write(' ')
1379
- ff.write('【등록실패:')
1380
- ff.write(error_text)
1381
- ff.write('】')
1382
- ff.write(' ')
1383
- ff.write(posting_url)
1384
- ff.close()
1385
- puts '-[√] 로그 파일 생성 완료.......'.yellow
1386
- end
1387
-
1388
- rescue
1389
- #@driver.execute_script("document.body.style.zoom = '1.00'")
1390
- sleep(1)
1391
- 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
1392
2184
 
1393
- File.open('./log/posting_log.txt', 'a') do |ff|
1394
- ff.write('[')
1395
- ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1396
- ff.write(']')
1397
- ff.write(' ')
1398
- ff.write('【등록성공확인】')
1399
- ff.write(' ')
1400
- ff.write(posting_url)
1401
- ff.write("\n")
1402
- ff.close()
1403
- puts '-[√] 로그 파일 생성 완료.......'.yellow
1404
- end
1405
- 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
1406
2203
 
1407
- def sleep_with_progress(sleep_delay)
1408
- print "[설정 딜레이 진행 중] "
1409
- steps = (sleep_delay.to_f / 0.5).to_i
1410
- steps.times do
1411
- print "."
1412
- STDOUT.flush
1413
- sleep(1)
1414
- end
1415
- puts "\n"
1416
- end
1417
- sleep_with_progress(sleep_delay)
1418
-
1419
- rescue
1420
-
1421
- end #댓글 작업 >> 끝
1422
-
1423
-
1424
-
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)
1425
2215
 
1426
- end
1427
-
2216
+ rescue
2217
+
2218
+ end #댓글 작업 >> 끝─────────────────────────────────────────────────────────────────────────────────────────>>>>>>일반 댓글
2219
+ end
2220
+ end
1428
2221
 
1429
-
1430
-
1431
-
1432
2222
  begin
1433
2223
  @driver.window_handles.each do |handle|
1434
2224
  @driver.switch_to.window(handle)
@@ -1444,15 +2234,10 @@ class Naver
1444
2234
 
1445
2235
  end
1446
2236
 
1447
-
1448
-
1449
-
1450
-
1451
-
1452
2237
  end
1453
2238
  end
1454
2239
 
1455
- class Wordpress
2240
+ class Wordpress
1456
2241
  include Glimmer
1457
2242
 
1458
2243
  def login_check2(user_id, user_pw)
@@ -1566,7 +2351,7 @@ class Wordpress
1566
2351
  # 상태 표시 퍼샌테이지 아래 [7]넘버는 게이지바에 맞게 넘버를 넣어줘야 작동됨
1567
2352
  while true
1568
2353
  for n in 0..@data['table'].length-1
1569
- @data['table'][n][8] = 0
2354
+ @data['table'][n][9] = 0
1570
2355
  end
1571
2356
 
1572
2357
  while true
@@ -1588,6 +2373,18 @@ class Wordpress
1588
2373
  option['category'] = ''
1589
2374
  end
1590
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
1591
2388
 
1592
2389
  option['proxy'] = ''
1593
2390
  if @data['포스트설정']['프록시'].checked?
@@ -1598,7 +2395,7 @@ class Wordpress
1598
2395
  end
1599
2396
  end
1600
2397
 
1601
- if table[7].to_i > table[8].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
2398
+ if table[8].to_i > table[9].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1602
2399
  #if table[6].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1603
2400
 
1604
2401
  if @data['포스트설정']['테더링'].checked?
@@ -1962,15 +2759,15 @@ class Wordpress
1962
2759
  # p option
1963
2760
 
1964
2761
  # 댓글 설정 수 카운트
1965
- counts_number = @data['table'][index][6].to_i
1966
- 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
1967
2764
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
1968
2765
  naver.update(content,image,option,counts_number,keyword,blog_url,api_key,sleep_delay)
1969
2766
 
1970
2767
 
1971
2768
 
1972
2769
  #완료했으니 수량 카운터
1973
- @data['table'][index][8] = @data['table'][index][8].to_i + 1
2770
+ @data['table'][index][9] = @data['table'][index][9].to_i + 1
1974
2771
  @data['table'][index][-1] = 100
1975
2772
  @data['table'] << []
1976
2773
  @data['table'].pop
@@ -2348,8 +3145,8 @@ class Wordpress
2348
3145
  button('    댓글 등록 ID 추가    '){
2349
3146
 
2350
3147
  on_clicked {
2351
- @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text, 1, 2, 1,0,0]
2352
- @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]
2353
3150
  @data['table'].pop
2354
3151
  }
2355
3152
  }
@@ -2362,8 +3159,8 @@ class Wordpress
2362
3159
  file_data.split("\n").each do |i|
2363
3160
  i3 = i.to_s.force_encoding('utf-8').to_s
2364
3161
  i2 = i3.split(',')
2365
- @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s, 1,2,1,0,0]
2366
- @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]
2367
3164
  @data['table'].pop
2368
3165
  end
2369
3166
  end
@@ -2391,8 +3188,12 @@ class Wordpress
2391
3188
  text_column('프록시'){
2392
3189
  editable true
2393
3190
  }
3191
+
3192
+ checkbox_column('대댓글작업') {
3193
+ editable true
3194
+ }
2394
3195
 
2395
- text_column('딜레이'){
3196
+ text_column('딜레이'){
2396
3197
  editable true
2397
3198
  }
2398
3199
 
@@ -2485,9 +3286,9 @@ class Wordpress
2485
3286
  table_counter_again = @data['table_counter_again'].text.to_i
2486
3287
  # @data['table']의 각 항목을 업데이트
2487
3288
  @data['table'].map! do |row|
2488
- row[5] = table_delay_input
2489
- row[6] = table_counter_input
2490
- row[7] = table_counter_again
3289
+ row[6] = table_delay_input
3290
+ row[7] = table_counter_input
3291
+ row[8] = table_counter_again
2491
3292
  row # 수정된 row를 반환
2492
3293
  end
2493
3294
  }
@@ -3214,9 +4015,14 @@ class Wordpress
3214
4015
  @data['포스트설정']['블로그무작위'].checked = false
3215
4016
  end
3216
4017
  }
3217
- }
4018
+ }
4019
+ }
4020
+ }
3218
4021
 
3219
- @data['포스트설정']['이웃추가'] = checkbox('이웃추가'){
4022
+ horizontal_box{
4023
+ stretchy false
4024
+ grid{
4025
+ @data['포스트설정']['이웃추가'] = checkbox('이웃추가       '){
3220
4026
  top 2
3221
4027
  left 0
3222
4028
 
@@ -3226,7 +4032,7 @@ class Wordpress
3226
4032
  end
3227
4033
  }
3228
4034
  }
3229
- @data['포스트설정']['서로이웃추가'] = checkbox('서로이웃추가'){
4035
+ @data['포스트설정']['서로이웃추가'] = checkbox('서로이웃추가     '){
3230
4036
  top 2
3231
4037
  left 1
3232
4038
 
@@ -3236,7 +4042,7 @@ class Wordpress
3236
4042
  end
3237
4043
  }
3238
4044
  }
3239
- @data['포스트설정']['공유하기'] = checkbox('공유하기'){
4045
+ @data['포스트설정']['공유하기'] = checkbox('공유하기       '){
3240
4046
  top 2
3241
4047
  left 2
3242
4048
 
@@ -3246,7 +4052,7 @@ class Wordpress
3246
4052
  end
3247
4053
  }
3248
4054
  }
3249
- @data['포스트설정']['공유하기비공개'] = checkbox('비공개 공유하기'){
4055
+ @data['포스트설정']['공유하기비공개'] = checkbox('비공개 공유하기     '){
3250
4056
  top 2
3251
4057
  left 3
3252
4058
 
@@ -3255,9 +4061,25 @@ class Wordpress
3255
4061
  @data['포스트설정']['공유하기'].checked = false
3256
4062
  end
3257
4063
  }
3258
- }
3259
-
3260
- }}
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
+ }
3261
4083
 
3262
4084
 
3263
4085
 
@@ -3287,32 +4109,45 @@ class Wordpress
3287
4109
  }
3288
4110
  }
3289
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) '){
3290
4123
  top 1
3291
- left 2
4124
+ left 3
3292
4125
  on_toggled{
3293
- if @data['포스트설정']['이미지자동삽입'].checked?
3294
- # @data['포스트설정']['저장내용발송1'].checked = false
3295
- # @data['포스트설정']['저장내용발송2'].checked = false
3296
- @data['포스트설정']['이모티콘자동삽입'].checked = false
4126
+ if @data['포스트설정']['전체대댓글'].checked?
4127
+ @data['포스트설정']['지정대댓글'].checked = false
3297
4128
  end
3298
4129
  }
3299
4130
  }
3300
- @data['포스트설정']['비공개댓글'] = checkbox('🔒비공개 댓글   '){
3301
- top 1
3302
- left 3
3303
- on_toggled{
3304
-
3305
- }
3306
- }
3307
- @data['포스트설정']['댓글패스'] = checkbox('🔙이미 작성한 댓글이 있는 경우 패스'){
4131
+ @data['포스트설정']['지정대댓글'] = checkbox(' 댓글 지정 타겟(옵션2)'){
3308
4132
  top 1
3309
4133
  left 4
3310
4134
  on_toggled{
3311
-
4135
+ if @data['포스트설정']['지정대댓글'].checked?
4136
+ @data['포스트설정']['전체대댓글'].checked = false
4137
+ end
3312
4138
  }
3313
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
+ }
3314
4150
  }
3315
- }
3316
4151
 
3317
4152
 
3318
4153
  vertical_separator{