Skip to content
This repository was archived by the owner on Aug 11, 2024. It is now read-only.

Commit ce83be3

Browse files
committed
user can now use a file as cmd line arg for automation of eb commands
1 parent c0209e3 commit ce83be3

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

automated_commands

Whitespace-only changes.

basicbot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
async def cog(client):
1010
#cogs detection
1111
os.chdir(os.path.dirname(os.path.abspath(__file__)))
12-
cogs = [f for f in os.listdir('./cogs') if f.endswith('.py')]
12+
cogs = [f[:-3] for f in os.listdir('./cogs') if f.endswith('.py')]
1313
if len(cogs) >= 5:
1414
print('This may take a while... please wait patiently')
1515
for cog in cogs:
16-
cog = cog.replace('.py', '')
1716
while True:
1817
try:
1918
try:

eb_launcher.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,48 @@ def offset(list):
1111

1212
def inputs():
1313
while True:
14-
nums = input('Select the bots you wish to select by listing the number corrosponding (e.g. 1 2 4): ').split(' ')
14+
nums = better.input('Select the bots you wish to select by listing the number corrosponding (e.g. 1 2 4): ').split(' ')
1515
try:
1616
nums = sorted(list(map(int, nums)))
1717
break
1818
except ValueError as e:
1919
print(e)
2020
return nums
2121

22+
class better:
23+
input_called = -1
24+
try:
25+
input_commands = [c.replace('\n', '') for c in open(sys.argv[1], 'r').readlines()]
26+
except:
27+
input_commands = []
28+
def input(*string):
29+
if string:
30+
print(string, end='')
31+
better.input_called += 1
32+
try:
33+
print(better.input_commands[better.input_called], end='')
34+
return better.input_commands[better.input_called]
35+
except:
36+
return input()
37+
38+
2239
def eula():
2340
if 'LICENSE' not in os.listdir(os.path.dirname(os.path.abspath(__file__))):
24-
input('LICENSE does not exist; Please download it from https://github.com/chisaku-dev/EasyBot.py and try again')
41+
better.input('LICENSE does not exist; Please download it from https://github.com/chisaku-dev/EasyBot.py and try again')
2542
quit()
2643
else:
27-
input(f"{open('LICENSE', 'r').read()}\n [If you press ENTER, you agree to the LICENSE included]")
44+
better.input(f"{open('LICENSE', 'r').read()}\n [If you press ENTER, you agree to the LICENSE included]")
2845

2946
class commands:
3047
def help():
3148
ui.sys_message('Commands List')
3249
ui.list_dict(choices)
3350
def add():
34-
tks = input('What is your bot token(s) (if multiple, seperate them with spaces)? Obtain it from https://discord.com/developers/ and paste it here: ').split(' ')
51+
tks = better.input('What is your bot token(s) (if multiple, seperate them with spaces)? Obtain it from https://discord.com/developers/ and paste it here: ').split(' ')
3552
exist_tks = data.extract_tks()
3653
for tk in tks:
3754
if not tk in exist_tks:
38-
data.save(tk, input(f'Prefix for {tk}: '))
55+
data.save(tk, better.input(f'Prefix for {tk}: '))
3956
else:
4057
print(tk, 'already exists in the database; Please remove the previous entry before trying to add this token again')
4158
ui.sys_message('Success')
@@ -66,8 +83,8 @@ def boots():
6683
else:
6784
ui.sys_message('There are no bots stored')
6885
def boott():
69-
tk = input('What is the bot token?\n')
70-
px = input('What is the desired bot prefix?\n')
86+
tk = better.input('What is the bot token?\n')
87+
px = better.input('What is the desired bot prefix?\n')
7188
bot = dict(token = tk, prefix = px)
7289
core.boot(bot)
7390
def restart():
@@ -97,8 +114,7 @@ def quit():
97114
quit()
98115
if __name__ == '__main__':
99116
os.chdir(os.path.dirname(os.path.abspath(__file__)))
100-
if not 'agreetos' in sys.argv:
101-
eula()
117+
eula()
102118
try:
103119
os.mkdir('./data')
104120
open('./data/bots.easybot', 'w').close()
@@ -124,13 +140,10 @@ def quit():
124140
i = 1
125141
ui.sys_message('EasyBot.py is running')
126142
commands.help()
143+
ui.sys_message('Run your commands below')
127144
while True:
128145
try:
129-
if i < len(sys.argv):
130-
choice = sys.argv[i]
131-
i += 1
132-
else:
133-
choice = input()
146+
choice = better.input()
134147
if choice == 'help':
135148
commands.help()
136149
if choice == 'add':

0 commit comments

Comments
 (0)