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.

40 lines
1009B

  1. """
  2. Message sending channel abstract class
  3. """
  4. from bridge.bridge import Bridge
  5. from bridge.context import Context
  6. from bridge.reply import Reply
  7. class Channel(object):
  8. def startup(self):
  9. """
  10. init channel
  11. """
  12. raise NotImplementedError
  13. def handle_text(self, msg):
  14. """
  15. process received msg
  16. :param msg: message object
  17. """
  18. raise NotImplementedError
  19. def send(self, msg, receiver):
  20. """
  21. send message to user
  22. :param msg: message content
  23. :param receiver: receiver channel account
  24. :return:
  25. """
  26. raise NotImplementedError
  27. def build_reply_content(self, query, context : Context=None) -> Reply:
  28. return Bridge().fetch_reply_content(query, context)
  29. def build_voice_to_text(self, voice_file) -> Reply:
  30. return Bridge().fetch_voice_to_text(voice_file)
  31. def build_text_to_voice(self, text) -> Reply:
  32. return Bridge().fetch_text_to_voice(text)