From 5986d03d4e6c59b620aec55d525d8a7251452e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Wed, 20 Nov 2024 21:47:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=91=E5=AE=9A=E4=BA=86=E4=BD=86?= =?UTF-8?q?=E6=B2=A1=E5=AE=8C=E5=85=A8=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/db/push.js | 4 ++++ models/db/user.js | 5 +++++ models/utils/index.js | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/models/db/push.js b/models/db/push.js index ff1d56c..4f6c03a 100644 --- a/models/db/push.js +++ b/models/db/push.js @@ -47,6 +47,8 @@ await PushTable.sync() * @returns {Promise} */ export async function PushTableAddData (userId, steamId, botId, groupId, transaction) { + userId = String(userId) + groupId = String(groupId) // 判断是否存在 const data = await PushTable.findOne({ where: { @@ -77,6 +79,8 @@ export async function PushTableAddData (userId, steamId, botId, groupId, transac * @returns {Promise} */ export async function PushTableDelData (userId, steamId, botId, groupId, transaction) { + userId = String(userId) + groupId = String(groupId) return await PushTable.destroy({ where: { userId, diff --git a/models/db/user.js b/models/db/user.js index b683e39..0fcbe0b 100644 --- a/models/db/user.js +++ b/models/db/user.js @@ -41,6 +41,7 @@ await UserTable.sync() * @returns {Promise} */ export async function UserTableAddSteamIdByUserId (userId, steamId) { + userId = String(userId) const res = await UserTable.create({ userId, steamId @@ -58,6 +59,7 @@ export async function UserTableAddSteamIdByUserId (userId, steamId) { * @param {boolean} isBind 是否绑定 */ export async function UserTableBindSteamIdByUserId (userId, steamId, isBind = true) { + userId = String(userId) // 开启一个事务 const transaction = await sequelize.transaction() try { @@ -99,6 +101,7 @@ export async function UserTableBindSteamIdByUserId (userId, steamId, isBind = tr * @returns {Promise} */ export async function UserTableDelSteamIdByUserId (userId, steamId) { + userId = String(userId) const transaction = await sequelize.transaction() const data = await UserTableGetDataByUserId(userId) try { @@ -141,6 +144,7 @@ export async function UserTableDelSteamIdByUserId (userId, steamId) { * @returns {Promise} */ export async function UserTableGetBindSteamIdByUserId (userId) { + userId = String(userId) return await UserTable.findOne({ where: { userId, @@ -168,6 +172,7 @@ export async function UserTableGetDataBySteamId (steamId) { * @returns {Promise} */ export async function UserTableGetDataByUserId (userId) { + userId = String(userId) return await UserTable.findAll({ where: { userId diff --git a/models/utils/index.js b/models/utils/index.js index 184e435..b283f1e 100644 --- a/models/utils/index.js +++ b/models/utils/index.js @@ -76,13 +76,13 @@ export async function getUserName (botId, uid, gid) { return uid } } else { + uid = Number(uid) || uid if (gid) { gid = Number(gid) || gid const group = Bot[botId].pickGroup(gid) const member = (await group.pickMember(uid)).getInfo() return member.card || member.nickname || member.user_id || uid } else { - uid = Number(uid) || uid const user = Bot[botId].pickUser(uid) const info = await user.getInfo() return info.nickname || info.user_id || uid @@ -122,6 +122,7 @@ export async function sendGroupMsg (botId, gid, msg) { if (Version.BotName === 'Karin') { return await Bot.sendMsg(botId, { scene: 'group', peer: gid }, msg) } else { + gid = Number(gid) || gid return await Bot[botId].pickGroup(gid).sendMsg(msg) } }