Skip to content

Commit

Permalink
fix: 绑定了但没完全绑定
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Nov 20, 2024
1 parent b762ce5 commit 5986d03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions models/db/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ await PushTable.sync()
* @returns {Promise<PushColumns>}
*/
export async function PushTableAddData (userId, steamId, botId, groupId, transaction) {
userId = String(userId)
groupId = String(groupId)
// 判断是否存在
const data = await PushTable.findOne({
where: {
Expand Down Expand Up @@ -77,6 +79,8 @@ export async function PushTableAddData (userId, steamId, botId, groupId, transac
* @returns {Promise<number>}
*/
export async function PushTableDelData (userId, steamId, botId, groupId, transaction) {
userId = String(userId)
groupId = String(groupId)
return await PushTable.destroy({
where: {
userId,
Expand Down
5 changes: 5 additions & 0 deletions models/db/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ await UserTable.sync()
* @returns {Promise<UserColumns|null>}
*/
export async function UserTableAddSteamIdByUserId (userId, steamId) {
userId = String(userId)
const res = await UserTable.create({
userId,
steamId
Expand All @@ -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 {
Expand Down Expand Up @@ -99,6 +101,7 @@ export async function UserTableBindSteamIdByUserId (userId, steamId, isBind = tr
* @returns {Promise<UserColumns|null>}
*/
export async function UserTableDelSteamIdByUserId (userId, steamId) {
userId = String(userId)
const transaction = await sequelize.transaction()
const data = await UserTableGetDataByUserId(userId)
try {
Expand Down Expand Up @@ -141,6 +144,7 @@ export async function UserTableDelSteamIdByUserId (userId, steamId) {
* @returns {Promise<string|null>}
*/
export async function UserTableGetBindSteamIdByUserId (userId) {
userId = String(userId)
return await UserTable.findOne({
where: {
userId,
Expand Down Expand Up @@ -168,6 +172,7 @@ export async function UserTableGetDataBySteamId (steamId) {
* @returns {Promise<UserColumns[]>}
*/
export async function UserTableGetDataByUserId (userId) {
userId = String(userId)
return await UserTable.findAll({
where: {
userId
Expand Down
3 changes: 2 additions & 1 deletion models/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 5986d03

Please sign in to comment.