Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

45 lines
1.3KB

  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