def interactive(self, context=None):
"""Runs interactive command line chat between user and bot. Runs
indefinitely until EOF is entered to the prompt.
context -- optional initial context. Set to {} if omitted
"""
if context is None:
context = {}
# input/raw_input are not interchangeable between Python 2 and 3
try:
input_function = raw_input
except NameError:
input_function = input
history = InMemoryHistory()
while True:
try:
message = prompt(INTERACTIVE_PROMPT, history=history, mouse_support=True).rstrip()
except (KeyboardInterrupt, EOFError):
return
print(self.message(message, context))
评论列表
文章目录