调整代码
This commit is contained in:
0
gewechat/response/model/__init__.py
Normal file
0
gewechat/response/model/__init__.py
Normal file
0
gewechat/response/model/contacts/__init__.py
Normal file
0
gewechat/response/model/contacts/__init__.py
Normal file
31
gewechat/response/model/contacts/brief_info.py
Normal file
31
gewechat/response/model/contacts/brief_info.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List
|
||||
|
||||
@dataclass
|
||||
class Datum:
|
||||
alias: Optional[str] = None
|
||||
big_head_img_url: Optional[str] = None
|
||||
card_img_url: Optional[str] = None
|
||||
city: Optional[str] = None
|
||||
country: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
label_list: Optional[str] = None
|
||||
nick_name: Optional[str] = None
|
||||
phone_num_list: Optional[List[str]] = None
|
||||
province: Optional[str] = None
|
||||
py_initial: Optional[str] = None
|
||||
quan_pin: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
remark_py_initial: Optional[str] = None
|
||||
remark_quan_pin: Optional[str] = None
|
||||
sex: Optional[int] = None
|
||||
signature: Optional[str] = None
|
||||
small_head_img_url: Optional[str] = None
|
||||
sns_bg_img: Optional[str] = None
|
||||
user_name: Optional[str] = None
|
||||
|
||||
@dataclass
|
||||
class BriefInfo:
|
||||
data: List[Datum]
|
||||
msg: str
|
||||
ret: int
|
||||
19
gewechat/response/model/contacts/contacts_list.py
Normal file
19
gewechat/response/model/contacts/contacts_list.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
|
||||
@dataclass
|
||||
class Data:
|
||||
"""保存到通讯录中群聊的ID"""
|
||||
chatrooms: List[str]
|
||||
"""好友的wxid"""
|
||||
friends: List[str]
|
||||
"""关注的公众号ID"""
|
||||
ghs: List[str]
|
||||
|
||||
|
||||
@dataclass
|
||||
class ContactsList:
|
||||
data: Data
|
||||
msg: str
|
||||
ret: int
|
||||
53
gewechat/response/model/contacts/detail_info.py
Normal file
53
gewechat/response/model/contacts/detail_info.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class Datum:
|
||||
"""好友的微信号"""
|
||||
alias: str
|
||||
"""大尺寸头像链接"""
|
||||
big_head_img_url: str
|
||||
"""好友描述的图片链接"""
|
||||
card_img_url: None
|
||||
"""城市"""
|
||||
city: None
|
||||
"""国家"""
|
||||
country: str
|
||||
"""好友的描述"""
|
||||
description: None
|
||||
"""好友的标签ID"""
|
||||
label_list: None
|
||||
"""好友的昵称"""
|
||||
nick_name: str
|
||||
"""好友的手机号码"""
|
||||
phone_num_list: None
|
||||
"""省份"""
|
||||
province: None
|
||||
"""好友昵称的拼音首字母"""
|
||||
py_initial: None
|
||||
"""好友昵称的全拼"""
|
||||
quan_pin: str
|
||||
"""好友备注"""
|
||||
remark: None
|
||||
"""好友备注的拼音首字母"""
|
||||
remark_py_initial: None
|
||||
"""好友备注的全拼"""
|
||||
remark_quan_pin: None
|
||||
"""好友的性别"""
|
||||
sex: Optional[int] = None
|
||||
"""好友的签名"""
|
||||
signature: Optional[str] = None
|
||||
"""小尺寸头像链接"""
|
||||
small_head_img_url: Optional[str] = None
|
||||
"""朋友圈背景图链接"""
|
||||
sns_bg_img: Optional[str] = None
|
||||
"""好友的wxid"""
|
||||
user_name: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class ContactsDetailInfo:
|
||||
data: List[Datum]
|
||||
msg: str
|
||||
ret: int
|
||||
0
gewechat/response/model/group/__init__.py
Normal file
0
gewechat/response/model/group/__init__.py
Normal file
54
gewechat/response/model/group/chatroom_info.py
Normal file
54
gewechat/response/model/group/chatroom_info.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class MemberList:
|
||||
"""大尺寸头像"""
|
||||
big_head_img_url: None
|
||||
"""在本群内的昵称"""
|
||||
display_name: None
|
||||
"""标识"""
|
||||
member_flag: int
|
||||
"""群成员的昵称"""
|
||||
nick_name: str
|
||||
"""小尺寸头像"""
|
||||
small_head_img_url: None
|
||||
"""群成员的wxid"""
|
||||
wxid: str
|
||||
"""邀请人的wxid"""
|
||||
inviter_user_name: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Data:
|
||||
"""群ID"""
|
||||
chatroom_id: str
|
||||
"""群消息是否提醒"""
|
||||
chat_room_notify: int
|
||||
"""群主的wxid"""
|
||||
chat_room_owner: str
|
||||
"""群成员列表"""
|
||||
member_list: List[MemberList]
|
||||
"""群名称"""
|
||||
nick_name: str
|
||||
"""群名称的拼音首字母"""
|
||||
py_initial: str
|
||||
"""群名称的全拼"""
|
||||
quan_pin: str
|
||||
"""群备注,仅自己可见"""
|
||||
remark: str
|
||||
"""群备注的拼音首字母"""
|
||||
remark_py_initial: str
|
||||
"""群备注的全拼"""
|
||||
remark_quan_pin: str
|
||||
sex: int
|
||||
"""群头像链接"""
|
||||
small_head_img_url: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChatroomInfo:
|
||||
data: Data
|
||||
msg: str
|
||||
ret: int
|
||||
61
gewechat/response/model/group/chatroom_member_detail.py
Normal file
61
gewechat/response/model/group/chatroom_member_detail.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class Datum:
|
||||
"""大尺寸头像"""
|
||||
big_head_img_url: str
|
||||
"""描述的图片链接"""
|
||||
card_img_url: None
|
||||
"""消息通知"""
|
||||
chat_room_notify: int
|
||||
"""国家"""
|
||||
country: str
|
||||
"""描述"""
|
||||
description: None
|
||||
"""好友的wxid"""
|
||||
friend_user_name: str
|
||||
"""群成员的昵称"""
|
||||
nick_name: str
|
||||
"""手机号码"""
|
||||
phone_num_list: List[str]
|
||||
"""群成员昵称的拼音首字母"""
|
||||
py_initial: str
|
||||
"""群成员昵称的全拼"""
|
||||
quan_pin: str
|
||||
"""性别"""
|
||||
sex: int
|
||||
"""小尺寸头像"""
|
||||
small_head_img_url: str
|
||||
"""朋友圈背景图链接"""
|
||||
sns_bg_img: str
|
||||
"""群成员的wxid"""
|
||||
user_name: str
|
||||
"""微信号"""
|
||||
alias: Optional[str] = None
|
||||
"""城市"""
|
||||
city: Optional[str] = None
|
||||
"""邀请人的wxid"""
|
||||
inviter_user_name: Optional[str] = None
|
||||
"""标签列表,多个英文逗号分隔"""
|
||||
label_list: Optional[str] = None
|
||||
"""标识"""
|
||||
member_flag: Optional[int] = None
|
||||
"""省份"""
|
||||
province: Optional[str] = None
|
||||
"""备注"""
|
||||
remark: Optional[str] = None
|
||||
"""备注的拼音首字母"""
|
||||
remark_py_initial: Optional[str] = None
|
||||
"""备注的全拼"""
|
||||
remark_quan_pin: Optional[str] = None
|
||||
"""签名"""
|
||||
signature: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChatroomMemberDetail:
|
||||
data: List[Datum]
|
||||
msg: str
|
||||
ret: int
|
||||
37
gewechat/response/model/group/chatroom_member_list.py
Normal file
37
gewechat/response/model/group/chatroom_member_list.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class MemberList:
|
||||
"""大尺寸头像"""
|
||||
big_head_img_url: str
|
||||
"""标识"""
|
||||
member_flag: int
|
||||
"""群成员昵称"""
|
||||
nick_name: str
|
||||
"""小尺寸头像"""
|
||||
small_head_img_url: str
|
||||
"""群成员的wxid"""
|
||||
wxid: str
|
||||
"""在本群内的昵称"""
|
||||
display_name: Optional[str] = None
|
||||
"""邀请人的wxid"""
|
||||
inviter_user_name: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Data:
|
||||
"""管理的wxid"""
|
||||
admin_wxid: None
|
||||
"""群主的wxid"""
|
||||
chatroom_owner: None
|
||||
"""群成员列表"""
|
||||
member_list: List[MemberList]
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChatroomMemberList:
|
||||
data: Data
|
||||
msg: str
|
||||
ret: int
|
||||
0
gewechat/response/model/personal/__init__.py
Normal file
0
gewechat/response/model/personal/__init__.py
Normal file
40
gewechat/response/model/personal/profile.py
Normal file
40
gewechat/response/model/personal/profile.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Data:
|
||||
"""微信号"""
|
||||
alias: str
|
||||
"""大尺寸头像"""
|
||||
big_head_img_url: str
|
||||
"""城市"""
|
||||
city: str
|
||||
"""国家"""
|
||||
country: str
|
||||
"""绑定的手机号"""
|
||||
mobile: str
|
||||
"""昵称"""
|
||||
nick_name: str
|
||||
"""省份"""
|
||||
province: str
|
||||
"""注册国家"""
|
||||
reg_country: str
|
||||
"""性别"""
|
||||
sex: int
|
||||
"""签名"""
|
||||
signature: str
|
||||
"""小尺寸头像"""
|
||||
small_head_img_url: str
|
||||
"""朋友圈背景图"""
|
||||
sns_bg_img: str
|
||||
"""uin"""
|
||||
uin: int
|
||||
"""微信ID"""
|
||||
wxid: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Profile:
|
||||
data: Data
|
||||
msg: str
|
||||
ret: int
|
||||
@@ -8,6 +8,7 @@ import xml.etree.ElementTree as ET
|
||||
|
||||
from gewechat.client import gewe_client
|
||||
from gewechat.response.gewe_resp import GeweResponse
|
||||
from gewechat.response.model.group.chatroom_member_detail import ChatroomMemberDetail
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
@@ -122,13 +123,14 @@ class GroupMemberChangePlugin(MessagePluginInterface):
|
||||
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
member_wxids = [wxid]
|
||||
profile = gewe_client.client.get_chatroom_member_detail(gewe_client.client.app_id, member_wxids)
|
||||
data = GeweResponse(profile).get_data()
|
||||
gewe_client.client.post_link(gewe_client.client.app_id, sender,
|
||||
title=f"👏欢迎 {nickname} 加入群聊!🎉",
|
||||
description=f"⌚时间:{now}\n",
|
||||
url="",
|
||||
thumb_url=data[0].get("BigHeadImgUrl", ""))
|
||||
profile: ChatroomMemberDetail = gewe_client.client.get_chatroom_member_detail(gewe_client.client.app_id,
|
||||
member_wxids)
|
||||
if profile.ret == 200:
|
||||
gewe_client.client.post_link(gewe_client.client.app_id, sender,
|
||||
title=f"👏欢迎 {nickname} 加入群聊!🎉",
|
||||
description=f"⌚时间:{now}\n",
|
||||
url="",
|
||||
thumb_url=profile.data[0].big_head_img_url)
|
||||
return True, "已发送进群欢迎语"
|
||||
return False, "无需执行"
|
||||
|
||||
|
||||
9
robot.py
9
robot.py
@@ -3,14 +3,13 @@ import logging
|
||||
import re
|
||||
import time
|
||||
|
||||
from gewechat_client import GewechatClient
|
||||
|
||||
from base.func_epic import is_friday, get_free
|
||||
|
||||
from base.func_news import News
|
||||
from configuration import Config
|
||||
from gewechat.call_back_message.message import WxMessage, MessageType
|
||||
from gewechat.client import gewe_client
|
||||
from gewechat.response.model.personal.profile import Profile
|
||||
from utils.json_converter import json_to_object
|
||||
from utils.wechat.message_to_db import MessageStorage
|
||||
from plugin_common.event_system import EventType, EventSystem
|
||||
@@ -63,11 +62,11 @@ class Robot(Job):
|
||||
self.contact_manager.set_contacts(self.allContacts)
|
||||
|
||||
# 获取个人信息
|
||||
obj = json_to_object(self.client.get_profile(self.app_id))
|
||||
if obj.data.wxid is None:
|
||||
profile: Profile = self.client.get_profile(self.app_id)
|
||||
if profile.data.wxid is None:
|
||||
self.LOG.info(f"获取个人信息失败,退出程序!")
|
||||
return
|
||||
self.wxid = obj.data.wxid
|
||||
self.wxid = profile.data.wxid
|
||||
|
||||
# 初始化消息工具类 - 使用联系人管理器
|
||||
self.message_util = MessageUtil()
|
||||
|
||||
Reference in New Issue
Block a user