Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def receive(self, *args, **kwargs):
        with colorize('green'):
            print('\nHello %s\n' % self.context['user'])

        self.shell.cmdloop()
Ejemplo n.º 4
0
 def say(self, message):
     with colorize('blue'):
         print('%s> %s' % (self.adapter.context.bot_name, message))
Ejemplo n.º 5
0
 def do_exit(self, line):
     """Exit the session"""
     with colorize('blue'):
         print('Good bye')
     return -1