This commit is contained in:
aaron 2025-03-04 15:47:13 +08:00
parent beadaf8ff7
commit 79a856f8c5

View File

@ -112,7 +112,7 @@ class WecomClient:
logging.error(f"unionid_to_external_userid异常: {str(e)}")
return None
async def send_welcome_message(self, group_id: str) -> bool:
async def send_welcome_message(self, chat_id: str) -> bool:
"""发送欢迎消息"""
try:
# 1. 获取 access_token
@ -122,10 +122,9 @@ class WecomClient:
return False
# 2. 发送欢迎消息
url = "https://qyapi.weixin.qq.com/cgi-bin/message/send"
params = {
"access_token": access_token,
"group_id": group_id,
url = f"https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token={access_token}"
data = {
"chatid": chat_id,
"msgtype": "text",
"text": {
"content": f"""🥳 欢迎您进群,在群内可以享受📦【代取快递】跑腿服务。
@ -137,11 +136,12 @@ class WecomClient:
𝟐 赠送𝟔枚鲜鸡蛋首次下单
🎊
点击小程序领券下单 &"""
}
},
"safe": 0
}
async with aiohttp.ClientSession() as session:
async with session.post(url, json=params) as response:
async with session.post(url, json=data) as response:
result = await response.json()
if result.get("errcode") == 0:
return True