-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spammer
executable file
·66 lines (57 loc) · 1.93 KB
/
Spammer
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
#!/bin/python3
from os.path import exists
from configparser import ConfigParser
from requests import post
from random import randint
from time import sleep
def main():
config = ConfigParser()
# Create file with default options if it doesn't exists
if not exists("config.ini"):
config["General"] = {
"Token": "None",
"Delay": 1.0
}
with open("config.ini", "w") as config_file:
config.write(config_file)
# If the file exists, read and parse it
else:
config.read_file(open("config.ini", "r"))
if not config["General"]["Token"] or config["General"]["Token"] == "None":
raise BaseException("Missing 'Token' property in config file")
# If message file doesn't exists create it with a default message
if not exists("message.txt"):
with open("message.txt", "w") as message_file:
message_file.write("Example message")
# Read the message file
message = ''
with open("message.txt", "r") as message_file:
message = '\n'.join(message_file.readlines())[:2000]
channel_id = input("Enter channel id: ")
if config["General"]["Delay"]:
delay = float(config["General"]["Delay"])
else:
delay = 0.5
# Loop that keeps sending the message
while True:
res = post(f"https://discord.com/api/v9/channels/{channel_id}/messages",
headers={
"Authorization": config["General"]["Token"]
},
json={
"content": message,
"nonce": ''.join([str(randint(0, 9)) for _ in range(18)]),
"tts": "false"
})
# print(res.status_code)
if res.status_code == 200:
print("Message sent")
else:
print("Message wasn't sent")
sleep(delay)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print()
exit(0)