I have this script import json Load the targets.json with open('targets.json', 'r') as…
- User
I have this script
import json
Load the targets.json
with open('targets.json', 'r') as f: targets = json.load(f)
Correct log file path
log_file = 'bot_log.log' # Your log file path sent_users = set() failed_users = set()
Parse the log file for sent and failed users
with open(log_file, 'r') as log: for line in log: if "INFO - Sent message to" in line: # Extract the username from the log user = line.split("Sent message to")[1].split("using")[0].strip() sent_users.add(user) elif ("ERROR - Failed to send message to" in line and ("Nobody is using this username" in line or "No user has" in line)): # Extract the failed username from the log user = line.split("Failed to send message to")[1].split("'")[1].strip() failed_users.add(user)
Step 1: Confirm removal of users who have successfully received messages
if not sent_users: print("No successfully sent messages found in the log file.") else: print(f"We found the following users who successfully received messages: {', '.join(sent_users)}") confirm_sent = input("Should we remove these users from targets.json? (yes/no): ") if confirm_sent.lower() == "yes": updated_targets = [] for user in targets: if user['username'].strip() not in {u.strip() for u in sent_users}: updated_targets.append(user) else: print(f"Removing '{user['username']}' from targets.json.")
# Save the updated targets.json with open('targets.json', 'w') as f: json.dump(updated_targets, f, indent=4) # Re-open and verify if 'Id_sammie' was actually removed with open('targets.json', 'r') as f: targets_after = json.load(f) if 'Id_sammie' in [user['username'] for user in targets_after]: print("'Id_sammie' was not removed from targets.json!") else: print("'Id_sammie' was successfully removed.") print("Successfully sent users have been removed from targets.json.") else: print("No changes made to targets.json for successfully sent users.")Step 2: Confirm removal of failed users
if not failed_users: print("No failed usernames were found in the log file.") else: print(f"We found the following usernames that failed due to username not existing: {', '.join(failed_users)}") confirm_failed = input("Should we remove these failed users from targets.json? (yes/no): ") if confirm_failed.lower() == "yes": updated_targets = [] for user in targets: if user['username'].strip() not in {u.strip() for u in failed_users}: updated_targets.append(user) else: print(f"Removing '{user['username']}' from targets.json.")
# Save the updated targets.json with open('targets.json', 'w') as f: json.dump(updated_targets, f, indent=4) print("Failed users have been removed from targets.json.") else: print("No changes made to targets.json for failed users.")it gives this output
(DM) sypherwork@sypherwork3080:~/Documents/DM_BOT_TELEGRAM$ python remove_sent_from_targets_json.py We found the following users who successfully received messages: blistersTrillet, SangMata_BOT, Slick_Criz, seantheone, karmavault, siren_studios, GergoParasite, ner09x3, DannyMykonos, Iggzyo, JSReddit, danielortega2025, FEAR_OF_AVERAGE, easymoneysniperr0, OFMEmmaaa, kyleeOFM, QatarEmperor, berniexs, kurrrby, eazilite, bigxprophets, Marek_Del, Johan213566, theofmegod, Christine56Hopkinsx, Saphfira, J05ng, FansBoosting, Ramalofm, jack_mjj, maddickson, quakecr, snt106, gunstreak, joonniaa, DimesMgmt, dimitrisvlch, ijack350, MartinStoi, tommy1of1, baldprisoner, brianbees, damienofm, drmayer85, FarmedReddit001, eminenceassistant, james_brockston, Id_sammie, jie2xTU, nstrok, asssblon, Andrewhogu, ValOFM, chatwaveAD2, CHidalgo98, nektheshark, tiggolbitties, damianmueler, HYCJT, Michael_260, madi294, bradhustlezz, volvo253, sherwolfhowlmes, mrpopad2, stxngy, Josephbdollar, kusheeb, niggerelon, MissRose_bot, den1sovv, Ceril_demoor, comandanteofm, happysads, synthscript, proxyad1, Gtboost1, Datdudemjc, fmanr_1, theSaito, Noems_s, ATLRE8, ShaneCarrollFrancisBot, ITSCritical, sixxfiguremanagement, deaofm, auxcol, eternalmatt, Blessing86, bmatt777, devsKayel, assyanaa, krsaaa Should we remove these users from targets.json? (yes/no): yes Removing 'Id_sammie' from targets.json. 'Id_sammie' was successfully removed. Successfully sent users have been removed from targets.json. We found the following usernames that failed due to username not existing: ChattingJobsToday, trafficadds, santiagoengagement, vaynehiring, TinderOF, ksfrts, Grekazo, PIMP_MNGMNT, karolunfazed, aggressivedaa, Astna_Ortega, neocat0x, MNSERVICES1, Unknown, RonnyBns Should we remove these failed users from targets.json? (yes/no): yes Failed users have been removed from targets.json.
- Assistant