Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Customized time-stamp input #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions chatbase/base_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class MessageTypes(object):
USER = "user"
AGENT = "agent"


class Message(object):
"""Base Message.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t

"""Base Message. modified based on older version
Define attributes present on all variants of the Message Class.
"""

Expand All @@ -48,7 +47,8 @@ def __init__(self,
message="",
intent="",
version="",
user_id=""):
user_id="",
time_stamp=None):
self.api_key = api_key
self.platform = platform
self.message = message
Expand All @@ -57,7 +57,8 @@ def __init__(self,
self.user_id = user_id
self.not_handled = False
self.feedback = False
self.time_stamp = Message.get_current_timestamp()
if time_stamp == None:
self.time_stamp = Message.get_current_timestamp()
self.type = MessageTypes.USER

@staticmethod
Expand Down Expand Up @@ -117,9 +118,8 @@ def send(self):
data=self.to_json(),
headers=Message.get_content_type())


class MessageSet(object):
"""Message Set.
"""Message Set. modified based on older version
Add messages to a set and send to the Batch API.
"""

Expand All @@ -134,14 +134,15 @@ def __init__(self,
self.user_id = user_id
self.messages = []

def new_message(self, intent="", message=""):
def new_message(self, intent="", message="", time_stamp=None):
"""Add a message to the internal messages list and return it"""
self.messages.append(Message(api_key=self.api_key,
platform=self.platform,
version=self.version,
user_id=self.user_id,
intent=intent,
message=message))
message=message,
time_stamp=time_stamp))
return self.messages[-1]

def to_json(self):
Expand Down