mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-02-14 08:16:32 +08:00
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
"""
|
|
channel factory
|
|
"""
|
|
from common import const
|
|
from .channel import Channel
|
|
|
|
|
|
def create_channel(channel_type) -> Channel:
|
|
"""
|
|
create a channel instance
|
|
:param channel_type: channel type code
|
|
:return: channel instance
|
|
"""
|
|
ch = Channel()
|
|
if channel_type == "wx":
|
|
from channel.wechat.wechat_channel import WechatChannel
|
|
ch = WechatChannel()
|
|
elif channel_type == "wxy":
|
|
from channel.wechat.wechaty_channel import WechatyChannel
|
|
ch = WechatyChannel()
|
|
elif channel_type == "wcf":
|
|
from channel.wechat.wcf_channel import WechatfChannel
|
|
ch = WechatfChannel()
|
|
elif channel_type == "terminal":
|
|
from channel.terminal.terminal_channel import TerminalChannel
|
|
ch = TerminalChannel()
|
|
elif channel_type == 'web':
|
|
from channel.web.web_channel import WebChannel
|
|
ch = WebChannel()
|
|
elif channel_type == "wechatmp":
|
|
from channel.wechatmp.wechatmp_channel import WechatMPChannel
|
|
ch = WechatMPChannel(passive_reply=True)
|
|
elif channel_type == "wechatmp_service":
|
|
from channel.wechatmp.wechatmp_channel import WechatMPChannel
|
|
ch = WechatMPChannel(passive_reply=False)
|
|
elif channel_type == "wechatcom_app":
|
|
from channel.wechatcom.wechatcomapp_channel import WechatComAppChannel
|
|
ch = WechatComAppChannel()
|
|
elif channel_type == "wework":
|
|
from channel.wework.wework_channel import WeworkChannel
|
|
ch = WeworkChannel()
|
|
elif channel_type == const.FEISHU:
|
|
from channel.feishu.feishu_channel import FeiShuChanel
|
|
ch = FeiShuChanel()
|
|
elif channel_type == const.DINGTALK:
|
|
from channel.dingtalk.dingtalk_channel import DingTalkChanel
|
|
ch = DingTalkChanel()
|
|
else:
|
|
raise RuntimeError
|
|
ch.channel_type = channel_type
|
|
return ch
|