@@ -84,6 +84,62 @@ def load_json_file(file_path):
8484 return {}
8585
8686
87+ def update_account_data (account_data , updated_username_or_status , expected_username ):
88+ """Update account data based on the current username status."""
89+ changes_made = False
90+
91+ # Check if account is deleted
92+ if updated_username_or_status and updated_username_or_status .startswith ("deleted_user" ):
93+ # Update username if it changed
94+ if account_data ["USERNAME" ] != updated_username_or_status :
95+ account_data ["USERNAME" ] = updated_username_or_status
96+ changes_made = True
97+ log_message (f"Updated username to: { updated_username_or_status } " )
98+
99+ # Update account status to DELETED
100+ if account_data ["ACCOUNT_STATUS" ] != "DELETED" :
101+ account_data ["ACCOUNT_STATUS" ] = "DELETED"
102+ changes_made = True
103+ log_message ("Updated ACCOUNT_STATUS to: DELETED" )
104+
105+ # Update account type to Deleted Accounts
106+ if account_data ["ACCOUNT_TYPE" ] != "Deleted Accounts" :
107+ account_data ["ACCOUNT_TYPE" ] = "Deleted Accounts"
108+ changes_made = True
109+ log_message ("Updated ACCOUNT_TYPE to: Deleted Accounts" )
110+
111+ # Check if account exists but username changed
112+ elif updated_username_or_status and updated_username_or_status != expected_username :
113+ # Update username
114+ account_data ["USERNAME" ] = updated_username_or_status
115+ changes_made = True
116+ log_message (f"Updated username from { expected_username } to: { updated_username_or_status } " )
117+
118+ # Update account status to OPERATIONAL (since it's not deleted)
119+ if account_data ["ACCOUNT_STATUS" ] != "OPERATIONAL" :
120+ account_data ["ACCOUNT_STATUS" ] = "OPERATIONAL"
121+ changes_made = True
122+ log_message ("Updated ACCOUNT_STATUS to: OPERATIONAL" )
123+
124+ # Update account type back to original type if it was previously marked as deleted
125+ if account_data ["ACCOUNT_TYPE" ] == "Deleted Accounts" :
126+ account_data ["ACCOUNT_TYPE" ] = "Burner Accounts" # Default assumption
127+ changes_made = True
128+ log_message ("Updated ACCOUNT_TYPE to: Burner Accounts" )
129+
130+ # Check if account was previously marked as deleted but is now operational
131+ elif not updated_username_or_status and account_data ["USERNAME" ].startswith ("deleted_user" ):
132+ # This means the account exists now (API returned 200) but was previously deleted
133+ # This is an edge case where a deleted account might have been restored
134+ log_message (f"Account { account_data ['DISCORD_ID' ]} appears to be restored from deleted state" )
135+
136+ # Update LAST_CHECK timestamp
137+ account_data ["LAST_CHECK" ] = datetime .now ().isoformat ()
138+ changes_made = True
139+
140+ return changes_made
141+
142+
87143def main ():
88144 file_path = "../Database-Files/Edit-Database/Compromised-Discord-Accounts.json"
89145
@@ -121,13 +177,22 @@ def main():
121177 start_index = 0
122178
123179 accounts_updated = 0
180+ accounts_skipped = 0
124181 for index , (account_number , account_data ) in enumerate (list (data .items ())):
125182 if index < start_index :
126183 continue # Skip cases before the chosen start point
127184
128185 discord_id = account_data ["DISCORD_ID" ]
129186 expected_username = account_data ["USERNAME" ]
130187
188+ # Skip accounts that are already marked as deleted
189+ if expected_username .startswith ("deleted_user" ):
190+ log_message (
191+ f"Skipping account { account_number } : Already deleted ({ expected_username } )"
192+ )
193+ accounts_skipped += 1
194+ continue
195+
131196 log_message (
132197 f"Checking account { account_number } : { discord_id } ({ expected_username } )"
133198 )
@@ -136,18 +201,13 @@ def main():
136201 discord_id , expected_username
137202 )
138203
139- # Only update if the username has changed
140- if (
141- updated_username_or_status
142- and updated_username_or_status != expected_username
143- ):
144- account_data ["USERNAME" ] = updated_username_or_status
145- accounts_updated += 1
146-
147- # Always update the deleted status regardless of previous status
148- if updated_username_or_status .startswith ("deleted_user" ):
149- account_data ["ACCOUNT_STATUS" ] = "DELETED"
204+ # Update account data based on the current status
205+ changes_made = update_account_data (
206+ account_data , updated_username_or_status , expected_username
207+ )
150208
209+ if changes_made :
210+ accounts_updated += 1
151211 # Live update the file after each change
152212 update_json_file (file_path , data )
153213 log_message (f"Live updated file for account { account_number } " )
@@ -157,11 +217,12 @@ def main():
157217 # Sleep to respect the rate limit
158218 time .sleep (60 / DISCORD_USERS_RATE_LIMIT )
159219
160- log_message (f"Scan complete. Updated { accounts_updated } accounts." )
220+ log_message (
221+ f"Scan complete. Updated { accounts_updated } accounts. Skipped { accounts_skipped } already deleted accounts." )
161222
162223 except Exception as e :
163224 log_message (f"An error occurred: { e } " )
164225
165226
166227if __name__ == "__main__" :
167- main ()
228+ main ()
0 commit comments