您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

30 行
770B

  1. from channel.channel import Channel
  2. import sys
  3. class TerminalChannel(Channel):
  4. def startup(self):
  5. context = {"from_user_id": "User"}
  6. print("\nPlease input your question")
  7. while True:
  8. try:
  9. prompt = self.get_input("User:\n")
  10. except KeyboardInterrupt:
  11. print("\nExiting...")
  12. sys.exit()
  13. print("Bot:")
  14. sys.stdout.flush()
  15. for res in super().build_reply_content(prompt, context):
  16. print(res, end="")
  17. sys.stdout.flush()
  18. print("\n")
  19. def get_input(self, prompt):
  20. """
  21. Multi-line input function
  22. """
  23. print(prompt, end="")
  24. line = input()
  25. return line