This repository has been archived by the owner on May 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
52 lines (44 loc) · 1.68 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
41
42
43
44
45
46
47
48
49
50
51
52
import json
import os
import discord
from termcolor import colored
print("Starting")
with open("config.json", "r") as f:
config_file = json.load(f)
with open("ignored_channels.json", "r") as f:
ignored_channels_file = json.load(f)
ignored_channels_list = ignored_channels_file["IGNORED_CHANNELS"]
TOKEN_AUTH = config_file["USER_TOKEN"]
USER_ID = config_file["USER_ID"]
FOLDER_PATH = config_file["FOLDER_PATH"]
user_list = []
for root, dirs, files in os.walk(FOLDER_PATH):
for main_file in files:
if main_file.startswith("channel.json"):
with open(os.path.join(root, main_file), "r") as f:
main_data = json.load(f)
if main_data["type"] == 1:
target_user = main_data["recipients"]
target_user.remove(f"{USER_ID}")
user_list.append(int(target_user[0]))
client = discord.Client()
ignored_channels_list = list(map(int, ignored_channels_list))
@client.event
async def on_ready():
for user in user_list:
if user in ignored_channels_list:
print(colored(f"Ignoring user {user}", "white"))
continue
fetched_user = await client.fetch_user(user)
await fetched_user.create_dm()
print(f'Created DMS with {user}')
# Uncomment the lines below if you wish to add a user to ignore list after opening its DMs
"""
ignored_channels_list.append(user)
with open("ignored_channels.json", "w") as f:
json.dump(ignored_channels_file, f)
print(colored(f'Added {user} to ignore list', 'yellow'))
"""
print(colored("All dms have been opened", "green"))
await client.close()
client.run(f"{TOKEN_AUTH}")