多通道

This commit is contained in:
RA
2023-03-18 22:48:06 +08:00
parent b013b283b3
commit 1c43111b1b
2 changed files with 13 additions and 9 deletions

20
app.py
View File

@@ -3,6 +3,13 @@
import config
from channel import channel_factory
from common import log
from multiprocessing import Process
def startProcess(channel_type):
# create channel
channel = channel_factory.create_channel(channel_type)
# startup channel
channel.startup()
if __name__ == '__main__':
try:
@@ -12,13 +19,10 @@ if __name__ == '__main__':
model_type = config.conf().get("model").get("type")
channel_type = config.conf().get("channel").get("type")
log.info("[INIT] Start up: {} on {}", model_type, channel_type)
# create channel
channel = channel_factory.create_channel(channel_type)
# startup channel
channel.startup()
for type in channel_type:
log.info("[INIT] Start up: {} on {}", model_type, type)
p = Process(target=startProcess, args=(type))
p.start()
except Exception as e:
log.error("App startup failed!")
log.exception(e)
log.exception(e)

View File

@@ -15,7 +15,7 @@
},
"channel": {
"type": "terminal",
"type": ["http","terminal","wechat"],
"single_chat_prefix": ["bot", "@bot"],
"single_chat_reply_prefix": "[bot] ",
"group_chat_prefix": ["@bot"],