Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

43 lines
1.4KB

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