添加获取公众号列表

This commit is contained in:
evilbeast 2022-09-05 16:39:18 +08:00
parent 138026a1e4
commit 254123f640
6 changed files with 47 additions and 3 deletions

View File

@ -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
View 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()

View File

@ -1,4 +1,4 @@
VERSION = '0.1.7'
VERSION = '0.1.8'
LOG_LEVEL = "DEBUG"
LOG_KEY = 'NTCHAT_LOG'

View File

@ -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

View File

@ -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):
"""
获取联系人详细信息

View File

@ -194,7 +194,7 @@ extension.extra_compile_cpp_args = extra_compile_cpp_args[target_os]
setup(
name='ntchat',
version='0.1.7',
version='0.1.8',
description='About Conversational RPA SDK for Chatbot Makers',
long_description="",
long_description_content_type='text/markdown',