-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
130 lines (100 loc) · 7.5 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
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
import discum
import time
import os
from pystyle import *
import json
import threading
#Open config file
def load_config():
base_dir = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(base_dir, "config.json")
with open(config_path, "r", encoding="utf-8") as file: # Spécifie l'encodage
return json.load(file)
# Mettre un titre à la console
System.Title("Automated Advertising Bot - By IlyMoon")
#Showing initializing before starting the actual script
print("Initializing script...")
print("Starting in a second, please wait.")
# Vars needed in order to make the user experience a lot better below
command = "nothing"
username=os.getlogin()
commandline=f"{username}@windows:~$ "
def selectchoice():
global command
command = Write.Input(f"{commandline} ", Colors.green, interval=0.00005)
def cc():
System.Clear()
#ASCII Art
logo="""
░█████╗░██╗░░░██╗████████╗░█████╗░███╗░░░███╗░█████╗░████████╗███████╗██████╗░
██╔══██╗██║░░░██║╚══██╔══╝██╔══██╗████╗░████║██╔══██╗╚══██╔══╝██╔════╝██╔══██╗
███████║██║░░░██║░░░██║░░░██║░░██║██╔████╔██║███████║░░░██║░░░█████╗░░██║░░██║
██╔══██║██║░░░██║░░░██║░░░██║░░██║██║╚██╔╝██║██╔══██║░░░██║░░░██╔══╝░░██║░░██║
██║░░██║╚██████╔╝░░░██║░░░╚█████╔╝██║░╚═╝░██║██║░░██║░░░██║░░░███████╗██████╔╝
╚═╝░░╚═╝░╚═════╝░░░░╚═╝░░░░╚════╝░╚═╝░░░░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═════╝░
░█████╗░██████╗░██╗░░░██╗███████╗██████╗░████████╗██╗░██████╗██╗███╗░░██╗░██████╗░ ██████╗░░█████╗░████████╗
██╔══██╗██╔══██╗██║░░░██║██╔════╝██╔══██╗╚══██╔══╝██║██╔════╝██║████╗░██║██╔════╝░ ██╔══██╗██╔══██╗╚══██╔══╝
███████║██║░░██║╚██╗░██╔╝█████╗░░██████╔╝░░░██║░░░██║╚█████╗░██║██╔██╗██║██║░░██╗░ ██████╦╝██║░░██║░░░██║░░░
██╔══██║██║░░██║░╚████╔╝░██╔══╝░░██╔══██╗░░░██║░░░██║░╚═══██╗██║██║╚████║██║░░╚██╗ ██╔══██╗██║░░██║░░░██║░░░
██║░░██║██████╔╝░░╚██╔╝░░███████╗██║░░██║░░░██║░░░██║██████╔╝██║██║░╚███║╚██████╔╝ ██████╦╝╚█████╔╝░░░██║░░░
╚═╝░░╚═╝╚═════╝░░░░╚═╝░░░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝╚═════╝░╚═╝╚═╝░░╚══╝░╚═════╝░ ╚═════╝░░╚════╝░░░░╚═╝░░░
by IlyMoon / https://github.com/IlyMooon
"""
# Menu de démarrage
def startmenu():
cc()
Write.Print(f"{logo}", Colors.green, interval=0.000005)
Write.Print("\n-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-", Colors.green, interval=0.00005)
print(Colors.green + "\nuse help command to get help about")
#Start menu launch
startmenu()
#Load config in the right var
config = load_config()
while True:
selectchoice()
# Vérifier le choix de l'utilisateur
if command == "start":
cc()
Write.Print("Bot starting with actual config file...\n", Colors.green, interval=0.00005)
# L'utilisateur a choisi d'exécuter le script
token = config["token"]
channel_ids = config["channel_ids"]
message = config["message"]
bot = discum.Client(token=token, log=False)
# Fonction pour envoyer les messages
def send_ads():
for channel_id in channel_ids:
try:
bot.sendMessage(channel_id, message)
Write.Print(f"Ad sent in channel : {channel_id}\n", Colors.light_green, interval=0.00005)
except Exception as e:
Write.Print(f"Error while sending ad in the channel {channel_id}: {e}\n", Colors.red, interval=0.00005)
time.sleep(3) # Wait time before sending next ad
Write.Print("All advertisements were sent, you can close the program.\nLaunching menu in 5 seconds.", Colors.light_green, interval=0.005)
time.sleep(5) # sleeping 5 secondes before returning to menu
# Lancer le bot dans un thread
threading.Thread(target=bot.gateway.run, kwargs={"auto_reconnect": True}).start()
# Attendre un moment pour permettre à la connexion de s'établir
time.sleep(3)
System.Title("Advertising in Progress - By IlyMoon")
send_ads()
System.Title("Automated Advertising Bot - By IlyMoon")
cc()
startmenu()
Write.Print("All ads were sent 5 seconds ago, thanks for using this script !", Colors.light_green, interval=0.00005)
elif command == "help":
Write.Print(f"Here are all the commands available :\nstart - Run the bot using actual configuration\neditconfig - launch notepad to edit the config file\nhelp - open the commands help\nexit - close the program\n", Colors.green, interval=0.00005)
elif command == "editconfig":
config_file_path = "config.json"
# Open the config json
os.system(f"notepad {config_file_path}")
Write.Print("Press enter when you have edited the config file and saved it.\n", Colors.green, interval=0.00005)
Write.Input("Please note that if the config file is wrongly edited, the bot won't work !\n", Colors.red, interval=0.00005)
Write.Print("Updating config file...\n", Colors.green, interval=0.00005)
config = load_config()
Write.Print("Updated !\n", Colors.light_green, interval=0.00005)
time.sleep(2)
elif command == "exit":
exit()
else:
Write.Print(f"{command} isn't recognized as an internal command, please check the spelling.\n", Colors.red, interval=0.00005)