예제 #1
0
파일: bot.py 프로젝트: wechat-bot/wxpy
    def create_group(self, users, topic=None):
        """
        创建一个新的群聊

        :param users: 用户列表
        :param topic: 群名称
        :return: 若建群成功,返回一个新的群聊对象
        :rtype: :class:`wxpy.Group`
        """

        logger.info('{}: creating group (topic: {}), with users:\n{}'.format(
            self, topic, pformat(users)))

        @handle_response()
        def request():
            return self.core.create_chatroom(memberList=dict_list,
                                             topic=topic or '')

        dict_list = wrap_user_name(self.except_self(ensure_list(users)))
        ret = request()
        user_name = ret.get('ChatRoomName')
        if user_name:
            return Group(self.core.update_chatroom(userName=user_name), self)
        else:
            raise Exception('Failed to create group:\n{}'.format(pformat(ret)))
예제 #2
0
    def create_group(self, users, topic=None):
        """
        创建一个新的群聊

        :param users: 用户列表
        :param topic: 群名称
        :return: 若建群成功,返回一个新的群聊对象
        """
        @handle_response()
        def request():
            return self.core.create_chatroom(memberList=wrap_user_name(users),
                                             topic=topic or '')

        ret = request()
        user_name = ret.get('ChatRoomName')
        if user_name:
            return Group(self.core.update_chatroom(userName=user_name), self)
        else:
            raise ResponseError('Failed to create group:\n{}'.format(
                pformat(ret)))