2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

Merge pull request #137 from TimeRainStarSky/patch-1

修复 getGroupMemberInfo 可能报错导致转发异常
This commit is contained in:
w(゚Д゚)w 2024-07-31 08:58:23 +08:00 committed by GitHub
commit 3c8fabd6bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,7 @@ export async function redisSet(userId="all", type = 'bbs', data, time=0) {
* @param msg 消息
*/
export async function relpyPrivate(userId, msg) {
userId = Number(userId)
userId = Number(userId) || userId
let friend = Bot.fl.get(userId)
if (friend) {
Bot.logger.mark(`发送好友消息[${friend.nickname}](${userId})`)
@ -54,13 +54,12 @@ export async function relpyPrivate(userId, msg) {
}
}
export async function replyMake(e, _msg, lenght) {
let nickname = Bot.nickname;
if (e.isGroup) {
if(Bot?.getGroupMemberInfo){
let info = await Bot?.getGroupMemberInfo(e.group_id, Bot.uin)
const bot = e.bot || Bot
let nickname = bot.nickname;
if (e.isGroup && bot.getGroupMemberInfo) try {
const info = await bot.getGroupMemberInfo(e.group_id, bot.uin)
nickname = info.card || info.nickname
}
}
} catch {}
let msgList = [];
for (let [index, item] of Object.entries(_msg)) {
if (index < lenght) {
@ -69,7 +68,7 @@ export async function replyMake(e, _msg, lenght) {
msgList.push({
message: item,
nickname: nickname,
user_id: Bot.uin
user_id: bot.uin
})
}
if (e.isGroup) {