def do_directives(self, line): """List all directives supported by the bot""" for name, cmd in self.adapter.directives.items(): with colorize('blue'): print('bot %s:' % name) if cmd.__doc__: for line in cmd.__doc__.split('\n'): print(' %s' % line) else: print()
def do_bot(self, line): """Call the bot""" with colorize('blue'): if not line: self.say('what?') try: res = self.adapter.receive(message=line) except UnknownCommand: self.say("I do not known what the '%s' directive is" % line) else: self.say(res)
def receive(self, *args, **kwargs): with colorize('green'): print('\nHello %s\n' % self.context['user']) self.shell.cmdloop()
def say(self, message): with colorize('blue'): print('%s> %s' % (self.adapter.context.bot_name, message))
def do_exit(self, line): """Exit the session""" with colorize('blue'): print('Good bye') return -1