如果用户在群里面了,则不发送邀请
This commit is contained in:
@@ -9,6 +9,7 @@ from plugin_common.message_plugin_interface import MessagePluginInterface
|
|||||||
from plugin_common.plugin_interface import PluginStatus
|
from plugin_common.plugin_interface import PluginStatus
|
||||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||||
from utils.robot_cmd.robot_command import GroupBotManager
|
from utils.robot_cmd.robot_command import GroupBotManager
|
||||||
|
from utils.wechat.contact_manager import ContactManager
|
||||||
|
|
||||||
|
|
||||||
class GroupAutoInvitePlugin(MessagePluginInterface):
|
class GroupAutoInvitePlugin(MessagePluginInterface):
|
||||||
@@ -124,7 +125,8 @@ class GroupAutoInvitePlugin(MessagePluginInterface):
|
|||||||
|
|
||||||
return False, "无法处理的消息"
|
return False, "无法处理的消息"
|
||||||
|
|
||||||
def _handle_config_command(self, content: str, sender: str, roomid: str, wcf: Wcf, gbm: GroupBotManager) -> Tuple[bool, Optional[str]]:
|
def _handle_config_command(self, content: str, sender: str, roomid: str, wcf: Wcf, gbm: GroupBotManager) -> Tuple[
|
||||||
|
bool, Optional[str]]:
|
||||||
"""处理配置命令"""
|
"""处理配置命令"""
|
||||||
# 检查是否为管理员
|
# 检查是否为管理员
|
||||||
admin_list = self.gbm.get_admin_list()
|
admin_list = self.gbm.get_admin_list()
|
||||||
@@ -141,7 +143,8 @@ class GroupAutoInvitePlugin(MessagePluginInterface):
|
|||||||
wcf.send_text(result, (roomid if roomid else sender), sender)
|
wcf.send_text(result, (roomid if roomid else sender), sender)
|
||||||
return True, "配置命令处理成功"
|
return True, "配置命令处理成功"
|
||||||
|
|
||||||
def _handle_join_request(self, key: str, sender: str, roomid: str, wcf: Wcf, gbm: GroupBotManager) -> Tuple[bool, Optional[str]]:
|
def _handle_join_request(self, key: str, sender: str, roomid: str, wcf: Wcf, gbm: GroupBotManager) -> Tuple[
|
||||||
|
bool, Optional[str]]:
|
||||||
"""处理加群请求"""
|
"""处理加群请求"""
|
||||||
try:
|
try:
|
||||||
# 获取对应的群ID
|
# 获取对应的群ID
|
||||||
@@ -151,7 +154,13 @@ class GroupAutoInvitePlugin(MessagePluginInterface):
|
|||||||
if isinstance(group_id, str) and "没有关联的群ID" in group_id:
|
if isinstance(group_id, str) and "没有关联的群ID" in group_id:
|
||||||
wcf.send_text(f"⚠️ 未找到关键词 '{key}' 对应的群聊", sender)
|
wcf.send_text(f"⚠️ 未找到关键词 '{key}' 对应的群聊", sender)
|
||||||
return True, "未找到群聊"
|
return True, "未找到群聊"
|
||||||
|
# 判断是否在群里面,如果在,则不添加
|
||||||
|
con = ContactManager.get_instance()
|
||||||
|
members = con.get_group_members(group_id)
|
||||||
|
# 如果在群里面,则不添加
|
||||||
|
if sender in members:
|
||||||
|
wcf.send_text(f"⚠️ 你已经在群聊中了,无需重复添加", sender)
|
||||||
|
return True, "你已经在群聊中了"
|
||||||
# 发送邀请
|
# 发送邀请
|
||||||
self.LOG.info(f"邀请用户 {sender} 加入群 {group_id}")
|
self.LOG.info(f"邀请用户 {sender} 加入群 {group_id}")
|
||||||
result = wcf.invite_chatroom_members(group_id, sender)
|
result = wcf.invite_chatroom_members(group_id, sender)
|
||||||
|
|||||||
Reference in New Issue
Block a user