INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Get a list of version Resources present on a project.
def project_versions(self, project): """Get a list of version Resources present on a project. :param project: ID or key of the project to get versions from :type project: str :rtype: List[Version] """ r_json = self._get_json('project/' + project + '/versions') ve...
Get a version Resource by its name present on a project.
def get_project_version_by_name(self, project, version_name): """Get a version Resource by its name present on a project. :param project: ID or key of the project to get versions from :type project: str :param version_name: name of the version to search for :type version_name: s...
Rename a version Resource on a project.
def rename_version(self, project, old_name, new_name): """Rename a version Resource on a project. :param project: ID or key of the project to get versions from :type project: str :param old_name: old name of the version to rename :type old_name: str :param new_name: new ...
Get a dict of role names to resource locations for a project.
def project_roles(self, project): """Get a dict of role names to resource locations for a project. :param project: ID or key of the project to get roles from """ path = 'project/' + project + '/role' _rolesdict = self._get_json(path) rolesdict = {} for k, v in _...
Get a role Resource.
def project_role(self, project, id): """Get a role Resource. :param project: ID or key of the project to get the role from :param id: ID of the role to get """ if isinstance(id, Number): id = "%s" % id return self._find_for_resource(Role, (project, id))
Get a list of resolution Resources from the server.
def resolutions(self): """Get a list of resolution Resources from the server. :rtype: List[Resolution] """ r_json = self._get_json('resolution') resolutions = [Resolution( self._options, self._session, raw_res_json) for raw_res_json in r_json] return resolut...
Get a: class: ~jira. client. ResultList of issue Resources matching a JQL search string.
def search_issues(self, jql_str, startAt=0, maxResults=50, validate_query=True, fields=None, expand=None, json_result=None, ): """Get a ...
Get a dict of server information for this JIRA instance.: rtype: Dict [ str Any ]
def server_info(self): """Get a dict of server information for this JIRA instance. :rtype: Dict[str, Any] """ retry = 0 j = self._get_json('serverInfo') while not j and retry < 3: logging.warning("Bug https://jira.atlassian.com/browse/JRA-59676 trying again......
Get a list of status Resources from the server.
def statuses(self): """Get a list of status Resources from the server. :rtype: List[Status] """ r_json = self._get_json('status') statuses = [Status(self._options, self._session, raw_stat_json) for raw_stat_json in r_json] return statuses
Get a list of status category Resources from the server.
def statuscategories(self): """Get a list of status category Resources from the server. :rtype: List[StatusCategory] """ r_json = self._get_json('statuscategory') statuscategories = [StatusCategory(self._options, self._session, raw_stat_json) for raw_...
Get a user Resource from the server.
def user(self, id, expand=None): """Get a user Resource from the server. :param id: ID of the user to get :param id: str :param expand: Extra information to fetch inside each resource :type expand: Optional[Any] :rtype: User """ user = User(self._options...
Get a list of user Resources that match the search string and can be assigned issues for projects.
def search_assignable_users_for_projects(self, username, projectKeys, startAt=0, maxResults=50): """Get a list of user Resources that match the search string and can be assigned issues for projects. :param username: A string to match usernames against :type username: str :param projectK...
Get a list of user Resources that match the search string for assigning or creating issues.
def search_assignable_users_for_issues(self, username, project=None, issueKey=None, expand=None, startAt=...
Register an image file as a user avatar.
def create_temp_user_avatar(self, user, filename, size, avatar_img, contentType=None, auto_confirm=False, ...
Confirm the temporary avatar image previously uploaded with the specified cropping.
def confirm_user_avatar(self, user, cropping_properties): """Confirm the temporary avatar image previously uploaded with the specified cropping. After a successful registry with :py:meth:`create_temp_user_avatar`, use this method to confirm the avatar for use. The final avatar can be a subarea ...
Set a user s avatar.
def set_user_avatar(self, username, avatar): """Set a user's avatar. :param username: the user to set the avatar for :param avatar: ID of the avatar to set """ self._set_avatar( {'username': username}, self._get_url('user/avatar'), avatar)
Delete a user s avatar.
def delete_user_avatar(self, username, avatar): """Delete a user's avatar. :param username: the user to delete the avatar from :param avatar: ID of the avatar to remove """ params = {'username': username} url = self._get_url('user/avatar/' + avatar) return self._...
Get a list of user Resources that match the specified search string.
def search_users(self, user, startAt=0, maxResults=50, includeActive=True, includeInactive=False): """Get a list of user Resources that match the specified search string. :param user: a string to match usernames, name or email against. :type user: str :param startAt: index of the first ...
Get a list of user Resources that match a username string and have browse permission for the issue or project.
def search_allowed_users_for_issue(self, user, issueKey=None, projectKey=None, startAt=0, maxResults=50): """Get a list of user Resources that match a username string and have browse permission for the issue or project. :param user: a string to match usernames against. :type user: str :...
Create a version in a project and return a Resource for it.
def create_version(self, name, project, description=None, releaseDate=None, startDate=None, archived=False, released=False, ): "...
Move a version within a project s ordered version list and return a new version Resource for it.
def move_version(self, id, after=None, position=None): """Move a version within a project's ordered version list and return a new version Resource for it. One, but not both, of ``after`` and ``position`` must be specified. :param id: ID of the version to move :param after: the self att...
Get a version Resource.
def version(self, id, expand=None): """Get a version Resource. :param id: ID of the version to get :type id: str :param expand: extra information to fetch inside each resource :type expand: Optional[Any] :rtype: Version """ version = Version(self._option...
Get a dict of the current authenticated user s session information.
def session(self, auth=None): """Get a dict of the current authenticated user's session information. :param auth: Tuple of username and password. :type auth: Optional[Tuple[str,str]] :rtype: User """ url = '{server}{auth_url}'.format(**self._options) if isinst...
Destroy the user s current WebSudo session.
def kill_websudo(self): """Destroy the user's current WebSudo session. Works only for non-cloud deployments, for others does nothing. :rtype: Optional[Any] """ if self.deploymentType != 'Cloud': url = self._options['server'] + '/rest/auth/1/websudo' retu...
Creates a basic http session.
def _create_http_basic_session(self, username, password, timeout=None): """ Creates a basic http session. :param username: Username for the session :type username: str :param password: Password for the username :type password: str :param timeout: If set determines the ti...
Returns the full url based on JIRA base url and the path provided
def _get_url(self, path, base=JIRA_BASE_URL): """ Returns the full url based on JIRA base url and the path provided :param path: The subpath desired. :type path: str :param base: The base url which should be prepended to the path :type base: Optional[str] :return Fully ...
Get the json for a given path and params.
def _get_json(self, path, params=None, base=JIRA_BASE_URL, ): """Get the json for a given path and params. :param path: The subpath required :type path: str :param params: Parameters to filter the json query. ...
Get the MIME type for a given stream of bytes
def _get_mime_type(self, buff): """Get the MIME type for a given stream of bytes :param buff: Stream of bytes :type buff: bytes :rtype: str """ if self._magic is not None: return self._magic.id_buffer(buff) else: try: ret...
Rename a JIRA user.
def rename_user(self, old_user, new_user): """Rename a JIRA user. :param old_user: Old username login :type old_user: str :param new_user: New username login :type new_user: str """ if self._version > (6, 0, 0): url = self._options['server'] + '/rest...
Deletes a JIRA User.
def delete_user(self, username): """Deletes a JIRA User. :param username: Username to delete :type username: str :return: Success of user deletion :rtype: bool """ url = self._options['server'] + '/rest/api/latest/user/?username=%s' % username r = sel...
Disable/ deactivate the user.
def deactivate_user(self, username): """Disable/deactivate the user. :param username: User to be deactivated. :type username: str :rtype: Union[str, int] """ if self.deploymentType == 'Cloud': # Disabling users now needs cookie auth in the Cloud - see https:...
Start jira re - indexing. Returns True if reindexing is in progress or not needed or False.
def reindex(self, force=False, background=True): """Start jira re-indexing. Returns True if reindexing is in progress or not needed, or False. If you call reindex() without any parameters it will perform a background reindex only if JIRA thinks it should do it. :param force: reindex even if JI...
Will call jira export to backup as zipped xml. Returning with success does not mean that the backup process finished.
def backup(self, filename='backup.zip', attachments=False): """Will call jira export to backup as zipped xml. Returning with success does not mean that the backup process finished.""" if self.deploymentType == 'Cloud': url = self._options['server'] + '/rest/backup/1/export/runbackup' ...
Return status of cloud backup as a dict.
def backup_progress(self): """Return status of cloud backup as a dict. Is there a way to get progress for Server version? """ epoch_time = int(time.time() * 1000) if self.deploymentType == 'Cloud': url = self._options['server'] + '/rest/obm/1.0/getprogress?_=%i' % ep...
Return boolean based on alternativePercentage and size returned from backup_progress ( cloud only ).
def backup_complete(self): """Return boolean based on 'alternativePercentage' and 'size' returned from backup_progress (cloud only).""" if self.deploymentType != 'Cloud': logging.warning( 'This functionality is not available in Server version') return None ...
Download backup file from WebDAV ( cloud only ).
def backup_download(self, filename=None): """Download backup file from WebDAV (cloud only).""" if self.deploymentType != 'Cloud': logging.warning( 'This functionality is not available in Server version') return None remote_file = self.backup_progress()['fi...
Returns the username of the current user.
def current_user(self): """Returns the username of the current user. :rtype: str """ if not hasattr(self, '_serverInfo') or 'username' not in self._serverInfo: url = self._get_url('serverInfo') r = self._session.get(url, headers=self._options['headers']) ...
Delete project from Jira.
def delete_project(self, pid): """Delete project from Jira. :param pid: JIRA projectID or Project or slug :type pid: str :return: True if project was deleted :rtype: bool :raises JIRAError: If project not found or not enough permissions :raises ValueError: If pi...
Create a project with the specified parameters.
def create_project(self, key, name=None, assignee=None, type="Software", template_name=None): """Create a project with the specified parameters. :param key: Mandatory. Must match JIRA project key requirements, usually only 2-10 uppercase characters. :type: str :param name: If not specif...
Create a new JIRA user.
def add_user(self, username, email, directoryId=1, password=None, fullname=None, notify=False, active=True, ignore_existing=False, application_keys=None, ...
Add a user to an existing group.
def add_user_to_group(self, username, group): """Add a user to an existing group. :param username: Username that will be added to specified group. :type username: str :param group: Group that the user will be added to. :type group: str :return: json response from Jira s...
Remove a user from a group.
def remove_user_from_group(self, username, groupname): """Remove a user from a group. :param username: The user to remove from the group. :param groupname: The group that the user will be removed from. """ url = self._options['server'] + '/rest/api/latest/group/user' x =...
Get a list of board resources.
def boards(self, startAt=0, maxResults=50, type=None, name=None, projectKeyOrID=None): """Get a list of board resources. :param startAt: The starting index of the returned boards. Base index: 0. :param maxResults: The maximum number of boards to return per page. Default: 50 :param type:...
Get a list of sprint GreenHopperResources.
def sprints(self, board_id, extended=False, startAt=0, maxResults=50, state=None): """Get a list of sprint GreenHopperResources. :param board_id: the board to get sprints from :param extended: Used only by old GreenHopper API to fetch additional information like startDate, endDate, ...
Return the total incompleted points this sprint.
def incompletedIssuesEstimateSum(self, board_id, sprint_id): """Return the total incompleted points this sprint.""" return self._get_json('rapid/charts/sprintreport?rapidViewId=%s&sprintId=%s' % (board_id, sprint_id), base=self.AGILE_BASE_URL)['contents']['incompletedIssues...
Return the completed issues for the sprint.
def removed_issues(self, board_id, sprint_id): """Return the completed issues for the sprint.""" r_json = self._get_json('rapid/charts/sprintreport?rapidViewId=%s&sprintId=%s' % (board_id, sprint_id), base=self.AGILE_BASE_URL) issues = [Issue(self._options, self._...
Return the total incompleted points this sprint.
def removedIssuesEstimateSum(self, board_id, sprint_id): """Return the total incompleted points this sprint.""" return self._get_json('rapid/charts/sprintreport?rapidViewId=%s&sprintId=%s' % (board_id, sprint_id), base=self.AGILE_BASE_URL)['contents']['puntedIssuesEstimateS...
Return the information about a sprint.
def sprint_info(self, board_id, sprint_id): """Return the information about a sprint. :param board_id: the board retrieving issues from. Deprecated and ignored. :param sprint_id: the sprint retrieving issues from """ sprint = Sprint(self._options, self._session) sprint.f...
Return the information about a sprint.
def sprint(self, id): """Return the information about a sprint. :param sprint_id: the sprint retrieving issues from :type sprint_id: int :rtype: :class:`~jira.resources.Sprint` """ sprint = Sprint(self._options, self._session) sprint.find(id) return spr...
Delete an agile board.
def delete_board(self, id): """Delete an agile board.""" board = Board(self._options, self._session, raw={'id': id}) board.delete()
Create a new board for the project_ids.
def create_board(self, name, project_ids, preset="scrum", location_type='user', location_id=None): """Create a new board for the ``project_ids``. :param name: name of the board :type name: str :param project_ids: the projects to create the board in :type pro...
Create a new sprint for the board_id.
def create_sprint(self, name, board_id, startDate=None, endDate=None): """Create a new sprint for the ``board_id``. :param name: Name of the sprint :type name: str :param board_id: Which board the sprint should be assigned. :type board_id: int :param startDate: Start dat...
Add the issues in issue_keys to the sprint_id.
def add_issues_to_sprint(self, sprint_id, issue_keys): """Add the issues in ``issue_keys`` to the ``sprint_id``. The sprint must be started but not completed. If a sprint was completed, then have to also edit the history of the issue so that it was added to the sprint before it was com...
Add the issues in issue_keys to the epic_id.
def add_issues_to_epic(self, epic_id, issue_keys, ignore_epics=True): """Add the issues in ``issue_keys`` to the ``epic_id``. :param epic_id: The ID for the epic where issues should be added. :type epic_id: int :param issue_keys: The issues to add to the epic :type issue_keys: s...
Rank an issue before another using the default Ranking field the one named Rank.
def rank(self, issue, next_issue): """Rank an issue before another using the default Ranking field, the one named 'Rank'. :param issue: issue key of the issue to be ranked before the second one. :param next_issue: issue key of the second issue. """ if not self._rank: ...
Convert a dictionary into a Jira Resource object.
def dict2resource(raw, top=None, options=None, session=None): """Convert a dictionary into a Jira Resource object. Recursively walks a dict structure, transforming the properties into attributes on a new ``Resource`` object of the appropriate type (if a ``self`` link is present) or a ``PropertyHolder``...
Finds a resource based on the input parameters.
def find(self, id, params=None, ): """Finds a resource based on the input parameters. :type id: Union[Tuple[str, str], int, str] :type params: Optional[Dict[str, str]] """ if params is None: params = {} if isinstance(...
Gets the url for the specified path.
def _get_url(self, path): """ Gets the url for the specified path. :type path: str :rtype: str """ options = self._options.copy() options.update({'path': path}) return self._base_url.format(**options)
Update this resource on the server.
def update(self, fields=None, async_=None, jira=None, notify=True, **kwargs): """Update this resource on the server. Keyword arguments are marshalled into a dict before being sent. If this resource doesn't support ``PUT``, a :py:exc:`.JIRAError` will be raised; subclasses that specialize this m...
Delete this resource from the server passing the specified query parameters.
def delete(self, params=None): """Delete this resource from the server, passing the specified query parameters. If this resource doesn't support ``DELETE``, a :py:exc:`.JIRAError` will be raised; subclasses that specialize this method will only raise errors in case of user error. ...
Load a resource.
def _load(self, url, headers=CaseInsensitiveDict(), params=None, path=None, ): """ Load a resource. :type url: str :type headers: CaseInsensitiveDict :type params: Optional[Dict[str,str]] :type path: Optional[...
Parse a raw dictionary to create a resource.
def _parse_raw(self, raw): """Parse a raw dictionary to create a resource. :type raw: Dict[str, Any] """ self.raw = raw if not raw: raise NotImplementedError("We cannot instantiate empty resources: %s" % raw) dict2resource(raw, self, self._options, self._sess...
Return the file content as a string.
def get(self): """Return the file content as a string.""" r = self._session.get(self.content, headers={'Accept': '*/*'}) return r.content
Return the file content as an iterable stream.
def iter_content(self, chunk_size=1024): """Return the file content as an iterable stream.""" r = self._session.get(self.content, stream=True) return r.iter_content(chunk_size)
Delete this component from the server.
def delete(self, moveIssuesTo=None): """Delete this component from the server. :param moveIssuesTo: the name of the component to which to move any issues this component is applied """ params = {} if moveIssuesTo is not None: params['moveIssuesTo'] = moveIssuesTo ...
Update this issue on the server.
def update(self, fields=None, update=None, async_=None, jira=None, notify=True, **fieldargs): """Update this issue on the server. Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value is treated as the intended value for that field -- if the ...
Add a value to a field that supports multiple values without resetting the existing values.
def add_field_value(self, field, value): """Add a value to a field that supports multiple values, without resetting the existing values. This should work with: labels, multiple checkbox lists, multiple select :param field: The field name :param value: The field's value :type f...
Delete this issue from the server.
def delete(self, deleteSubtasks=False): """Delete this issue from the server. :param deleteSubtasks: if the issue has subtasks, this argument must be set to true for the call to succeed. :type deleteSubtasks: bool """ super(Issue, self).delete(params={'deleteSubtasks': deleteSu...
Update a RemoteLink. object is required.
def update(self, object, globalId=None, application=None, relationship=None): """Update a RemoteLink. 'object' is required. For definitions of the allowable fields for 'object' and the keyword arguments 'globalId', 'application' and 'relationship', see https://developer.atlassian.com/display/JI...
Delete this worklog entry from its associated issue.
def delete(self, adjustEstimate=None, newEstimate=None, increaseBy=None): """Delete this worklog entry from its associated issue. :param adjustEstimate: one of ``new``, ``leave``, ``manual`` or ``auto``. ``auto`` is the default and adjusts the estimate automatically. ``leave`` l...
Add the specified users or groups to this project role. One of users or groups must be specified.
def update(self, users=None, groups=None): """Add the specified users or groups to this project role. One of ``users`` or ``groups`` must be specified. :param users: a user or users to add to the role :type users: string, list or tuple :param groups: a group or groups to add to the role...
Add the specified users or groups to this project role.
def add_user(self, users=None, groups=None): """Add the specified users or groups to this project role. One of ``users`` or ``groups`` must be specified. :param users: a user or users to add to the role :type users: string, list or tuple :param groups: a group or groups to add ...
Delete this project version from the server.
def delete(self, moveFixIssuesTo=None, moveAffectedIssuesTo=None): """Delete this project version from the server. If neither of the arguments are specified, the version is removed from all issues it is attached to. :param moveFixIssuesTo: in issues for which this version is a fix ...
Update this project version from the server. It is prior used to archive versions.
def update(self, **args): """Update this project version from the server. It is prior used to archive versions.""" data = {} for field in args: data[field] = args[field] super(Version, self).update(**data)
Return a JIRA object by loading the connection details from the config. ini file.
def get_jira(profile=None, url="http://localhost:2990", username="admin", password="admin", appid=None, autofix=False, verify=True): """Return a JIRA object by loading the connection details from the `config.ini` file. :param profile: The name of the section from config.ini file that stores server config url/u...
为一个 BaseRoBot 生成 Flask view。
def make_view(robot): """ 为一个 BaseRoBot 生成 Flask view。 Usage :: from werobot import WeRoBot robot = WeRoBot(token='token') @robot.handler def hello(message): return 'Hello World!' from flask import Flask from werobot.contrib.flask import make...
在一个 Python 文件中读取配置。
def from_pyfile(self, filename): """ 在一个 Python 文件中读取配置。 :param filename: 配置文件的文件名 :return: 如果读取成功,返回 ``True``,如果失败,会抛出错误异常 """ d = types.ModuleType('config') d.__file__ = filename with open(filename) as config_file: exec(compile(config_file.r...
为一个 BaseRoBot 生成 Tornado Handler。
def make_handler(robot): """ 为一个 BaseRoBot 生成 Tornado Handler。 Usage :: import tornado.ioloop import tornado.web from werobot import WeRoBot from tornado_werobot import make_handler robot = WeRoBot(token='token') @robot.handler def hello(message):...
根据 id 获取数据。
def get(self, id): """ 根据 id 获取数据。 :param id: 要获取的数据的 id :return: 返回取到的数据,如果是空则返回一个空的 ``dict`` 对象 """ document = self._get_document(id) if document: session_json = document["session"] return json_loads(session_json) return {}
根据 id 写入数据。
def set(self, id, value): """ 根据 id 写入数据。 :param id: 要写入的 id :param value: 要写入的数据,可以是一个 ``dict`` 对象 """ session = json_dumps(value) self.collection.replace_one( { "wechat_id": id }, { "wechat_id": id...
获取 Access Token。
def grant_token(self): """ 获取 Access Token。 :return: 返回的 JSON 数据包 """ return self.get( url="https://api.weixin.qq.com/cgi-bin/token", params={ "grant_type": "client_credential", "appid": self.appid, "secret"...
判断现有的token是否过期。 用户需要多进程或者多机部署可以手动重写这个函数 来自定义token的存储,刷新策略。
def get_access_token(self): """ 判断现有的token是否过期。 用户需要多进程或者多机部署可以手动重写这个函数 来自定义token的存储,刷新策略。 :return: 返回token """ if self._token: now = time.time() if self.token_expires_at - now > 60: return self._token json = self.g...
创建个性化菜单::
def create_custom_menu(self, menu_data, matchrule): """ 创建个性化菜单:: button = [ { "type":"click", "name":"今日歌曲", "key":"V1001_TODAY_MUSIC" }, { "name":"菜单", ...
添加客服帐号。
def add_custom_service_account(self, account, nickname, password): """ 添加客服帐号。 :param account: 客服账号的用户名 :param nickname: 客服账号的昵称 :param password: 客服账号的密码 :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/customservice/...
修改客服帐号。
def update_custom_service_account(self, account, nickname, password): """ 修改客服帐号。 :param account: 客服账号的用户名 :param nickname: 客服账号的昵称 :param password: 客服账号的密码 :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/customservi...
删除客服帐号。
def delete_custom_service_account(self, account, nickname, password): """ 删除客服帐号。 :param account: 客服账号的用户名 :param nickname: 客服账号的昵称 :param password: 客服账号的密码 :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/customservi...
设置客服帐号的头像。
def upload_custom_service_account_avatar(self, account, avatar): """ 设置客服帐号的头像。 :param account: 客服账号的用户名 :param avatar: 头像文件,必须是 jpg 格式 :return: 返回的 JSON 数据包 """ return self.post( url= "http://api.weixin.qq.com/customservice/kfaccount/uplo...
下载临时多媒体文件。
def download_media(self, media_id): """ 下载临时多媒体文件。 :param media_id: 媒体文件 ID :return: requests 的 Response 实例 """ return requests.get( url="https://api.weixin.qq.com/cgi-bin/media/get", params={ "access_token": self.token, ...
上传图文消息内的图片。
def upload_news_picture(self, file): """ 上传图文消息内的图片。 :param file: 要上传的文件,一个 File-object :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/cgi-bin/media/uploadimg", params={"access_token": self.token}, files={"m...
上传其他类型永久素材。
def upload_permanent_media(self, media_type, media_file): """ 上传其他类型永久素材。 :param media_type: 媒体文件类型,分别有图片(image)、语音(voice)和缩略图(thumb) :param media_file: 要上传的文件,一个 File-object :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/c...
上传永久视频。
def upload_permanent_video(self, title, introduction, video): """ 上传永久视频。 :param title: 视频素材的标题 :param introduction: 视频素材的描述 :param video: 要上传的视频,一个 File-object :return: requests 的 Response 实例 """ return requests.post( url="https://api.weixin....
获取永久素材。
def download_permanent_media(self, media_id): """ 获取永久素材。 :param media_id: 媒体文件 ID :return: requests 的 Response 实例 """ return requests.post( url="https://api.weixin.qq.com/cgi-bin/material/get_material", params={"access_token": self.token}, ...
获取素材列表。
def get_media_list(self, media_type, offset, count): """ 获取素材列表。 :param media_type: 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news) :param offset: 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 :param count: 返回素材的数量,取值在1到20之间 :return: 返回的 JSON 数据包 """ return self.post( ...
创建分组。
def create_group(self, name): """ 创建分组。 :param name: 分组名字(30个字符以内) :return: 返回的 JSON 数据包 """ name = to_text(name) return self.post( url="https://api.weixin.qq.com/cgi-bin/groups/create", data={"group": { "name": name ...
修改分组名。
def update_group(self, group_id, name): """ 修改分组名。 :param group_id: 分组 ID,由微信分配 :param name: 分组名字(30个字符以内) :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/cgi-bin/groups/update", data={"group": { ...
批量移动用户分组。
def move_users(self, user_id_list, group_id): """ 批量移动用户分组。 :param user_id_list: 用户 ID 的列表(长度不能超过50) :param group_id: 分组 ID :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/cgi-bin/groups/members/batchupdate", dat...
设置备注名。
def remark_user(self, user_id, remark): """ 设置备注名。 :param user_id: 设置备注名的用户 ID :param remark: 新的备注名,长度必须小于30字符 :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/cgi-bin/user/info/updateremark", data={ ...
获取用户基本信息。
def get_user_info(self, user_id, lang="zh_CN"): """ 获取用户基本信息。 :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param lang: 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 :return: 返回的 JSON 数据包 """ return self.get( url="https://api.weixin.qq.com/cgi-bin/user/info...
批量获取用户基本信息。
def get_users_info(self, user_id_list, lang="zh_CN"): """ 批量获取用户基本信息。 :param user_id_list: 用户 ID 的列表 :param lang: 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 :return: 返回的 JSON 数据包 """ return self.post( url="https://api.weixin.qq.com/cgi-bin/user/info/batchget"...
获取关注者列表 详情请参考 http:// mp. weixin. qq. com/ wiki/ index. php?title = 获取关注者列表
def get_followers(self, first_user_id=None): """ 获取关注者列表 详情请参考 http://mp.weixin.qq.com/wiki/index.php?title=获取关注者列表 :param first_user_id: 可选。第一个拉取的OPENID,不填默认从头开始拉取 :return: 返回的 JSON 数据包 """ params = {"access_token": self.token} if first_user_id: ...