-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
376 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,93 @@ | ||
export function bindSteamId (e) { | ||
import { db, utils, api } from '#models' | ||
import { Config, Render } from '#components' | ||
|
||
/** | ||
* 获得已绑定的steamId的文本 | ||
* @param {string} uid | ||
* @param {string} gid | ||
* @param {UserColumns[]?} userBindAll | ||
* @returns | ||
*/ | ||
export async function getBindSteamIdsImg (bid, uid, gid, userBindAll = []) { | ||
if (!userBindAll?.length) { | ||
userBindAll = await db.UserTableGetDataByUserId(uid) | ||
} | ||
if (!userBindAll.length) { | ||
return '没有绑定任何steamId, 请使用#steam绑定steamId或好友码 进行绑定' | ||
} | ||
const enablePush = (() => { | ||
if (!Config.push.enable) { | ||
return false | ||
} | ||
if (Config.push.whiteBotList.length && !Config.push.whiteBotList.some(i => i == bid)) { | ||
return false | ||
} | ||
if (Config.push.blackBotList.length && Config.push.blackBotList.some(i => i == bid)) { | ||
return false | ||
} | ||
if (Config.push.whiteGroupList.length && !Config.push.whiteGroupList.some(i => i == gid)) { | ||
return false | ||
} | ||
if (Config.push.blackGroupList.length && Config.push.blackGroupList.some(i => i == gid)) { | ||
return false | ||
} | ||
return true | ||
})() | ||
const data = [] | ||
const pushSteamId = [] | ||
const unPushSteamId = [] | ||
const enablePushSteamIdList = enablePush ? await db.PushTableGetAllSteamIdBySteamIdAndGroupId(uid, gid, true) : [] | ||
const allSteamIdInfo = {} | ||
try { | ||
const res = await api.ISteamUser.GetPlayerSummaries(userBindAll.map(i => i.steamId)) | ||
res.forEach(i => { | ||
allSteamIdInfo[i.steamid] = i | ||
}) | ||
} catch { } | ||
let index = 1 | ||
for (const item of userBindAll) { | ||
const avatar = Config.other.steamAvatar ? allSteamIdInfo[item.steamId].avatarfull : await utils.getUserAvatar(bid, uid, gid) | ||
const info = { | ||
steamId: item.steamId, | ||
isBind: item.isBind, | ||
name: allSteamIdInfo[item.steamId].personaname, | ||
avatar: avatar ?? await utils.getUserAvatar(bid, uid, gid), | ||
index | ||
} | ||
if (enablePushSteamIdList.includes(item.steamId)) { | ||
pushSteamId.push(info) | ||
} else { | ||
unPushSteamId.push(info) | ||
} | ||
index++ | ||
} | ||
if (enablePush) { | ||
if (pushSteamId.length) { | ||
data.push({ | ||
title: '已开启推送', | ||
list: pushSteamId | ||
}) | ||
} | ||
if (unPushSteamId.length) { | ||
data.push({ | ||
title: '未开启推送', | ||
list: unPushSteamId | ||
}) | ||
} | ||
} else { | ||
data.push({ | ||
title: '所有steamId', | ||
list: unPushSteamId | ||
}) | ||
} | ||
const img = await Render.render('user/index', { | ||
data, | ||
enablePush, | ||
random: Math.floor(Math.random() * 5) + 1 | ||
}) | ||
if (img) { | ||
return img | ||
} else { | ||
return '制作图片失败,重试一下' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.