# Path: wxpy/api/consts.py
# ATTACHMENT = 'Attachment'
# 
# PICTURE = 'Picture'
# 
# TEXT = 'Text'
# 
# VIDEO = 'Video'
# 
# Path: wxpy/compatible/utils.py
# def force_encoded_string_output(func):
# 
#     if sys.version_info.major < 3:
# 
#         def _func(*args, **kwargs):
#             return func(*args, **kwargs).encode(sys.stdout.encoding or 'utf-8')
# 
#         return _func
# 
#     else:
#         return func
# 
# Path: wxpy/utils/misc.py
# def handle_response(to_class=None):
#     """
#     装饰器：检查从 itchat 返回的字典对象，并将其转化为指定类的实例
#     若返回值不为0，会抛出 ResponseError 异常
# 
#     :param to_class: 需转化成的类，若为None则不转换
#     """
# 
#     def decorator(func):
#         @wraps(func)
#         def wrapped(*args, **kwargs):
#             ret = func(*args, **kwargs)
# 
#             if ret is None:
#                 return
# 
#             smart_map(check_response_body, ret)
# 
#             if to_class:
#                 if args:
#                     self = args[0]
#                 else:
#                     self = inspect.currentframe().f_back.f_locals.get('self')
# 
#                 from wxpy.api.bot import Bot
#                 if isinstance(self, Bot):
#                     bot = weakref.proxy(self)
#                 else:
#                     bot = getattr(self, 'bot', None)
#                     if not bot:
#                         raise ValueError('bot not found:m\nmethod: {}\nself: {}\nbot: {}'.format(
#                             func, self, bot
#                         ))
# 
#                 ret = smart_map(to_class, ret, bot)
# 
#                 if isinstance(ret, list):
#                     from wxpy.api.chats import Group
#                     if to_class == Group:
#                         from wxpy.api.chats import Groups
#                         ret = Groups(ret)
#                     else:
#                         from wxpy.api.chats import Chats
#                         ret = Chats(ret, bot)
# 
#             return ret
# 
#         return wrapped
# 
#     return decorator


import datetime
import logging
import re
import time
from functools import partial, wraps
from wxpy.api.consts import ATTACHMENT, PICTURE, TEXT, VIDEO
from wxpy.compatible import *
from wxpy.compatible.utils import force_encoded_string_output
from wxpy.utils import handle_response
            from wxpy import SentMessage
        from wxpy.utils import BaseRequest
        from wxpy.utils import BaseRequest
        from .group import Group
        from .member import Member
        from .friend import User
    def mark_as_read(self):
        """
        消除当前聊天对象的未读提示小红点
        """

        req = BaseRequest(
            bot=self.bot,
            # itchat 中的 pass_ticket 已经预先编码了
            uri='/webwxstatusnotify?pass_ticket={}'.format(self.bot.core.loginInfo['pass_ticket'])
        )

        req.data.update({
            'ClientMsgId': int(time.time() * 1000),
            'Code': 1,
            'FromUserName': self.bot.self.user_name,
            'ToUserName': self.user_name,
        })

        logger.debug('marking {} as read'.format(self))

        return req.request('POST')

    @handle_response()
    def pin(self):
        """
        将聊天对象置顶
        """
        logger.info('pinning {}'.format(self))
        return self.bot.core.set_pinned(userName=self.user_name, isPinned=True)


# Path: wxpy/api/consts.py
# ATTACHMENT = 'Attachment'
# 
# PICTURE = 'Picture'
# 
# TEXT = 'Text'
# 
# VIDEO = 'Video'
# 
# Path: wxpy/compatible/utils.py
# def force_encoded_string_output(func):
# 
#     if sys.version_info.major < 3:
# 
#         def _func(*args, **kwargs):
#             return func(*args, **kwargs).encode(sys.stdout.encoding or 'utf-8')
# 
#         return _func
# 
#     else:
#         return func
# 
# Path: wxpy/utils/misc.py
# def handle_response(to_class=None):
#     """
#     装饰器：检查从 itchat 返回的字典对象，并将其转化为指定类的实例
#     若返回值不为0，会抛出 ResponseError 异常
# 
#     :param to_class: 需转化成的类，若为None则不转换
#     """
# 
#     def decorator(func):
#         @wraps(func)
#         def wrapped(*args, **kwargs):
#             ret = func(*args, **kwargs)
# 
#             if ret is None:
#                 return
# 
#             smart_map(check_response_body, ret)
# 
#             if to_class:
#                 if args:
#                     self = args[0]
#                 else:
#                     self = inspect.currentframe().f_back.f_locals.get('self')
# 
#                 from wxpy.api.bot import Bot
#                 if isinstance(self, Bot):
#                     bot = weakref.proxy(self)
#                 else:
#                     bot = getattr(self, 'bot', None)
#                     if not bot:
#                         raise ValueError('bot not found:m\nmethod: {}\nself: {}\nbot: {}'.format(
#                             func, self, bot
#                         ))
# 
#                 ret = smart_map(to_class, ret, bot)
# 
#                 if isinstance(ret, list):
#                     from wxpy.api.chats import Group
#                     if to_class == Group:
#                         from wxpy.api.chats import Groups
#                         ret = Groups(ret)
#                     else:
#                         from wxpy.api.chats import Chats
#                         ret = Chats(ret, bot)
# 
#             return ret
# 
#         return wrapped
# 
#     return decorator


# Path: wxpy/api/chats/chat.py
import datetime
import logging
import re
import time
from functools import partial, wraps
from wxpy.api.consts import ATTACHMENT, PICTURE, TEXT, VIDEO
from wxpy.compatible import *
from wxpy.compatible.utils import force_encoded_string_output
from wxpy.utils import handle_response
            from wxpy import SentMessage
        from wxpy.utils import BaseRequest
        from wxpy.utils import BaseRequest
        from .group import Group
        from .member import Member
        from .friend import User

    def mark_as_read(self):
        """
        消除当前聊天对象的未读提示小红点
        """

        req = BaseRequest(
            bot=self.bot,
            # itchat 中的 pass_ticket 已经预先编码了
            uri='/webwxstatusnotify?pass_ticket={}'.format(self.bot.core.loginInfo['pass_ticket'])
        )

        req.data.update({
            'ClientMsgId': int(time.time() * 1000),
            'Code': 1,
            'FromUserName': self.bot.self.user_name,
            'ToUserName': self.user_name,
        })

        logger.debug('marking {} as read'.format(self))

        return req.request('POST')

    @handle_response()
    def pin(self):
        """
        将聊天对象置顶
        """
        logger.info('pinning {}'.format(self))
        return self.bot.core.set_pinned(userName=self.user_name, isPinned=True)


    @handle_response()