mirror of
https://github.com/smallevilbeast/ntchat.git
synced 2025-05-23 03:37:37 +08:00
添加获取公众号列表
This commit is contained in:
parent
138026a1e4
commit
254123f640
|
@ -1,6 +1,6 @@
|
|||
<h1 align="center">NtChat</h1>
|
||||
<p align="center">
|
||||
<a href="https://github.com/smallevilbeast/ntchat/releases"><img src="https://img.shields.io/badge/release-0.1.7-blue.svg?" alt="release"></a>
|
||||
<a href="https://github.com/smallevilbeast/ntchat/releases"><img src="https://img.shields.io/badge/release-0.1.8-blue.svg?" alt="release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-brightgreen.svg?" alt="License"></a>
|
||||
</p>
|
||||
|
||||
|
|
35
examples/get_publics.py
Normal file
35
examples/get_publics.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import time
|
||||
import ntchat
|
||||
|
||||
|
||||
def version_tuple(v):
|
||||
return tuple(map(int, (v.split("."))))
|
||||
|
||||
|
||||
if version_tuple(ntchat.__version__) < version_tuple('0.1.8'):
|
||||
print("error: ntchat version required 0.1.8, use `pip install -U ntchat` to upgrade")
|
||||
sys.exit()
|
||||
|
||||
wechat = ntchat.WeChat()
|
||||
|
||||
# 打开pc微信, smart: 是否管理已经登录的微信
|
||||
wechat.open(smart=True)
|
||||
|
||||
# 等待登录
|
||||
wechat.wait_login()
|
||||
|
||||
# 获取群列表并输出
|
||||
rooms = wechat.get_publics()
|
||||
|
||||
print("公众号列表: ")
|
||||
print(rooms)
|
||||
|
||||
# 以下是为了让程序不结束,如果有用于PyQt等有主循环消息的框架,可以去除下面代码
|
||||
try:
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
except KeyboardInterrupt:
|
||||
ntchat.exit_()
|
||||
sys.exit()
|
|
@ -1,4 +1,4 @@
|
|||
VERSION = '0.1.7'
|
||||
VERSION = '0.1.8'
|
||||
|
||||
LOG_LEVEL = "DEBUG"
|
||||
LOG_KEY = 'NTCHAT_LOG'
|
||||
|
|
|
@ -7,6 +7,9 @@ MT_GET_CONTACTS_MSG = 11030
|
|||
# 获取所有的群
|
||||
MT_GET_ROOMS_MSG = 11031
|
||||
|
||||
# 获取公众号列表
|
||||
MT_GET_PUBLICS_MSG = 11033
|
||||
|
||||
# 获取指定的群成员
|
||||
MT_GET_ROOM_MEMBERS_MSG = 11032
|
||||
|
||||
|
|
|
@ -181,6 +181,12 @@ class WeChat:
|
|||
"""
|
||||
return self.__send_sync(send_type.MT_GET_CONTACTS_MSG)
|
||||
|
||||
def get_publics(self):
|
||||
"""
|
||||
获取关注公众号列表
|
||||
"""
|
||||
return self.__send_sync(send_type.MT_GET_PUBLICS_MSG)
|
||||
|
||||
def get_contact_detail(self, wxid):
|
||||
"""
|
||||
获取联系人详细信息
|
||||
|
|
Loading…
Reference in New Issue
Block a user