Exemple #1
0
    def __init__(self, chat_manager, message, interceptors=None):
        from botshot.core.logging.logging_service import AsyncLoggingService
        flows = get_flows()
        if flows is None:
            raise ValueError("Flows have not been initialized.")
        if chat_manager is None:
            raise ValueError("ChatManager is None")
        if message is None:
            raise ValueError("Message is None")
        if message.conversation is None:
            raise ValueError("Conversation is None")

        self.message = message
        self.chat_manager = chat_manager
        self.send_exceptions = config.get("SEND_EXCEPTIONS",
                                          default=settings.DEBUG)
        self.flows = flows
        self.current_state_name = self.message.conversation.state or 'default.root'
        self.context = Context.load(
            data=message.conversation.context_dict or {})
        loggers = [
            import_string(path)()
            for path in config.get('MESSAGE_LOGGERS', default=[])
        ]
        self.logging_service = AsyncLoggingService(loggers)
        self.dialog = Dialog(message=self.message,
                             context=self.context,
                             chat_manager=self.chat_manager,
                             logging_service=self.logging_service)
        self.interceptors = interceptors or []
 def get_ids(self):
     matching = []
     for conversation in ChatConversation.objects.all():
         context = Context.load(data=conversation.context_dict)
         if self._filter_context(context):
             matching.append(conversation.id)
     return matching
Exemple #3
0
    def __init__(self):

        self.message = ChatMessage()
        self.sender = ChatUser()
        self.conversation = ChatConversation()
        self.conversation.conversation_id = 1
        self.conversation.save()
        self.chat_manager = ChatManager()
        self.context = Context.load({})
        self.logging_service = Mock()

        self.sent = []
        self.schedules = []
        self.inactive_callbacks = []