diff --git a/pagebot.py b/pagebot.py index ab663fc..ed308e0 100644 --- a/pagebot.py +++ b/pagebot.py @@ -93,6 +93,19 @@ async def upload_to_discord(mp4_file,text): else: print(f"Could not find channel with ID {channel}") +def launch_and_watch(program_path): + while True: + process = subprocess.Popen(program_path) + process.wait() + if process.returncode != 0: + print("TTD has crashed. Relaunching...") + else: + print("TTD has exited normally.") + break + + # Wait for a few seconds before relaunching + time.sleep(5) + if __name__ == "__main__": ## initialize watchdogs @@ -101,11 +114,15 @@ if __name__ == "__main__": observer.schedule(event_handler, secrets_file.watch_folder, recursive=False) observer.start() + ## Launch TTD + launch_and_watch(secrets_file.ttd_path) + ## initialize discord intents = discord.Intents.default() intents.message_content = True client = discord.Client(intents=intents) client.run(secrets_file.key) + try: while True: diff --git a/sample-secrets_file.py b/sample-secrets_file.py index 379d3e3..7b0fb56 100644 --- a/sample-secrets_file.py +++ b/sample-secrets_file.py @@ -1,5 +1,12 @@ +## TwoToneDetect Executable Path +ttd_path = "C:\\PATH\\TO\\TTD.exe" +## Discord Bot Token key = 'Bot Token' +## Folder to Watch for output audio watch_folder = '/path/to/folder' +## Discord Channel ID to send notifications channel_id = channel_id_number +## Generally a good idea. delete_after_upload=True +## This will slow down pages and is unreliable. speech_to_text = True \ No newline at end of file