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.

преди 2 години
преди 1 година
преди 2 години
преди 1 година
преди 2 години
преди 1 година
преди 1 година
преди 1 година
преди 1 година
преди 1 година
преди 1 година
преди 1 година
преди 1 година
123456789101112131415161718192021222324252627282930313233343536373839
  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)