duo_blog_comment 0.0.59 → 0.0.62

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