-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
40 lines (30 loc) · 1.43 KB
/
main.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
from random import choice
import aiohttp
import asyncio
class advertiser:
def __init__(self, authsDirectory: str, messageDirectory: str, channelsDirectory: str, delay: int=300) -> str:
self.authsDirectory = authsDirectory
self.messageDirectory = messageDirectory
self.channelsDirectory = channelsDirectory
self.delay = delay
self.message = open(messageDirectory).read()
async def sendMessage(self, channel, auth):
data = {
"content" : self.message
}
headers = {
"Authorization" : auth
}
async with aiohttp.ClientSession() as session:
async with session.post(f"https://discord.com/api/v9/channels/{channel}/messages", data=data, headers=headers) as response:
return response.status
async def main(self):
channels = [channel for channel in open(self.channelsDirectory).read().splitlines()]
account = choice([auth for auth in open(self.authsDirectory).read().splitlines()])
funcs = [self.sendMessage(channel, account) for channel in channels]
responses = await asyncio.gather(*funcs)
print(f"Sent messages with responses: {responses}")
await asyncio.sleep(self.delay)
a = advertiser(authsDirectory="auths.txt", messageDirectory="message.txt", channelsDirectory="channels.txt")
while True:
asyncio.run(a.main())