From 4066f827349904566cb006688e33e929cfaed998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=8C=E8=8E=9E?= Date: Mon, 22 Nov 2021 17:32:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=20atype=3D0=20=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=AF=E4=B8=8D=E6=98=AF=E5=8F=98=E7=9B=B8?= =?UTF-8?q?=E7=9A=84=E7=AD=BE=E5=88=B0=E6=B6=88=E6=81=AF=20fix=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/inspectionProfiles/Project_Default.xml | 6 +++++ handlers/handleEasemobMessage.ts | 25 +++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..435a822 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/handlers/handleEasemobMessage.ts b/handlers/handleEasemobMessage.ts index 1fe86c3..39a9698 100644 --- a/handlers/handleEasemobMessage.ts +++ b/handlers/handleEasemobMessage.ts @@ -1,5 +1,5 @@ import ImMessageCheckin from '../types/ImMessageCheckin' -import { error, info, success, warn } from '../utils/log' +import {error, info, success, warn} from '../utils/log' import getCheckinDetail from '../requests/getCheckinDetail' import * as db from '../providers/db' import handlerSimpleCheckin from './handlerSimpleCheckin' @@ -23,6 +23,9 @@ export default async (message: ImMessageCheckin) => { return } switch (message.ext.attachment.att_chat_course.atype) { + case 0: + // 可能是签到 + if (!isSignActivity(message)) return case 2: const checkinInfo = await getCheckinDetail(await db.getMeta('cookie'), aid) info('收到', checkinInfo.type, '类型签到') @@ -62,3 +65,23 @@ export default async (message: ImMessageCheckin) => { error('处理 IM 消息时出现异常,可能不是活动消息', e) } } + +// 用于判断一个 atype=0 的消息是不是变相的签到消息 +const isSignActivity = (atype0Activity: ImMessageCheckin) => { + if (atype0Activity.ext.attachment.att_chat_course.pcUrl.toLowerCase().includes('sign')) { + return true + } + if (atype0Activity.ext.attachment.att_chat_course.pcUrl.toLowerCase().includes('checkin')) { + return true + } + if (atype0Activity.ext.attachment.att_chat_course.url.toLowerCase().includes('sign')) { + return true + } + if (atype0Activity.ext.attachment.att_chat_course.url.toLowerCase().includes('checkin')) { + return true + } + if (atype0Activity.ext.attachment.att_chat_course.logo.toLowerCase().includes('qd3.png')) { + return true + } + return atype0Activity.ext.attachment.att_chat_course.title.includes('签到') +}