1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/bots.py

34 lines
1.2 KiB
Python
Raw Normal View History

2017-10-30 12:45:38 +00:00
import multiprocessing
import os
2017-10-30 12:45:38 +00:00
import telegrambot
import discordbot
2018-01-20 14:28:04 +00:00
import time
import platform
2017-10-30 12:45:38 +00:00
2017-11-15 09:48:58 +00:00
discord_telegram_pipe = multiprocessing.Pipe()
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True)
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True)
2017-10-30 12:45:38 +00:00
if __name__ == "__main__":
discord.start()
2017-11-10 07:53:48 +00:00
telegram.start()
try:
while True:
if discord.exitcode is not None:
print("Restarting Discord Bot...")
del discord
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True)
discord.start()
if telegram.exitcode is not None:
print("Restarting Telegram Bot...")
del telegram
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True)
telegram.start()
time.sleep(60)
except KeyboardInterrupt:
if platform.system() == "Linux":
2018-05-25 17:58:30 +00:00
os.system("reset")
2018-07-31 16:38:42 +00:00
print("Stopping...")
2018-07-31 16:31:06 +00:00
discord_telegram_pipe[0].send("stop")
2018-07-31 16:38:54 +00:00
time.sleep(30)