Skip to content

Commit c8544e4

Browse files
committed
Add config setup in --create-new scripts
1 parent 312056c commit c8544e4

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

twitchio/__main__.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"""
2424

2525
import argparse
26+
import getpass
2627
import os
2728
import pathlib
2829
import platform
@@ -227,6 +228,51 @@ def generate_bot() -> ...:
227228
with open(comp_dir / "general.py", "w") as fp:
228229
fp.write(COMPONENT)
229230

231+
client_id = None
232+
client_sec = None
233+
config = bool_check(validate_input("Would you like to create a config? (y/N): ", bool_validate))
234+
235+
if config:
236+
237+
while True:
238+
239+
client_id = validate_input("Please enter your Client-ID: ")
240+
cid_reenter = validate_input("Please re-enter your Client-ID: ")
241+
242+
if client_id != cid_reenter:
243+
print("Client-ID does not match, please try again...", end="\n\n")
244+
continue
245+
246+
break
247+
248+
while True:
249+
client_sec = getpass.getpass("Please enter your Client-Secret: ")
250+
csec_reenter = getpass.getpass("Please re-enter your Client-Secret: ")
251+
252+
if client_sec != csec_reenter:
253+
print("Client-Secret does not match, please try again...", end="\n\n")
254+
continue
255+
256+
break
257+
258+
config_data = f"""[secrets]\nclient_id = \"{client_id}\"\nclient_secret = \"{client_sec}\""""
259+
with open("config.toml", "w") as fp:
260+
fp.write(config_data)
261+
262+
if client_id and client_sec:
263+
while True:
264+
owner_name = validate_input("Please enter the Twitch username of the owner of this Bot (E.g. chillymosh): ")
265+
bot_name = validate_input("Please enter the Twitch username of the Bot Account (E.g. chillybot): ")
266+
names = f"Owner Name: '{owner_name}'\nBot Name: '{bot_name}'"
267+
268+
correct = bool_check(validate_input(f"Is this information correct? (y/N)\n\n{names}\n", bool_validate))
269+
if not correct:
270+
continue
271+
272+
break
273+
274+
275+
230276
# TODO: .env
231277
# TODO: client details
232278
# TODO: fetch owner/bot IDs

0 commit comments

Comments
 (0)