-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddmd.py
146 lines (129 loc) · 4.94 KB
/
ddmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import pyautogui #macro control library
import sys
import time
from tqdm import tqdm #progress bar library
print('')
print('DDMD is a python macro that automates mass deletion of Discord messages.')
print('')
#check user input for valid message deletion quota
while True:
iterations = input('Number of messages to delete: ')
if len(iterations) < 1:
iterations = 100
try:
iterations = int(iterations) #checks user input for an integer
except:
print('Invalid input:', iterations, 'is not a number')
continue
break
#check user input for valid message edit mode setting
while True:
editMode = input('Edit messages before deletion? y/n: ')
if len(editMode) < 1:
editMode = 'n'
elif editMode not in ('y', 'yes', 'Yes', 'n', 'no', 'No'):
print('Invalid input: Please enter y or n')
continue
if editMode not in ('y', 'yes', 'Yes'):
modeCorrect = 1
print('editMode off')
else:
modeCorrect = 0
print('editMode on')
break
#default screen coordinates
xa = 220 #Friends tab x default coordinate
ya = 120 #Friends tab y default coordinate
xb = 220 #conversation tab x default coordinate
yb = 330 #conversation tab y default coordinate
print('')
print('Screen', pyautogui.size()) #print users screen resolution
print('Default screen coordinates', (xa, xb),'and', (xb, yb))
#checks user input for valid custom coordinate mode setting
while True:
ccMode = input('Custom screen coordinates? (recommended for first time users) y/n: ')
if len(ccMode) < 1:
ccMode = 'y'
elif ccMode not in ('y', 'yes', 'Yes', 'n', 'no', 'No'):
print('Invalid input: Please enter y or n')
continue
elif ccMode in ('n', 'no', 'No'):
print('ccMode off')
break
if ccMode == 'y':
print('ccMode on')
xa = None
ya = None
xb = None
yb = None
counter = 0
print('')
print('Position cursor over the "Friends" tab in Discord and then press Ctrl-C.')
print('')
while xa == None or ya == None or xb == None or yb == None:
try:
x, y = pyautogui.position()
positionStr = '(' + str(x) + ', ' + str(y) + ')'
print(positionStr, end='')
print('\b' * len(positionStr), end='')
except KeyboardInterrupt:
counter = counter + 1
if counter == 1:
print('\b' * len(positionStr), end='')
print('"Friends" tab coordinates are:', positionStr)
xa = x
ya = y
print('')
print('Next, position the cursor over the desired conversation and press Ctrl-C.')
if counter == 2:
print('\b' * len(positionStr), end='')
print('Conversation tab coordinates are:', positionStr)
print('')
xb = x
yb = y
break
#logic gate for when edit mode is turned on
gateOpen = True
gateClosed = False
t = gateOpen ^ gateClosed
gateStatus = gateOpen
count = 0
#pyautogui.click(1, 1) #moves mouse to upper left hand corner and selects app
#message deletion loop
while True:
beginDeletion = input('Start deleting messages? y/n: ')
if len(beginDeletion) < 1:
pass
elif beginDeletion not in ('y', 'yes', 'Yes', 'n', 'no', 'No'):
print('Invalid input: Please enter y or n')
continue
elif beginDeletion in ('n', 'no', 'No'):
print('Exiting')
exit()
break
try:
print('To exit program, select the command line window and press Ctrl-C.')
for i in tqdm (range (iterations), desc="Deleting", ascii=False):
pyautogui.click(xa, ya) #moves mouse to Friends tab and clicks right
pyautogui.click(xb, yb) #moves mouse to conversation tab and clicks right
while count < (2 - modeCorrect):
count += 1
pyautogui.typewrite(['up']) #up arrow key
pyautogui.hotkey('ctrlleft', 'a') #left ctrl+a key combination
time.sleep(1) #sleep used to prevent execution of commands faster than discord will accept them
if editMode in ('y', 'yes', 'Yes'):
if gateStatus == True:
pyautogui.typewrite(['backspace', 'x', 'enter']) #backspace key then x key then enter key
gateStatus ^= t #toggles the logic gate
time.sleep(1)
continue
else:
gateStatus ^= t
pyautogui.typewrite(['backspace', 'enter']) #backspace key then enter key
pyautogui.typewrite(['enter']) #enter key (seperate commant because it executes too fast for discord)
time.sleep(1)
count = 0
print('Finished:', iterations, 'messages deleted')
except KeyboardInterrupt:
print('Exiting')
exit()