Skip to content

Commit

Permalink
fix: 投降喵
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Dec 1, 2024
1 parent 8b6e8af commit 6f23550
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 24 deletions.
64 changes: 42 additions & 22 deletions apps/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,50 @@ export const rule = {
return true
}
const info = data.pop()
const color = info.gameid ? 1 : info.personastate === 0 ? 3 : 2
const bg = await api.IPlayerService.GetProfileItemsEquipped(steamId)
const img = await Render.render('info/index', {
background: await utils.saveImg(utils.getStaticUrl(bg.mini_profile_background.image_large)),
frame: await utils.saveImg(utils.getStaticUrl(bg.avatar_frame.image_small)),
avatar: await utils.saveImg(Config.other.steamAvatar ? info.avatarfull : await utils.getUserAvatar(e.self_id, uid, e.group_id)),
name: info.personaname,
status: utils.getPersonaState(info.personastate),
gameId: info.gameid,
gameName: info.gameextrainfo,
friendCode: utils.getFriendCode(info.steamid),
createTime: moment.unix(info.timecreated).format('YYYY-MM-DD HH:mm:ss'),
lastTime: (info.lastlogoff && info.personastate === 0) ? moment.unix(info.lastlogoff).format('YYYY-MM-DD HH:mm:ss') : '',
country: info.loccountrycode ? getLoccountryCode(info.loccountrycode) : '',
color,
scale: 1.4,
pageGotoParams: {
waitUntil: 'load'
if (Config.other.infoMode == 2) {
const color = info.gameid ? 1 : info.personastate === 0 ? 3 : 2
const bg = await api.IPlayerService.GetProfileItemsEquipped(steamId)
const img = await Render.render('info/index', {
background: await utils.saveImg(utils.getStaticUrl(bg.mini_profile_background.image_large)),
frame: await utils.saveImg(utils.getStaticUrl(bg.avatar_frame.image_small)),
avatar: await utils.saveImg(Config.other.steamAvatar ? info.avatarfull : await utils.getUserAvatar(e.self_id, uid, e.group_id)),
name: info.personaname,
status: utils.getPersonaState(info.personastate),
gameId: info.gameid,
gameName: info.gameextrainfo,
friendCode: utils.getFriendCode(info.steamid),
createTime: moment.unix(info.timecreated).format('YYYY-MM-DD HH:mm:ss'),
lastTime: (info.lastlogoff && info.personastate === 0) ? moment.unix(info.lastlogoff).format('YYYY-MM-DD HH:mm:ss') : '',
country: info.loccountrycode ? getLoccountryCode(info.loccountrycode) : '',
color,
scale: 1.4,
pageGotoParams: {
waitUntil: 'load'
}
})
if (img) {
await e.reply(img)
} else {
await e.reply([segment.at(uid), '\n截图失败了, 重试一下吧'])
}
})
if (img) {
await e.reply(img)
} else {
await e.reply([segment.at(uid), '\n截图失败了, 重试一下吧'])
const avatarBuffer = Config.other.steamAvatar ? await utils.getImgUrlBuffer(info.avatarfull) : ''
const msg = []
avatarBuffer && msg.push(segment.image(avatarBuffer), '\n')
msg.push([
`好友代码: ${utils.getFriendCode(info.steamid)}`,
`steamId: ${info.steamid}`,
`用户名称: ${info.personaname}`,
`当前状态: ${utils.getPersonaState(info.personastate)}`,
info.lastlogoff ? `最后下线: ${moment.unix(info.lastlogoff).format('YYYY-MM-DD HH:mm:ss')}` : '',
`注册时间: ${moment.unix(info.timecreated).format('YYYY-MM-DD HH:mm:ss')}`,
info.loccountrycode ? `账号地区: ${getLoccountryCode(info.loccountrycode)}` : ''
].filter(Boolean).join('\n'))
if (info.gameid) {
const icon = utils.getHeaderImgUrlByAppid(info.gameid)
msg.push('\n', segment.image(icon), `\n正在游玩: ${info.gameextrainfo}`)
}
await e.reply(msg)
}
return true
}
Expand Down
1 change: 1 addition & 0 deletions components/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Config {
* hiddenLength: number,
* itemLength: number,
* steamAvatar: boolean,
* infoMode: number,
* }}
*/
get other () {
Expand Down
5 changes: 5 additions & 0 deletions config/default_config/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ itemLength: 3

# 是否显示Steam头像 可能会有18+的头像
steamAvatar: true

# steam状态 发送消息模式
# 1: 文字
# 2: 图片 (若图片发送时间长可更换为文字模式)
infoMode: 2
16 changes: 16 additions & 0 deletions models/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ export const cfgSchema = {
type: 'boolean',
def: true,
desc: '是否展示steam头像, 可能会有18+头像'
},
infoMode: {
title: 'steam状态发送模式',
key: '状态模式',
type: 'number',
def: 2,
min: 1,
max: 2,
input: (n) => {
if (n >= 1 && n <= 2) {
return n * 1
} else {
return 2
}
},
desc: 'steam状态发送消息的模式 1: 文字 2: 图片 若图片发送时间长可更换为文字'
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions models/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export async function getImgUrlBuffer (url, retry = 3) {
retry = Number(retry) || 3
for (let i = 0; i < retry; i++) {
try {
const buffer = await request.get(path.pathname, {
const buffer = await request.get(path.pathname + path.search, {
responseType: 'arraybuffer',
baseURL: path.origin
}).then(res => res.data)
Expand Down Expand Up @@ -253,7 +253,7 @@ export async function saveImg (url, retry = 3) {
for (let i = 0; i < retry; i++) {
try {
let ext = ''
const buffer = await request.get(path.pathname, {
const buffer = await request.get(path.pathname + path.search, {
responseType: 'arraybuffer',
baseURL: path.origin
}).then(res => {
Expand Down

0 comments on commit 6f23550

Please sign in to comment.