def main(): OUT.put('Hi! My name is %(name)s.' % config) OUT.put('U can try 2 talk w/ me & ask me anything u want\n') name = IN.put("What's yr name?\n") OUT.put('\nNice 2 meet u, %(name)s' % locals()) OUT.put('Please type "bye" to finish our talk\n') bot = Bot(IN.args) while True: q = IN.put(message(name)) if q == config['exit']: break OUT.put(message(config['name'], bot.answer(q))) OUT.put(message(config['name'], 'bye!'))
from bot import Bot if __name__ == '__main__': bot1 = Bot('../cfgs/tricks/huarui') state, sentence = bot1.start() print(state, sentence) while True: user_input = input('user input: ') if user_input == 'q': break state, sentence = bot1.answer(user_input) print(state, sentence) if '结束' in state: print(bot1.get_label()) break