Skip to content

Commit

Permalink
支持 atype=0 的消息是不是变相的签到消息
Browse files Browse the repository at this point in the history
fix #3
  • Loading branch information
clansty committed Nov 22, 2021
1 parent 8ce46d7 commit 4066f82
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion handlers/handleEasemobMessage.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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<string>('cookie'), aid)
info('收到', checkinInfo.type, '类型签到')
Expand Down Expand Up @@ -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('签到')
}

0 comments on commit 4066f82

Please sign in to comment.