# ✨朋友圈类 - chatautox

# ✨朋友圈类

## MomentsWnd

**朋友圈窗口**对象，即的是朋友圈的窗口对象，提供对朋友圈窗口的各种操作，如获取朋友圈内容、刷新、关闭等功能。

```python
from chatautox import WeChat

wx = WeChat()
pyq = wx.Moments()   # 打开朋友圈并获取朋友圈窗口对象（如果为None则说明你没开启朋友圈，需要在手机端设置）
```

### ✨GetMoments

**获取朋友圈内容**

```python
# 获取当前页面的朋友圈内容
moments = pyq.GetMoments()

# 通过`next_page`参数获取下一页的朋友圈内容
moments = pyq.GetMoments(next_page=True)
```

**参数**：

| 参数         | 类型   | 默认值   | 说明                                    |
| ---------- | ---- | ----- | ------------------------------------- |
| next\_page | bool | False | 是否翻页后再获取                              |
| speed1     | int  | 3     | 翻页时的滚动速度，根据自己的情况进行调整，建议3-10自行调整       |
| speed2     | int  | 1     | 翻页最后时的速度，避免翻页过多导致遗漏所以一般比speed1慢，建议1-3 |

**返回值**：List\[[Moments](#Moments)]

### ✨Refresh

**刷新朋友圈**

```text
pyq.Refresh()
```

### ✨close

**关闭朋友圈**

```text
pyq.Close()
```

### ✨Publish

**发表朋友圈**

**参数**：

| 参数              | 类型   | 默认值  | 说明                        |
| --------------- | ---- | ---- | ------------------------- |
| text            | str  | 必填   | 朋友圈内容                     |
| media\_files    | list | None | 图片/视频文件路径列表，为None时只发表文字内容 |
| privacy\_config | dict | None | 是否翻页后再获取                  |

```python
text = '''oh
今天天气真好
适合出去走走

嘿嘿~
'''
media_files = [
    r"D:\Images\Pictures\1.png",
    r"D:\Images\Pictures\2.png",
    r"D:\Images\Pictures\3.png",
]
privacy_config = {
    'privacy': '白名单',    # 设置为黑名单模式
    'tags': ['家人','朋友']      # 白名单为仅这些标签能看，黑名单为屏蔽这些标签的人
}
# privacy_config = {}     # 公开发布，没有任何权限设置
pyq.Publish(text, media_files, privacy_config)
```

## Moments

**朋友圈内容**对象，即的是朋友圈的内容对象，提供对朋友圈的各种操作，如获取朋友圈内容、点赞、评论等功能。

```python
# 获取朋友圈对象
moments = pyq.GetMoments()

# 获取第一条朋友圈
moment = moments[0]
```

### ✨获取朋友圈内容

```text
# 获取朋友圈内容
moment.content
```

### ✨Like

**点赞朋友圈**

**参数**：

| 参数   | 类型   | 默认值  | 说明              |
| ---- | ---- | ---- | --------------- |
| like | bool | True | True点赞，False取消赞 |

```python
# 点赞
moment.Like()
# 取消赞
moment.Like(False)
```

**返回值**：无

### ✨Comment

**评论朋友圈**

**参数**：

| 参数   | 类型  | 默认值 | 说明   |
| ---- | --- | --- | ---- |
| text | str | 必填  | 评论内容 |

```python
# 评论
moment.Comment('评论内容')
```

**返回值**：无

<div class="doc-page-nav"><a class="doc-page-nav__prev" href="/docs/class/message">上一页 Message类</a><a class="doc-page-nav__next" href="/docs/class/other">下一页 其他类/方法</a></div>
