| skipped 27 lines |
28 | 28 | | process_message, |
29 | 29 | | process_description, |
30 | 30 | | parse_tg_date, |
31 | | - | parse_html_page |
| 31 | + | parse_html_page, |
| 32 | + | print_shell |
32 | 33 | | ) |
33 | | - | import telepathy.const as const |
| 34 | + | import const as const |
34 | 35 | | |
35 | 36 | | from colorama import Fore, Back, Style |
36 | 37 | | |
| skipped 187 lines |
224 | 225 | | _desc = process_description( |
225 | 226 | | group_description, user_language |
226 | 227 | | ) |
227 | | - | |
228 | | - | original_language = _desc[ |
229 | | - | "original_language" |
230 | | - | ] |
231 | 228 | | translated_description = _desc["translated_text"] |
232 | 229 | | |
233 | 230 | | if Dialog.entity.broadcast is True: |
| skipped 244 lines |
478 | 475 | | width=preferredWidth, |
479 | 476 | | subsequent_indent=" ", |
480 | 477 | | ) |
| 478 | + | found_participants = 0 |
| 479 | + | found_participants = 0 |
481 | 480 | | |
482 | 481 | | if chat_type != "Channel": |
483 | 482 | | members = [] |
| skipped 45 lines |
529 | 528 | | else: |
530 | 529 | | pass |
531 | 530 | | |
532 | | - | color_print_green(" ⬠Chat details", "") |
533 | | - | color_print_green(" â Title: ", str(entity.title)) |
534 | | - | color_print_green(" â ", wrapper_d.fill(group_description)) |
535 | | - | if translated_description != group_description: |
536 | | - | color_print_green(" â ", wrapper_td.fill(translated_description)) |
537 | | - | color_print_green( |
538 | | - | " â Total participants: ", str(total_participants) |
539 | | - | ) |
540 | | - | |
| 531 | + | setattr(entity, "group_description", group_description) |
| 532 | + | setattr(entity, "group_status", group_status) |
| 533 | + | setattr(entity, "group_username", group_username) |
| 534 | + | setattr(entity, "first_post", first_post) |
| 535 | + | setattr(entity, "group_url", group_url) |
| 536 | + | setattr(entity, "chat_type", chat_type) |
| 537 | + | setattr(entity, "translated_description", translated_description) |
| 538 | + | setattr(entity, "total_participants", total_participants) |
541 | 539 | | if chat_type != "Channel": |
542 | | - | color_print_green( |
543 | | - | " â Participants found: ", |
544 | | - | str(found_participants) |
545 | | - | + " (" |
546 | | - | + str(format(found_percentage, ".2f")) |
547 | | - | + "%)", |
548 | | - | ) |
| 540 | + | setattr(entity, "found_participants", found_participants) |
| 541 | + | setattr(entity, "found_percentage", found_percentage) |
| 542 | + | setattr(entity, "memberlist_filename", memberlist_filename) |
549 | 543 | | else: |
550 | | - | found_participants = "N/A" |
551 | | - | |
552 | | - | color_print_green(" â Username: ", str(group_username)) |
553 | | - | color_print_green(" â URL: ", str(group_url)) |
554 | | - | color_print_green(" â Chat type: ", str(chat_type)) |
555 | | - | color_print_green(" â Chat id: ", str(entity.id)) |
556 | | - | color_print_green(" â Access hash: ", str(entity.access_hash)) |
557 | | - | |
| 544 | + | setattr(entity, "found_participants", found_participants) |
| 545 | + | print_flag = "group_recap" |
558 | 546 | | if chat_type == "Channel": |
559 | | - | scam_status = str(entity.scam) |
560 | | - | color_print_green(" â Scam: ", str(scam_status)) |
561 | | - | else: |
562 | | - | scam_status = "N/A" |
| 547 | + | print_flag = "channel_recap" |
563 | 548 | | |
564 | | - | color_print_green(" â First post date: ", str(first_post)) |
565 | | - | |
566 | | - | if chat_type != "Channel": |
567 | | - | color_print_green( |
568 | | - | " â Memberlist saved to: ", memberlist_filename |
569 | | - | ) |
570 | | - | |
571 | | - | color_print_green( |
572 | | - | " â ", wrapper_r.fill(group_status) |
573 | | - | ) |
574 | | - | #print("\n") |
| 549 | + | print_shell(print_flag, entity) |
575 | 550 | | |
576 | 551 | | log.append( |
577 | 552 | | [ |
| skipped 8 lines |
586 | 561 | | chat_type, |
587 | 562 | | entity.id, |
588 | 563 | | entity.access_hash, |
589 | | - | scam_status, |
| 564 | + | str(entity.scam), |
590 | 565 | | date, |
591 | 566 | | mtime, |
592 | 567 | | group_status, |
| skipped 147 lines |
740 | 715 | | name="counts" |
741 | 716 | | ) |
742 | 717 | | |
743 | | - | top_forward_one = df01.iloc[0]["unique_values"] |
744 | | - | top_value_one = df01.iloc[0]["counts"] |
745 | | - | top_forward_two = df01.iloc[1]["unique_values"] |
746 | | - | top_value_two = df01.iloc[1]["counts"] |
747 | | - | top_forward_three = df01.iloc[2]["unique_values"] |
748 | | - | top_value_three = df01.iloc[2]["counts"] |
749 | | - | top_forward_four = df01.iloc[3]["unique_values"] |
750 | | - | top_value_four = df01.iloc[3]["counts"] |
751 | | - | top_forward_five = df01.iloc[4]["unique_values"] |
752 | | - | top_value_five = df01.iloc[4]["counts"] |
753 | | - | |
754 | | - | forward_one = ( |
755 | | - | str(top_forward_one) |
| 718 | + | report_forward = object() |
| 719 | + | setattr(report_forward, "forward_one", ( |
| 720 | + | str(df01.iloc[0]["unique_values"]) |
756 | 721 | | + ", " |
757 | | - | + str(top_value_one) |
| 722 | + | + str(df01.iloc[0]["counts"]) |
758 | 723 | | + " forwarded messages" |
759 | | - | ) |
760 | | - | forward_two = ( |
761 | | - | str(top_forward_two) |
| 724 | + | )) |
| 725 | + | setattr(report_forward, "forward_two", ( |
| 726 | + | str(df01.iloc[1]["unique_values"]) |
762 | 727 | | + ", " |
763 | | - | + str(top_value_two) |
| 728 | + | + str(df01.iloc[1]["counts"]) |
764 | 729 | | + " forwarded messages" |
765 | | - | ) |
766 | | - | forward_three = ( |
767 | | - | str(top_forward_three) |
| 730 | + | )) |
| 731 | + | setattr(report_forward, "forward_three", ( |
| 732 | + | str(df01.iloc[2]["unique_values"]) |
768 | 733 | | + ", " |
769 | | - | + str(top_value_three) |
| 734 | + | + str(df01.iloc[2]["counts"]) |
770 | 735 | | + " forwarded messages" |
771 | | - | ) |
772 | | - | forward_four = ( |
773 | | - | str(top_forward_four) |
| 736 | + | )) |
| 737 | + | setattr(report_forward, "forward_four", ( |
| 738 | + | str(df01.iloc[3]["unique_values"]) |
774 | 739 | | + ", " |
775 | | - | + str(top_value_four) |
| 740 | + | + str(df01.iloc[3]["counts"]) |
776 | 741 | | + " forwarded messages" |
777 | | - | ) |
778 | | - | forward_five = ( |
779 | | - | str(top_forward_five) |
| 742 | + | )) |
| 743 | + | setattr(report_forward, "forward_five", ( |
| 744 | + | str(df01.iloc[4]["unique_values"]) |
780 | 745 | | + ", " |
781 | | - | + str(top_value_five) |
| 746 | + | + str(df01.iloc[4]["counts"]) |
782 | 747 | | + " forwarded messages" |
783 | | - | ) |
| 748 | + | )) |
784 | 749 | | |
785 | 750 | | df02 = forwards_df.Source.unique() |
786 | | - | unique_forwards = len(df02) |
787 | | - | |
788 | | - | #print("\n") |
789 | | - | color_print_green(" [+] Forward scrape complete", "") |
790 | | - | color_print_green(" ⬠Statistics", "") |
791 | | - | color_print_green( |
792 | | - | " â Forwarded messages found: ", str(forward_count) |
793 | | - | ) |
794 | | - | color_print_green( |
795 | | - | " â Forwards from active public chats: ", |
796 | | - | str(forwards_found), |
797 | | - | ) |
798 | | - | color_print_green( |
799 | | - | " â Unique forward sources: ", str(unique_forwards) |
800 | | - | ) |
801 | | - | color_print_green( |
802 | | - | " â Top forward source 1: ", str(forward_one) |
803 | | - | ) |
804 | | - | color_print_green( |
805 | | - | " â Top forward source 2: ", str(forward_two) |
806 | | - | ) |
807 | | - | color_print_green( |
808 | | - | " â Top forward source 3: ", str(forward_three) |
809 | | - | ) |
810 | | - | color_print_green( |
811 | | - | " â Top forward source 4: ", str(forward_four) |
812 | | - | ) |
813 | | - | color_print_green( |
814 | | - | " â Top forward source 5: ", str(forward_five) |
815 | | - | ) |
816 | | - | color_print_green(" â Edgelist saved to: ", edgelist_file) |
817 | | - | #print("\n") |
| 751 | + | setattr(report_forward, "unique_forwards", len(df02)) |
| 752 | + | setattr(report_forward, "edgelist_file", len(df02)) |
| 753 | + | print_shell("forwarder_stat",report_forward) |
818 | 754 | | |
819 | 755 | | else: |
820 | 756 | | print( |
| skipped 8 lines |
829 | 765 | | if comp_check is True: |
830 | 766 | | |
831 | 767 | | messages = client.iter_messages(t) |
832 | | - | |
833 | 768 | | message_list = [] |
834 | 769 | | forwards_list = [] |
835 | | - | |
836 | 770 | | user_reaction_list = [] |
837 | | - | |
838 | 771 | | replies_list = [] |
839 | 772 | | user_replier_list = [] |
840 | | - | |
841 | 773 | | timecount = [] |
842 | | - | |
843 | 774 | | forward_count = 0 |
844 | 775 | | private_count = 0 |
845 | 776 | | |
| skipped 104 lines |
950 | 881 | | "Message ID", |
951 | 882 | | "Reply ID", |
952 | 883 | | "Display_name", |
953 | | - | "ID", |
| 884 | + | "User ID", |
954 | 885 | | "Message_text", |
955 | 886 | | "Original_language", |
956 | 887 | | "Translated_text", |
| skipped 301 lines |
1258 | 1189 | | pass |
1259 | 1190 | | |
1260 | 1191 | | messages_found = int(c_archive.To.count()) - 1 |
1261 | | - | message_frequency_count = {} |
1262 | | - | message_text = {} |
1263 | | - | word_count = {} |
1264 | | - | most_used_words = {} |
1265 | | - | most_used_words_filtered = {} |
1266 | | - | # message stats, top words |
1267 | | - | |
1268 | | - | if chat_type != "Channel": |
1269 | | - | pcount = c_archive.Display_name.count() |
| 1192 | + | report_obj = object() |
| 1193 | + | setattr(report_obj,"messages_found", messages_found) |
| 1194 | + | setattr(report_obj,"file_archive", file_archive) |
| 1195 | + | if chat_type == "Channel": |
| 1196 | + | print_shell("channel_stat", report_obj) |
| 1197 | + | else: |
1270 | 1198 | | pvalue_count = c_archive["Display_name"].value_counts() |
1271 | 1199 | | df03 = pvalue_count.rename_axis( |
1272 | 1200 | | "unique_values" |
1273 | 1201 | | ).reset_index(name="counts") |
1274 | 1202 | | |
1275 | | - | top_poster_one = str(df03.iloc[0]["unique_values"]) |
1276 | | - | top_pvalue_one = df03.iloc[0]["counts"] |
1277 | | - | top_poster_two = str(df03.iloc[1]["unique_values"]) |
1278 | | - | top_pvalue_two = df03.iloc[1]["counts"] |
1279 | | - | top_poster_three = str(df03.iloc[2]["unique_values"]) |
1280 | | - | top_pvalue_three = df03.iloc[2]["counts"] |
1281 | | - | top_poster_four = str(df03.iloc[3]["unique_values"]) |
1282 | | - | top_pvalue_four = df03.iloc[3]["counts"] |
1283 | | - | top_poster_five = str(df03.iloc[4]["unique_values"]) |
1284 | | - | top_pvalue_five = df03.iloc[4]["counts"] |
| 1203 | + | ''' |
| 1204 | + | message_frequency_count = {} |
| 1205 | + | message_text = {} |
| 1206 | + | word_count = {} |
| 1207 | + | most_used_words = {} |
| 1208 | + | most_used_words_filtered = {} |
| 1209 | + | ''' |
| 1210 | + | #message stats, top words |
1285 | 1211 | | |
1286 | | - | poster_one = ( |
1287 | | - | str(top_poster_one) |
| 1212 | + | setattr(report_obj, "poster_one", ( |
| 1213 | + | str(df03.iloc[0]["unique_values"]) |
1288 | 1214 | | + ", " |
1289 | | - | + str(top_pvalue_one) |
| 1215 | + | + str(df03.iloc[0]["counts"]) |
1290 | 1216 | | + " messages" |
1291 | | - | ) |
1292 | | - | poster_two = ( |
1293 | | - | str(top_poster_two) |
| 1217 | + | )) |
| 1218 | + | setattr(report_obj, "poster_two", ( |
| 1219 | + | str(df03.iloc[1]["unique_values"]) |
1294 | 1220 | | + ", " |
1295 | | - | + str(top_pvalue_two) |
| 1221 | + | + str(df03.iloc[2]["counts"]) |
1296 | 1222 | | + " messages" |
1297 | | - | ) |
1298 | | - | poster_three = ( |
1299 | | - | str(top_poster_three) |
| 1223 | + | )) |
| 1224 | + | setattr(report_obj, "poster_three", ( |
| 1225 | + | str(df03.iloc[2]["unique_values"]) |
1300 | 1226 | | + ", " |
1301 | | - | + str(top_pvalue_three) |
| 1227 | + | + str(df03.iloc[2]["counts"]) |
1302 | 1228 | | + " messages" |
1303 | | - | ) |
1304 | | - | poster_four = ( |
1305 | | - | str(top_poster_four) |
| 1229 | + | )) |
| 1230 | + | setattr(report_obj, "poster_four", ( |
| 1231 | + | str(df03.iloc[3]["unique_values"]) |
1306 | 1232 | | + ", " |
1307 | | - | + str(top_pvalue_four) |
| 1233 | + | + df03.iloc[3]["counts"] |
1308 | 1234 | | + " messages" |
1309 | | - | ) |
1310 | | - | poster_five = ( |
1311 | | - | str(top_poster_five) |
| 1235 | + | )) |
| 1236 | + | setattr(report_obj, "poster_five", ( |
| 1237 | + | str(df03.iloc[4]["unique_values"]) |
1312 | 1238 | | + ", " |
1313 | | - | + str(top_pvalue_five) |
| 1239 | + | + str(df03.iloc[4]["counts"]) |
1314 | 1240 | | + " messages" |
1315 | | - | ) |
| 1241 | + | )) |
1316 | 1242 | | |
1317 | 1243 | | df04 = c_archive.Display_name.unique() |
1318 | | - | plength = len(df03) |
1319 | 1244 | | unique_active = len(df04) |
| 1245 | + | setattr(report_obj, "unique_active", unique_active) |
| 1246 | + | print_shell("group_stat", report_obj) |
1320 | 1247 | | |
1321 | | - | elif reply_analysis is True: |
| 1248 | + | if reply_analysis is True: |
| 1249 | + | |
1322 | 1250 | | if len(replies_list) > 0: |
1323 | | - | replier_count = c_repliers["User id"].count() |
1324 | | - | replier_value_count = c_repliers["User id"].value_counts() |
| 1251 | + | replier_value_count = c_repliers["User ID"].value_counts() |
1325 | 1252 | | replier_df = replier_value_count.rename_axis( |
1326 | 1253 | | "unique_values" |
1327 | 1254 | | ).reset_index(name="counts") |
1328 | 1255 | | |
1329 | | - | top_replier_one = str(replier_df.iloc[0]["unique_values"]) |
1330 | | - | top_replier_value_one = replier_df.iloc[0]["counts"] |
1331 | | - | top_replier_two = str(replier_df.iloc[1]["unique_values"]) |
1332 | | - | top_replier_value_two = replier_df.iloc[1]["counts"] |
1333 | | - | top_replier_three = str(replier_df.iloc[2]["unique_values"]) |
1334 | | - | top_replier_value_three = replier_df.iloc[2]["counts"] |
1335 | | - | top_replier_four = str(replier_df.iloc[3]["unique_values"]) |
1336 | | - | top_replier_value_four = replier_df.iloc[3]["counts"] |
1337 | | - | top_replier_five = str(replier_df.iloc[4]["unique_values"]) |
1338 | | - | top_replier_value_five = replier_df.iloc[4]["counts"] |
1339 | | - | |
1340 | | - | replier_one = ( |
1341 | | - | str(top_replier_one) |
| 1256 | + | repliers = object() |
| 1257 | + | setattr(repliers, "replier_one", ( |
| 1258 | + | str(replier_df.iloc[0]["unique_values"]) |
1342 | 1259 | | + ", " |
1343 | | - | + str(top_replier_value_one) |
| 1260 | + | + str(replier_df.iloc[0]["counts"]) |
1344 | 1261 | | + " replies" |
1345 | | - | ) |
1346 | | - | replier_two = ( |
1347 | | - | str(top_replier_two) |
| 1262 | + | )) |
| 1263 | + | setattr(repliers, "replier_two", ( |
| 1264 | + | str(replier_df.iloc[1]["unique_values"]) |
1348 | 1265 | | + ", " |
1349 | | - | + str(top_replier_value_two) |
| 1266 | + | + str(replier_df.iloc[1]["counts"]) |
1350 | 1267 | | + " replies" |
1351 | | - | ) |
1352 | | - | replier_three = ( |
1353 | | - | str(top_replier_three) |
| 1268 | + | )) |
| 1269 | + | setattr(repliers, "replier_three", ( |
| 1270 | + | str(replier_df.iloc[2]["unique_values"]) |
1354 | 1271 | | + ", " |
1355 | | - | + str(top_replier_value_three) |
| 1272 | + | + str(replier_df.iloc[2]["counts"]) |
1356 | 1273 | | + " replies" |
1357 | | - | ) |
1358 | | - | replier_four = ( |
1359 | | - | str(top_replier_four) |
| 1274 | + | )) |
| 1275 | + | setattr(repliers, "replier_four", ( |
| 1276 | + | str(replier_df.iloc[3]["unique_values"]) |
1360 | 1277 | | + ", " |
1361 | | - | + str(top_replier_value_four) |
| 1278 | + | + str(replier_df.iloc[3]["counts"]) |
1362 | 1279 | | + " replies" |
1363 | | - | ) |
1364 | | - | replier_five = ( |
1365 | | - | str(top_replier_five) |
| 1280 | + | )) |
| 1281 | + | setattr(repliers, "replier_five", ( |
| 1282 | + | str(replier_df.iloc[3]["counts"]) |
1366 | 1283 | | + ", " |
1367 | | - | + str(top_replier_value_five) |
| 1284 | + | + str(replier_df.iloc[4]["counts"]) |
1368 | 1285 | | + " replies" |
1369 | | - | ) |
1370 | | - | |
1371 | | - | replier_count_df = c_repliers["User id"].unique() |
1372 | | - | replier_length = len(replier_df) |
| 1286 | + | )) |
| 1287 | + | replier_count_df = c_repliers["User ID"].unique() |
1373 | 1288 | | replier_unique = len(replier_count_df) |
1374 | | - | |
1375 | | - | else: |
1376 | | - | pass |
1377 | | - | |
1378 | | - | #print("\n") |
1379 | | - | color_print_green(" [+] Chat archive saved", "") |
1380 | | - | color_print_green(" ⬠Chat statistics", "") |
1381 | | - | color_print_green( |
1382 | | - | " â Number of messages found: ", str(messages_found) |
1383 | | - | ) |
1384 | | - | |
1385 | | - | if chat_type != "Channel": |
1386 | | - | color_print_green( |
1387 | | - | " â Top poster 1: ", str(poster_one) |
1388 | | - | ) |
1389 | | - | color_print_green( |
1390 | | - | " â Top poster 2: ", str(poster_two) |
1391 | | - | ) |
1392 | | - | color_print_green( |
1393 | | - | " â Top poster 3: ", str(poster_three) |
1394 | | - | ) |
1395 | | - | color_print_green( |
1396 | | - | " â Top poster 4: ", str(poster_four) |
1397 | | - | ) |
1398 | | - | color_print_green( |
1399 | | - | " â Top poster 5: ", str(poster_five) |
1400 | | - | ) |
1401 | | - | color_print_green( |
1402 | | - | " â Total unique posters: ", str(unique_active) |
1403 | | - | ) |
1404 | | - | |
1405 | | - | else: |
1406 | | - | pass |
1407 | | - | # timestamp analysis |
1408 | | - | # print(Fore.GREEN |
1409 | | - | # + ' â Number of messages: ' |
1410 | | - | # + Style.RESET_ALL |
1411 | | - | # + str(message_count)) |
1412 | | - | |
1413 | | - | color_print_green( |
1414 | | - | " â Archive saved to: ", str(file_archive) |
1415 | | - | ) |
1416 | | - | |
1417 | | - | if reply_analysis is True: |
1418 | | - | if len(replies_list) > 0: |
1419 | | - | middle_char = "â" |
1420 | | - | if user_replier_list == 0: |
1421 | | - | middle_char = "â" |
1422 | | - | |
1423 | | - | #print("\n") |
1424 | | - | color_print_green(" [+] Replies analysis ", "") |
1425 | | - | color_print_green(" ⬠Chat statistics", "") |
1426 | | - | color_print_green( |
1427 | | - | f" {middle_char} Archive of replies saved to: ", |
1428 | | - | str(reply_file_archive), |
1429 | | - | ) |
1430 | | - | if len(user_replier_list) > 0: |
1431 | | - | color_print_green( |
1432 | | - | " â Active members list who replied to messages, saved to: ", |
1433 | | - | str(reply_memberlist_filename), |
1434 | | - | ) |
1435 | | - | |
1436 | | - | color_print_green( |
1437 | | - | " â Top replier 1: ", str(replier_one) |
1438 | | - | ) |
1439 | | - | color_print_green( |
1440 | | - | " â Top replier 2: ", str(replier_two) |
1441 | | - | ) |
1442 | | - | color_print_green( |
1443 | | - | " â Top replier 3: ", str(replier_three) |
1444 | | - | ) |
1445 | | - | color_print_green( |
1446 | | - | " â Top replier 4: ", str(replier_four) |
1447 | | - | ) |
1448 | | - | color_print_green( |
1449 | | - | " â Top replier 5: ", str(replier_five) |
1450 | | - | ) |
1451 | | - | color_print_green( |
1452 | | - | " â Total unique repliers: ", str(replier_unique) |
1453 | | - | ) |
| 1289 | + | setattr(repliers,"user_replier_list_len", len(user_replier_list)) |
| 1290 | + | setattr(repliers, "reply_file_archive", str(reply_file_archive)) |
| 1291 | + | setattr(repliers, "reply_memberlist_filename", str(reply_memberlist_filename)) |
| 1292 | + | setattr(repliers,"replier_unique", str(replier_unique)) |
| 1293 | + | print_shell("reply_stat",repliers) |
1454 | 1294 | | |
1455 | 1295 | | if forwards_check is True: |
1456 | 1296 | | if forward_count >= 15: |
| skipped 2 lines |
1459 | 1299 | | c_f_stats = value_count.rename_axis( |
1460 | 1300 | | "unique_values" |
1461 | 1301 | | ).reset_index(name="counts") |
1462 | | - | |
1463 | | - | top_forward_one = c_f_stats.iloc[0]["unique_values"] |
1464 | | - | top_value_one = c_f_stats.iloc[0]["counts"] |
1465 | | - | top_forward_two = c_f_stats.iloc[1]["unique_values"] |
1466 | | - | top_value_two = c_f_stats.iloc[1]["counts"] |
1467 | | - | top_forward_three = c_f_stats.iloc[2][ |
1468 | | - | "unique_values" |
1469 | | - | ] |
1470 | | - | top_value_three = c_f_stats.iloc[2]["counts"] |
1471 | | - | top_forward_four = c_f_stats.iloc[3][ |
1472 | | - | "unique_values" |
1473 | | - | ] |
1474 | | - | top_value_four = c_f_stats.iloc[3]["counts"] |
1475 | | - | top_forward_five = c_f_stats.iloc[4][ |
1476 | | - | "unique_values" |
1477 | | - | ] |
1478 | | - | top_value_five = c_f_stats.iloc[4]["counts"] |
1479 | | - | |
1480 | | - | forward_one = ( |
1481 | | - | str(top_forward_one) |
1482 | | - | + ", " |
1483 | | - | + str(top_value_one) |
1484 | | - | + " forwarded messages" |
1485 | | - | ) |
1486 | | - | forward_two = ( |
1487 | | - | str(top_forward_two) |
1488 | | - | + ", " |
1489 | | - | + str(top_value_two) |
1490 | | - | + " forwarded messages" |
1491 | | - | ) |
1492 | | - | forward_three = ( |
1493 | | - | str(top_forward_three) |
1494 | | - | + ", " |
1495 | | - | + str(top_value_three) |
1496 | | - | + " forwarded messages" |
1497 | | - | ) |
1498 | | - | forward_four = ( |
1499 | | - | str(top_forward_four) |
1500 | | - | + ", " |
1501 | | - | + str(top_value_four) |
1502 | | - | + " forwarded messages" |
1503 | | - | ) |
1504 | | - | forward_five = ( |
1505 | | - | str(top_forward_five) |
1506 | | - | + ", " |
1507 | | - | + str(top_value_five) |
1508 | | - | + " forwarded messages" |
1509 | | - | ) |
1510 | | - | |
| 1302 | + | report_forward = object() |
| 1303 | + | setattr(report_forward, "forward_one", ( |
| 1304 | + | str(c_f_stats.iloc[0]["unique_values"]) |
| 1305 | + | + ", " |
| 1306 | + | + str(c_f_stats.iloc[0]["counts"]) |
| 1307 | + | + " forwarded messages" |
| 1308 | + | )) |
| 1309 | + | setattr(report_forward, "forward_two", ( |
| 1310 | + | str(c_f_stats.iloc[1]["unique_values"]) |
| 1311 | + | + ", " |
| 1312 | + | + str(c_f_stats.iloc[1]["counts"]) |
| 1313 | + | + " forwarded messages" |
| 1314 | + | )) |
| 1315 | + | setattr(report_forward, "forward_three", ( |
| 1316 | + | str(c_f_stats.iloc[2]["unique_values"]) |
| 1317 | + | + ", " |
| 1318 | + | + str(c_f_stats.iloc[2]["counts"]) |
| 1319 | + | + " forwarded messages" |
| 1320 | + | )) |
| 1321 | + | setattr(report_forward, "forward_four", ( |
| 1322 | + | str(c_f_stats.iloc[3]["unique_values"]) |
| 1323 | + | + ", " |
| 1324 | + | + str(c_f_stats.iloc[3]["counts"]) |
| 1325 | + | + " forwarded messages" |
| 1326 | + | )) |
| 1327 | + | setattr(report_forward, "forward_five", ( |
| 1328 | + | str(c_f_stats.iloc[4]["unique_values"]) |
| 1329 | + | + ", " |
| 1330 | + | + str(c_f_stats.iloc[4]["counts"]) |
| 1331 | + | + " forwarded messages" |
| 1332 | + | )) |
1511 | 1333 | | c_f_unique = c_forwards.Source.unique() |
1512 | | - | unique_forwards = len(c_f_unique) |
1513 | | - | |
1514 | | - | #print("\n") |
1515 | | - | color_print_green(" [+] Edgelist saved", "") |
1516 | | - | color_print_green( |
1517 | | - | " ⬠Forwarded message statistics", "" |
1518 | | - | ) |
1519 | | - | color_print_green( |
1520 | | - | " â Forwarded messages found: ", |
1521 | | - | str(forward_count), |
1522 | | - | ) |
1523 | | - | color_print_green( |
1524 | | - | " â Forwards from active public chats: ", |
1525 | | - | str(forwards_found), |
1526 | | - | ) |
1527 | | - | color_print_green( |
1528 | | - | " â Forwards from private (or now private) chats: ", |
1529 | | - | str(private_count), |
1530 | | - | ) |
1531 | | - | color_print_green( |
1532 | | - | " â Unique forward sources: ", |
1533 | | - | str(unique_forwards), |
1534 | | - | ) |
1535 | | - | color_print_green( |
1536 | | - | " â Top forward source 1: ", str(forward_one) |
1537 | | - | ) |
1538 | | - | color_print_green( |
1539 | | - | " â Top forward source 2: ", str(forward_two) |
1540 | | - | ) |
1541 | | - | color_print_green( |
1542 | | - | " â Top forward source 3: ", |
1543 | | - | str(forward_three), |
1544 | | - | ) |
1545 | | - | color_print_green( |
1546 | | - | " â Top forward source 4: ", str(forward_four) |
1547 | | - | ) |
1548 | | - | color_print_green( |
1549 | | - | " â Top forward source 5: ", str(forward_five) |
1550 | | - | ) |
1551 | | - | color_print_green( |
1552 | | - | " â Edgelist saved to: ", edgelist_file |
1553 | | - | ) |
1554 | | - | #print("\n") |
1555 | | - | |
| 1334 | + | setattr(report_forward, "unique_forwards", len(c_f_unique)) |
| 1335 | + | setattr(report_forward, "edgelist_file", len(df02)) |
| 1336 | + | setattr(report_forward, "private_count", private_count) |
| 1337 | + | print_shell("forwarder_stat", report_forward) |
1556 | 1338 | | else: |
1557 | 1339 | | #print("\n") |
1558 | 1340 | | color_print_green( |
| skipped 37 lines |
1596 | 1378 | | user_restrictions = str(ios_restriction) |
1597 | 1379 | | else: |
1598 | 1380 | | user_restrictions = "None" |
1599 | | - | |
1600 | | - | color_print_green(" [+] ", "User details for " + t) |
1601 | | - | color_print_green(" â Username: ", str(my_user.username)) |
1602 | | - | color_print_green(" â Name: ", str(user_full_name)) |
1603 | | - | color_print_green(" â Verification: ", str(my_user.verified)) |
1604 | | - | color_print_green(" â Photo ID: ", str(user_photo)) |
1605 | | - | color_print_green(" â Phone number: ", str(my_user.phone)) |
1606 | | - | color_print_green( |
1607 | | - | " â Access hash: ", str(my_user.access_hash) |
1608 | | - | ) |
1609 | | - | color_print_green(" â Language: ", str(my_user.lang_code)) |
1610 | | - | color_print_green(" â Bot: ", str(my_user.bot)) |
1611 | | - | color_print_green(" â Scam: ", str(my_user.scam)) |
1612 | | - | color_print_green(" â Restrictions: ", str(user_restrictions)) |
| 1381 | + | setattr(my_user, "user_restrictions", str(user_restrictions)) |
| 1382 | + | setattr(my_user, "user_full_name", str(user_full_name)) |
| 1383 | + | setattr(my_user, "user_photo", str(user_photo)) |
| 1384 | + | setattr(my_user, "target", t) |
| 1385 | + | print_shell("user", my_user) |
1613 | 1386 | | |
1614 | 1387 | | except ValueError: |
1615 | 1388 | | pass |
| skipped 70 lines |
1686 | 1459 | | except: |
1687 | 1460 | | pass |
1688 | 1461 | | |
1689 | | - | d_500 = 0 |
1690 | | - | d_1000 = 0 |
1691 | | - | d_2000 = 0 |
1692 | | - | d_3000 = 0 |
| 1462 | + | distance_obj = object() |
| 1463 | + | setattr(distance_obj, "d500", 0) |
| 1464 | + | setattr(distance_obj, "d1000", 0) |
| 1465 | + | setattr(distance_obj, "d2000", 0) |
| 1466 | + | setattr(distance_obj, "d3000", 0) |
1693 | 1467 | | |
1694 | 1468 | | for account, distance in user_df.itertuples(index=False): |
1695 | 1469 | | account = int(account) |
| skipped 3 lines |
1699 | 1473 | | distance = int(distance) |
1700 | 1474 | | |
1701 | 1475 | | if distance == 500: |
1702 | | - | d_500 += 1 |
| 1476 | + | distance_obj.d500 += 1 |
1703 | 1477 | | elif distance == 1000: |
1704 | | - | d_1000 += 1 |
| 1478 | + | distance_obj.d1000 += 1 |
1705 | 1479 | | elif distance == 2000: |
1706 | | - | d_2000 += 1 |
| 1480 | + | distance_obj.d2000 += 1 |
1707 | 1481 | | elif distance == 3000: |
1708 | | - | d_3000 += 1 |
| 1482 | + | distance_obj.d3000 += 1 |
1709 | 1483 | | |
1710 | 1484 | | with open( |
1711 | 1485 | | save_file, "w+", encoding="utf-8" |
1712 | | - | ) as f: |
| 1486 | + | ) as f: # could one day append, including access time to differentiate |
1713 | 1487 | | user_df.to_csv(f, sep=";", index=False) |
1714 | 1488 | | |
| 1489 | + | setattr(distance_obj, "save_file", save_file) |
| 1490 | + | setattr(distance_obj, "total", total) |
1715 | 1491 | | total = len(locations_list) |
1716 | | - | |
1717 | | - | color_print_green(" [+] Users located", "") |
1718 | | - | color_print_green(" â Users within 500m: ", str(d_500)) |
1719 | | - | color_print_green(" â Users within 1000m: ", str(d_1000)) |
1720 | | - | color_print_green(" â Users within 2000m: ", str(d_2000)) |
1721 | | - | color_print_green(" â Users within 3000m: ", str(d_3000)) |
1722 | | - | color_print_green(" â Total users found: ", str(total)) |
1723 | | - | color_print_green(" â Location list saved to: ", save_file) |
1724 | | - | |
1725 | | - | user_df.iloc[0:0] |
| 1492 | + | print_shell("location_report",distance_obj) |
| 1493 | + | # can also do the same for channels with similar output file to users |
| 1494 | + | # may one day add trilateration to find users closest to exact point |
1726 | 1495 | | |
1727 | 1496 | | with client: |
1728 | 1497 | | client.loop.run_until_complete(main()) |
| skipped 4 lines |