Merge branch 'master' into wechatmp

This commit is contained in:
JS00000
2023-04-17 20:11:41 +08:00
100 changed files with 2026 additions and 1215 deletions

29
app.py
View File

@@ -1,23 +1,27 @@
# encoding:utf-8
import os
from config import conf, load_config
from channel import channel_factory
from common.log import logger
from plugins import *
import signal
import sys
from channel import channel_factory
from common.log import logger
from config import conf, load_config
from plugins import *
def sigterm_handler_wrap(_signo):
old_handler = signal.getsignal(_signo)
def func(_signo, _stack_frame):
logger.info("signal {} received, exiting...".format(_signo))
conf().save_user_datas()
if callable(old_handler): # check old_handler
if callable(old_handler): # check old_handler
return old_handler(_signo, _stack_frame)
sys.exit(0)
signal.signal(_signo, func)
def run():
try:
# load config
@@ -28,17 +32,17 @@ def run():
sigterm_handler_wrap(signal.SIGTERM)
# create channel
channel_name=conf().get('channel_type', 'wx')
channel_name = conf().get("channel_type", "wx")
if "--cmd" in sys.argv:
channel_name = 'terminal'
channel_name = "terminal"
if channel_name == 'wxy':
os.environ['WECHATY_LOG']="warn"
if channel_name == "wxy":
os.environ["WECHATY_LOG"] = "warn"
# os.environ['WECHATY_PUPPET_SERVICE_ENDPOINT'] = '127.0.0.1:9001'
channel = channel_factory.create_channel(channel_name)
if channel_name in ['wx','wxy','terminal','wechatmp','wechatmp_service']:
if channel_name in ["wx", "wxy", "terminal", "wechatmp", "wechatmp_service"]:
PluginManager().load_plugins()
# startup channel
@@ -47,5 +51,6 @@ def run():
logger.error("App startup failed!")
logger.exception(e)
if __name__ == '__main__':
run()
if __name__ == "__main__":
run()