You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

channel_factory.py 1.3KB

1 anno fa
1 anno fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. channel factory
  3. """
  4. from common import const
  5. def create_channel(channel_type):
  6. """
  7. create a channel instance
  8. :param channel_type: channel type code
  9. :return: channel instance
  10. """
  11. if channel_type == "wx":
  12. from channel.wechat.wechat_channel import WechatChannel
  13. return WechatChannel()
  14. elif channel_type == "wxy":
  15. from channel.wechat.wechaty_channel import WechatyChannel
  16. return WechatyChannel()
  17. elif channel_type == "terminal":
  18. from channel.terminal.terminal_channel import TerminalChannel
  19. return TerminalChannel()
  20. elif channel_type == "wechatmp":
  21. from channel.wechatmp.wechatmp_channel import WechatMPChannel
  22. return WechatMPChannel(passive_reply=True)
  23. elif channel_type == "wechatmp_service":
  24. from channel.wechatmp.wechatmp_channel import WechatMPChannel
  25. return WechatMPChannel(passive_reply=False)
  26. elif channel_type == "wechatcom_app":
  27. from channel.wechatcom.wechatcomapp_channel import WechatComAppChannel
  28. return WechatComAppChannel()
  29. elif channel_type == "wework":
  30. from channel.wework.wework_channel import WeworkChannel
  31. return WeworkChannel()
  32. elif channel_type == const.FEISHU:
  33. from channel.feishu.feishu_channel import FeiShuChanel
  34. return FeiShuChanel()
  35. raise RuntimeError