# Path: yaklient/helper.py
# def backslash_remove(text):
# def emoji_remove(text):
# def generate_id(dashes=True, upper=False):
# def hash_msg(key, msg):
#     def __init__(self, error_string, response):
#     def __str__(self):
# class ParsingResponseError(Exception):
# 
# Path: yaklient/objects/message.py
# class Message(object):
#     """An abstract class for a postable object on Yik Yak (Comment or Yak)"""
#     def __init__(self, raw, user):
#         """Initialize message from raw JSON dict and user"""
#         self.delivery_id = raw["deliveryID"]
#         self.liked = raw["liked"]
#         self.likes = raw["numberOfLikes"]
#         self.message_id = helper.backslash_remove(raw["messageID"])
#         self.poster_id = raw["posterID"]
#         self.time = raw["time"]
#         self.user = user
#         try:
#             self.reyaked = raw["reyaked"]
#         except KeyError:
#             self.reyaked = None
# 
#     @abstractmethod
#     def __str__(self):
#         """Return message as string"""
#         pass
# 
#     def delete(self):
#         """Delete message from Yik Yak. Return True if successful, False if
#         unsuccessful"""
#         return self.user.delete(self)
# 
#     def downvote(self):
#         """Downvote the message. Return True if successful, False if
#         unsuccessful"""
#         if self.user.downvote(self):
#             self.likes -= 1
#             return True
#         else:
#             return False
# 
#     def get_comments(self):
#         """Get comments on the message"""
#         return self.user.get_comments(self)
# 
#     def post_comment(self, comment):
#         """Post a comment on the message. Return True if successful, False if
#         unsuccessful"""
#         return self.user.post_comment(comment, self.message_id)
# 
#     def report(self):
#         """Report a message to Yik Yak"""
#         self.user.report(self)
# 
#     @abstractmethod
#     def update(self):
#         """Update properties from Yik Yak"""
#         pass
# 
#     def upvote(self):
#         """Upvote the message. Return True if successful, False if
#         unsuccessful"""
#         if self.user.upvote(self):
#             self.likes += 1
#             return True
#         else:
#             return False


from yaklient import helper
from yaklient.objects.message import Message
# -*- coding: utf-8 -*-

"""Class for a comment on Yik Yak"""



class Comment(Message):
    """A comment on a post on Yik Yak"""
    def __init__(self, raw, user):
        """Initialize comment from raw JSON dict and user"""
        super(Comment, self).__init__(raw, user)
        self.comment = raw["comment"]
        self.comment_id = raw["commentID"]
        try:
            self.gmt = raw["gmt"]
        except KeyError:
            self.gmt = None
        try:
            self.back_id = raw["backID"]
            self.overlay_id = raw["overlayID"]
        except KeyError:
            self.back_id = None
            self.overlay_id = None
        try:
            self.text_style = raw["textStyle"]
        except KeyError:
            self.text_style = None

    def __str__(self):
        """Return comment as string"""

# Path: yaklient/helper.py
# def backslash_remove(text):
# def emoji_remove(text):
# def generate_id(dashes=True, upper=False):
# def hash_msg(key, msg):
#     def __init__(self, error_string, response):
#     def __str__(self):
# class ParsingResponseError(Exception):
# 
# Path: yaklient/objects/message.py
# class Message(object):
#     """An abstract class for a postable object on Yik Yak (Comment or Yak)"""
#     def __init__(self, raw, user):
#         """Initialize message from raw JSON dict and user"""
#         self.delivery_id = raw["deliveryID"]
#         self.liked = raw["liked"]
#         self.likes = raw["numberOfLikes"]
#         self.message_id = helper.backslash_remove(raw["messageID"])
#         self.poster_id = raw["posterID"]
#         self.time = raw["time"]
#         self.user = user
#         try:
#             self.reyaked = raw["reyaked"]
#         except KeyError:
#             self.reyaked = None
# 
#     @abstractmethod
#     def __str__(self):
#         """Return message as string"""
#         pass
# 
#     def delete(self):
#         """Delete message from Yik Yak. Return True if successful, False if
#         unsuccessful"""
#         return self.user.delete(self)
# 
#     def downvote(self):
#         """Downvote the message. Return True if successful, False if
#         unsuccessful"""
#         if self.user.downvote(self):
#             self.likes -= 1
#             return True
#         else:
#             return False
# 
#     def get_comments(self):
#         """Get comments on the message"""
#         return self.user.get_comments(self)
# 
#     def post_comment(self, comment):
#         """Post a comment on the message. Return True if successful, False if
#         unsuccessful"""
#         return self.user.post_comment(comment, self.message_id)
# 
#     def report(self):
#         """Report a message to Yik Yak"""
#         self.user.report(self)
# 
#     @abstractmethod
#     def update(self):
#         """Update properties from Yik Yak"""
#         pass
# 
#     def upvote(self):
#         """Upvote the message. Return True if successful, False if
#         unsuccessful"""
#         if self.user.upvote(self):
#             self.likes += 1
#             return True
#         else:
#             return False


# Path: yaklient/objects/comment.py
from yaklient import helper
from yaklient.objects.message import Message

# -*- coding: utf-8 -*-

"""Class for a comment on Yik Yak"""



class Comment(Message):
    """A comment on a post on Yik Yak"""
    def __init__(self, raw, user):
        """Initialize comment from raw JSON dict and user"""
        super(Comment, self).__init__(raw, user)
        self.comment = raw["comment"]
        self.comment_id = raw["commentID"]
        try:
            self.gmt = raw["gmt"]
        except KeyError:
            self.gmt = None
        try:
            self.back_id = raw["backID"]
            self.overlay_id = raw["overlayID"]
        except KeyError:
            self.back_id = None
            self.overlay_id = None
        try:
            self.text_style = raw["textStyle"]
        except KeyError:
            self.text_style = None

    def __str__(self):
        """Return comment as string"""

        return "%s (%d)" % (helper.emoji_remove(self.comment), self.likes)