mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-22 11:00:51 +08:00
Merge pull request #137 from TimeRainStarSky/patch-1
修复 getGroupMemberInfo 可能报错导致转发异常
This commit is contained in:
commit
3c8fabd6bf
@ -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)
|
||||
nickname = info.card || info.nickname
|
||||
}
|
||||
}
|
||||
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) {
|
||||
@ -139,4 +138,4 @@ export default {
|
||||
redisSet,recallMsg,
|
||||
relpyPrivate,
|
||||
getCookieMap
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user