koishi-plugin-p-draw 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +32 -32
- package/lib/i18n.js +0 -2
- package/package.json +1 -1
- package/readme.md +1 -1
package/index.js
CHANGED
|
@@ -462,19 +462,34 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
462
462
|
return { notices }
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
-
function buildChargeNotice({ isAdmin, totalPrice, unetName, seeds }) {
|
|
466
|
-
if (isAdmin || !seeds.length) return ''
|
|
467
|
-
return `已扣除 ${totalPrice} P 点,当前模型:${unetName},--seed=${seeds.join(',')}`
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
465
|
+
function buildChargeNotice({ isAdmin, totalPrice, unetName, seeds }) {
|
|
466
|
+
if (isAdmin || !seeds.length) return ''
|
|
467
|
+
return `已扣除 ${totalPrice} P 点,当前模型:${unetName},--seed=${seeds.join(',')}`
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function buildGenerationReply(session, { successCount, count, failures, notes = [] }) {
|
|
471
|
+
const reply = []
|
|
472
|
+
if (notes.length) reply.push(notes.join('\n'))
|
|
473
|
+
if (failures.length) reply.push(session.text('.batch-partial', [successCount, count, failures.length, failures.join(';')]))
|
|
474
|
+
return reply.filter(Boolean).join('\n')
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
async function sendNotices(session, notices, opts = {}) {
|
|
478
|
+
const content = notices.filter(Boolean).join('\n')
|
|
479
|
+
if (!content) return
|
|
480
|
+
try {
|
|
481
|
+
const quoteId = session.event?.message?.id || session.messageId
|
|
482
|
+
let message = content
|
|
483
|
+
if (opts.quote && quoteId) {
|
|
484
|
+
const quote = session.platform === 'onebot'
|
|
485
|
+
? h('reply', { id: quoteId })
|
|
486
|
+
: h.quote(quoteId)
|
|
487
|
+
message = quote + content
|
|
488
|
+
}
|
|
489
|
+
if (cfg.outputLogs && opts.quote) logger.info(`[p-draw] 发送扣费引用通知 platform=${session.platform || 'unknown'} messageId=${quoteId || 'missing'}`)
|
|
490
|
+
await session.send(message)
|
|
491
|
+
} catch (e) {
|
|
492
|
+
logger.warn(`发送反馈消息失败:${e.message}`)
|
|
478
493
|
}
|
|
479
494
|
}
|
|
480
495
|
|
|
@@ -1467,15 +1482,7 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
1467
1482
|
// 发图:合并转发,不引用原指令
|
|
1468
1483
|
await sendImagesAsForward(session, forwardOutputs)
|
|
1469
1484
|
|
|
1470
|
-
|
|
1471
|
-
if (count > 1) {
|
|
1472
|
-
reply.push(session.text('.generate-ok-batch', [count * price, successCount, seeds.join(', ') || '-']))
|
|
1473
|
-
} else {
|
|
1474
|
-
reply.push(session.text('.generate-ok', [price, seeds[0] || '-']))
|
|
1475
|
-
}
|
|
1476
|
-
if (notes.length) reply.push(notes.join('\n'))
|
|
1477
|
-
if (failures.length) reply.push(session.text('.batch-partial', [successCount, count, failures.length, failures.join(';')]))
|
|
1478
|
-
return reply.filter(Boolean).join('\n')
|
|
1485
|
+
return buildGenerationReply(session, { successCount, count, failures, notes })
|
|
1479
1486
|
}
|
|
1480
1487
|
|
|
1481
1488
|
// ---------------- 权限 ----------------
|
|
@@ -2005,14 +2012,7 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
2005
2012
|
// 发图:合并转发,不引用原指令
|
|
2006
2013
|
await sendImagesAsForward(session, forwardOutputs)
|
|
2007
2014
|
|
|
2008
|
-
|
|
2009
|
-
if (count > 1) {
|
|
2010
|
-
reply.push(session.text('.generate-ok-batch', [count * cfg.price, successCount, seeds.join(', ') || '-']))
|
|
2011
|
-
} else {
|
|
2012
|
-
reply.push(session.text('.generate-ok', [cfg.price, seeds[0] || '-']))
|
|
2013
|
-
}
|
|
2014
|
-
if (failures.length) reply.push(session.text('.batch-partial', [successCount, count, failures.length, failures.join(';')]))
|
|
2015
|
-
return reply.filter(Boolean).join('\n')
|
|
2015
|
+
return buildGenerationReply(session, { successCount, count, failures })
|
|
2016
2016
|
}
|
|
2017
2017
|
// ---------------- 提示词优化券交互式确认 ----------------
|
|
2018
2018
|
// 仅全局优化关闭 + 非管理员 + 已配置 LLM(tokenOpt 分支)时进入。
|
|
@@ -2157,5 +2157,5 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
2157
2157
|
})
|
|
2158
2158
|
|
|
2159
2159
|
// 暴露内部接口供自动化测试调用(Koishi 忽略 apply 返回值,不影响生产行为)
|
|
2160
|
-
return { couponConfirmFlow, buyCouponsAndConsume, normalizeConfirm, resolveCouponPrice, buildChargeNotice, sendNotices, sendImagesAsForward, executeBatch }
|
|
2161
|
-
}
|
|
2160
|
+
return { couponConfirmFlow, buyCouponsAndConsume, normalizeConfirm, resolveCouponPrice, buildChargeNotice, buildGenerationReply, sendNotices, sendImagesAsForward, executeBatch }
|
|
2161
|
+
}
|
package/lib/i18n.js
CHANGED
|
@@ -83,8 +83,6 @@ const zhCN = {
|
|
|
83
83
|
'coupon-buy-pshort': 'P 点不足,无法购买提示词优化券(需 {0} P,现有 {1} P)。\n是否仍然生图(不使用 LLM 优化)?\n(回复「是」生图 / 回复「否」取消本次生图)',
|
|
84
84
|
'coupon-consume-fail': '提示词优化券操作失败,本次未使用 LLM 优化。',
|
|
85
85
|
'generate-failed': '生成失败:{0}',
|
|
86
|
-
'generate-ok': '已扣除 {0} P 点,seed={1}',
|
|
87
|
-
'generate-ok-batch': '已扣除 {0} P 点,共 {1} 张(seed:{2})',
|
|
88
86
|
'batch-partial': '本次共生成 {0}/{1} 张,失败 {2} 张:{3}',
|
|
89
87
|
'batch-limit': '每次最多生成 {0} 张,本次已按 {0} 张处理。',
|
|
90
88
|
'batch-count': '本次共生成 {0} 张。',
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -20,7 +20,7 @@ p点-绘图插件,连接本地 ComfyUI 生图,参考 AstrBot 的 [anima 绘
|
|
|
20
20
|
- 生成队列(逐张顺序执行,防止争抢 GPU)。
|
|
21
21
|
- `p-draw 状态` 查看 ComfyUI 连接状态与模型可用性。
|
|
22
22
|
- `p-draw help`(或 `帮助`)查看全部指令帮助,包含生成 / 多人 / 批量张数 / 尺寸 / 画师组 / 状态等。
|
|
23
|
-
- 发图时会以合并转发发送,每张图片后附对应的 Positive / Negative
|
|
23
|
+
- 发图时会以合并转发发送,每张图片后附对应的 Positive / Negative 提示词;扣费提醒单独引用触发指令,并显示实际模型和 seed(如 `已扣除 750 P 点,当前模型:animagine-xl-3.1.safetensors,--seed=123456`)。OneBot/NapCat 自动使用原生 `reply` 消息段发送引用。
|
|
24
24
|
|
|
25
25
|
## 安装
|
|
26
26
|
|