This repository was archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEasyBotPluginMaker.cpp
172 lines (167 loc) · 6.55 KB
/
EasyBotPluginMaker.cpp
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include <iostream>
#include <string>
#include <list>
using namespace std;
class pythonlike {
public:
string input() {
string return_data;
getline(cin, return_data);
return return_data;
}
void print(string input_data) {
cout << input_data << endl;
}
};
class python {
private:
int tabs = 2;
string tab_me() {
string output_data;
for (int i = 0; i < tabs; i++) {
output_data = output_data + "\t";
};
return output_data;
};
public:
string output(string input_data) {
return tab_me() + "await ctx.send(f'" + input_data + "')\n";
};
string input(string variable_name, bool isfloat) {
if (isfloat) {
return tab_me() + "msg = await self.bot.wait_for('message', timeout = 10)\n" + tab_me() + variable_name + " = float(msg.content)\n";
}
else {
return tab_me() + "msg = await self.bot.wait_for('message', timeout = 10)\n" + tab_me() + variable_name + " = msg.content\n";
}
};
string loop(string repeats) {
string output = tab_me() + "for i in range(0, " + repeats + "):\n";
tabs++;
return output;
};
string leave_loop() {
string output = tab_me() + "break\n";
tabs--;
return output;
}
string math(string operation, string var_name) {
return tab_me() + var_name + "=" + operation + "\n";
};
string newvar(string var_name, bool isfloat, string value) {
if (isfloat) {
return tab_me() + var_name + "=" + value + "\n";
}
else {
return tab_me() + var_name + "=f'" + value + "'\n";
}
}
string custompython(string command) {
return tab_me() + command + "\n";
}
string end(string category) {
return "def setup(bot):\n\
\tbot.add_cog(" + category + "(bot))";
}
};
int main()
{
pythonlike pylike;
pylike.print("-----Welcome to easybot.py cogs maker!-----");
string filename;
pylike.print("What is the category the command will be placed in?");
string category = pylike.input();
pylike.print("What is the name of the command?");
string name_of_command = pylike.input();
pylike.print("What will the command do?");
string command_description = pylike.input();
string fileformat = "import discord\n\
from discord.ext import commands\n\
class " + category + "(commands.Cog):\n\
\tdef __init__(self, bot):\n\
\t\tself.bot = bot\n\
\[email protected](name='" + name_of_command + "', help='" + command_description + "')\n\
\tasync def " + name_of_command + "(self, ctx):\n";
python py;
string backup[2] = {};
while (true) {
pylike.print("---------Program Code----------");
pylike.print(fileformat);
string questionaire = "What do you want to do? (If you don't know what to do; type help)";
pylike.print(questionaire);
backup[0] = backup[1];
backup[1] = fileformat;
string call = pylike.input();
if (call == "output") {
pylike.print("What do you want the bot to say? (You can place a variable here by using {} to surround it's name)");
fileformat = fileformat + py.output(pylike.input());
}
else if (call == "input") {
pylike.print("What do you want to name the variable?");
string var = pylike.input();
pylike.print("Will this variable be a number? Enter YES or NO");
string isfloat_string = pylike.input();
bool isfloat = false;
if (isfloat_string == "YES") {
bool isfloat = true;
}
fileformat = fileformat + py.input(var, isfloat);
}
else if (call == "loop") {
pylike.print("How many times do you want to repeat? (You can use an int variable here as an alternitive)");
fileformat = fileformat + py.loop(pylike.input());
}
else if (call == "leave loop") {
fileformat = fileformat + py.leave_loop();
}
else if (call == "math") {
pylike.print("Specify the operator that you want to use e.g., *, /, +, - and the two numbers you wish to compute such as 1+1 or 2*4 or 3/6; Variables can be used in place of the numbers");
string operation = pylike.input();
pylike.print("What is the name of the variable in which you want to store this?");
string var = pylike.input();
fileformat = fileformat + py.math(operation, var);
}
else if (call == "new variable") {
pylike.print("What is the new variable name?");
string var = pylike.input();
pylike.print("Will this contain a number? Enter YES or NO");
string type_s = pylike.input();
bool isfloat = false;
if (type_s == "YES") {
isfloat = true;
}
pylike.print("What is it's value?");
string value = pylike.input();
fileformat = fileformat + py.newvar(var, isfloat, value);
}
else if (call == "end") {
fileformat = fileformat + py.end(category);
break;
}
else if (call == "help") {
pylike.print("output|Sends a message to the channel\n\
input|Waits for a response\n\
loop|Repeats the script a specified amount of times\n\
leave loop|Breaks the loop before it completes the specified amount of times\n\
math|Allows you to calculate things between numbers and or variables\n\
new variable|Lets you make a new variable to store information\n\
end|To apply the end of the code and stop the program; This program does NOT save data and cannot reopen a file. Make sure you copy the final code before closing\n\
undo|To undo the last change made\n\
custompython|To add your own line of custom python\n");
}
else if (call == "undo") {
fileformat = backup[0];
}
else if (call == "custompython") {
pylike.print("Enter your custom python below: This does not support multiline inputs.");
py.custompython(pylike.input());
}
}
pylike.print("---------Final Code----------");
pylike.print("This program does NOT save data and cannot reopen a file. Make sure you copy the final code before closing");
pylike.print("Copy the code below into a new file that ends with .py and place the file you created into the .cogs folder of your easybot.py setup by chisaku-dev");
pylike.print("----------COPY HERE----------");
pylike.print(fileformat);
pylike.print("-----------END HERE----------");
pylike.input();
}