32 lines
653 B
Python
32 lines
653 B
Python
|
|
import os
|
||
|
|
import time
|
||
|
|
import threading
|
||
|
|
import webbrowser
|
||
|
|
|
||
|
|
import py_backend
|
||
|
|
from wechat_multi_chat_bot import WechatMultiChatBot
|
||
|
|
|
||
|
|
HOST = os.getenv("APP_HOST", "127.0.0.1")
|
||
|
|
PORT = int(os.getenv("APP_PORT", "5000"))
|
||
|
|
OPEN_BROWSER = os.getenv("OPEN_BROWSER", "1") == "1"
|
||
|
|
|
||
|
|
|
||
|
|
def run_backend():
|
||
|
|
py_backend.start_backend(host=HOST, port=PORT)
|
||
|
|
|
||
|
|
|
||
|
|
def run_bot():
|
||
|
|
bot = WechatMultiChatBot()
|
||
|
|
bot.run_forever()
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
backend_thread = threading.Thread(target=run_backend, daemon=True)
|
||
|
|
backend_thread.start()
|
||
|
|
|
||
|
|
time.sleep(1.5)
|
||
|
|
if OPEN_BROWSER:
|
||
|
|
webbrowser.open(f"http://{HOST}:{PORT}/admin.html")
|
||
|
|
|
||
|
|
run_bot()
|