koishi-plugin-starfx-bot 0.27.0 → 0.27.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/lib/index.d.ts +1 -0
- package/lib/index.js +82 -19
- package/lib/plugins/drawHead.d.ts +2 -2
- package/package.json +1 -1
- package/readme.md +3 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// src/locales/zh-CN.yml
|
|
34
34
|
var require_zh_CN = __commonJS({
|
|
35
35
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
36
|
-
module2.exports = { commands: { roll: { messages: { noParam: "你问啥?", invalid: "你要不看看你说的是啥", "too-many": "太、太多了啦!", noodles: "扔出了{num}个{noodles}面的骰子,点数如下:{points}", possibility: "{param}是{possibility}%", choose: "当然是{option}啦!" } }, "room-number": { messages: { roomNumber: "当前的房间号是: {room}", changeRoom: "已将当前房间号 {oldRoom} 修改为 {newRoom}", newRoom: "已添加房间号: {room}", noRoom: "当前没有保存的房间", delRoom: "已删除房间: {room}", invalid: "无效输入" } }, forward: { messages: { delete: "已删除转发群聊: {gid}", noTarget: "未配置转发群组", success: "已转发消息到: {target}", noMessage: "请引用要转发的消息", setOK: "已配置转发: {target}", forwardContent: "[转发消息]<br/> {content}" } }, "waiting-play": { messages: { addReady: "已添加,当前待机{num}人: <br/>{list}", delReady: "已删除,当前待机{num}人: <br/>{list}", delFailed: "未删除,当前待机{num}人: <br/>{list}", clearReady: "待机列表已清空", listReady: "当前待机{num}人: <br/>{list}", invalid: "输入无效" } },
|
|
36
|
+
module2.exports = { commands: { roll: { messages: { noParam: "你问啥?", invalid: "你要不看看你说的是啥", "too-many": "太、太多了啦!", noodles: "扔出了{num}个{noodles}面的骰子,点数如下:{points}", possibility: "{param}是{possibility}%", choose: "当然是{option}啦!" } }, "room-number": { messages: { roomNumber: "当前的房间号是: {room}", changeRoom: "已将当前房间号 {oldRoom} 修改为 {newRoom}", newRoom: "已添加房间号: {room}", noRoom: "当前没有保存的房间", delRoom: "已删除房间: {room}", invalid: "无效输入" } }, forward: { messages: { delete: "已删除转发群聊: {gid}", noTarget: "未配置转发群组", success: "已转发消息到: {target}", noMessage: "请引用要转发的消息", setOK: "已配置转发: {target}", forwardContent: "[转发消息]<br/> {content}" } }, "waiting-play": { messages: { addReady: "已添加,当前待机{num}人: <br/>{list}", delReady: "已删除,当前待机{num}人: <br/>{list}", delFailed: "未删除,当前待机{num}人: <br/>{list}", clearReady: "待机列表已清空", listReady: "当前待机{num}人: <br/>{list}", invalid: "输入无效" } }, 开启车牌检测: { messages: { success: "车牌检测:已打开\n当前车牌位数: {length}", noPermission: "你没有权限开启车牌检测", noGuild: "请在群聊中使用该指令", invalidLength: "位数设定不合理,请输入 1-20 之间的数字" } }, 关闭车牌检测: { messages: { success: "已关闭车牌检测", noPermission: "你没有权限关闭车牌检测", noGuild: "请在群聊中使用该指令" } }, 车牌检测状态: { messages: { enabled: "车牌检测: 已打开\n当前车牌位数: {length}", disabled: "车牌检测: 已关闭", managerEnabled: "管理员权限正常", managerDisabled: "无管理员权限,无法修改群名", noPermission: "你没有权限查看车牌检测状态", noGuild: "请在群聊中使用该指令" } }, 车牌检测权限: { messages: { status: { enabled: "普通群员开关车牌检测: 允许", disabled: "普通群员开关车牌检测: 禁止" }, enabled: "已允许普通群员开关车牌检测", disabled: "已禁止普通群员开关车牌检测", invalid: "无效输入,请输入 开 / 关", noPermission: "你没有权限设置车牌检测权限", noGuild: "请在群聊中使用该指令" } } }, middleware: { messages: { atNotReply: "艾特我又不说话", atNotReplyOther: "艾特他又不说话", notBot: "我才不是机器人!", loveMessage: "我喜欢你", iLoveU: "我也喜欢你", notManager: "当前bot没有管理员权限,无法修改群名", editFuncNotFound: "无法找到设置群名的底层方法", editGroupNameSuccess: "检测到车牌 {content},群名修改成功!", editGroupNameRetrySuccess: '检测到车牌 {content},由于限制已修改为 "{spacedContent}"' } } };
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -63,7 +63,7 @@ var package_default = {
|
|
|
63
63
|
contributors: [
|
|
64
64
|
"StarFreedomX <starfreedomx@outlook.com>"
|
|
65
65
|
],
|
|
66
|
-
version: "0.27.
|
|
66
|
+
version: "0.27.2",
|
|
67
67
|
main: "lib/index.js",
|
|
68
68
|
typings: "lib/index.d.ts",
|
|
69
69
|
files: [
|
|
@@ -1355,8 +1355,9 @@ var Config = import_koishi5.Schema.intersect([
|
|
|
1355
1355
|
]);
|
|
1356
1356
|
function apply(ctx, cfg) {
|
|
1357
1357
|
ctx.model.extend("channel", {
|
|
1358
|
-
pickupLength: "unsigned"
|
|
1358
|
+
pickupLength: "unsigned",
|
|
1359
1359
|
// 无符号整数
|
|
1360
|
+
pickupGrant: "boolean"
|
|
1360
1361
|
});
|
|
1361
1362
|
ctx.i18n.define("zh-CN", require_zh_CN());
|
|
1362
1363
|
baseDir = ctx.baseDir;
|
|
@@ -1683,40 +1684,61 @@ function apply(ctx, cfg) {
|
|
|
1683
1684
|
}
|
|
1684
1685
|
});
|
|
1685
1686
|
}
|
|
1687
|
+
const canTogglePickup = /* @__PURE__ */ __name(async (session) => {
|
|
1688
|
+
if (await canGrant(session)) return true;
|
|
1689
|
+
const channel = await session.observeChannel(["pickupGrant"]);
|
|
1690
|
+
return !!channel.pickupGrant;
|
|
1691
|
+
}, "canTogglePickup");
|
|
1686
1692
|
if (cfg.roomNumToName) {
|
|
1687
|
-
ctx.command("
|
|
1693
|
+
ctx.command("车牌检测权限 [allow:text]").channelFields(["pickupGrant"]).action(async ({ session }, allow) => {
|
|
1688
1694
|
if (!detectControl(featureControl, session.guildId, "pickup")) return;
|
|
1689
1695
|
if (!session.guildId) return session.text(".noGuild");
|
|
1690
1696
|
if (!await canGrant(session)) return session.text(".noPermission");
|
|
1697
|
+
if (!allow) {
|
|
1698
|
+
return session.channel.pickupGrant ? session.text(".status.enabled") : session.text(".status.disabled");
|
|
1699
|
+
}
|
|
1700
|
+
const normalized = String(allow).trim().toLowerCase();
|
|
1701
|
+
if (["1", "true", "yes", "y", "on", "开", "开启", "允许"].includes(normalized)) {
|
|
1702
|
+
session.channel.pickupGrant = true;
|
|
1703
|
+
return session.text(".enabled");
|
|
1704
|
+
}
|
|
1705
|
+
if (["0", "false", "no", "n", "off", "关", "关闭", "禁止"].includes(normalized)) {
|
|
1706
|
+
session.channel.pickupGrant = false;
|
|
1707
|
+
return session.text(".disabled");
|
|
1708
|
+
}
|
|
1709
|
+
return session.text(".invalid");
|
|
1710
|
+
});
|
|
1711
|
+
ctx.command("开启车牌检测 [length:number]").alias("打开车牌检测", "打开拾取").channelFields(["pickupLength", "pickupGrant"]).action(async ({ session }, length) => {
|
|
1712
|
+
if (!detectControl(featureControl, session.guildId, "pickup")) return;
|
|
1713
|
+
if (!session.guildId) return session.text(".noGuild");
|
|
1714
|
+
if (!await canTogglePickup(session)) return session.text(".noPermission");
|
|
1715
|
+
if (!await canBotManage(session)) return session.text("middleware.messages.notManager");
|
|
1691
1716
|
const finalLength = length || cfg.roomNumLength || 5;
|
|
1692
1717
|
if (finalLength < 1 || finalLength > 20) return session.text(".invalidLength");
|
|
1693
1718
|
session.channel.pickupLength = finalLength;
|
|
1694
1719
|
return session.text(".success", { length: finalLength });
|
|
1695
1720
|
});
|
|
1696
|
-
ctx.command("关闭拾取").channelFields(["pickupLength"]).action(async ({ session }) => {
|
|
1721
|
+
ctx.command("关闭车牌检测").alias("关闭拾取").channelFields(["pickupLength", "pickupGrant"]).action(async ({ session }) => {
|
|
1697
1722
|
if (!detectControl(featureControl, session.guildId, "pickup")) return;
|
|
1698
1723
|
if (!session.guildId) return session.text(".noGuild");
|
|
1699
|
-
if (!await
|
|
1700
|
-
if (!await canBotManage(session)) return session.text("middleware.messages.notManager");
|
|
1724
|
+
if (!await canTogglePickup(session)) return session.text(".noPermission");
|
|
1701
1725
|
session.channel.pickupLength = 0;
|
|
1702
1726
|
return session.text(".success");
|
|
1703
1727
|
});
|
|
1704
|
-
ctx.command("
|
|
1728
|
+
ctx.command("车牌检测状态").channelFields(["pickupLength", "pickupGrant"]).action(async ({ session }) => {
|
|
1705
1729
|
if (!detectControl(featureControl, session.guildId, "pickup")) return;
|
|
1706
1730
|
if (!session.guildId) return session.text(".noGuild");
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
return session.channel.pickupLength > 0 ? session.text(".enabled", { length: session.channel.pickupLength }) : session.text(".disabled");
|
|
1731
|
+
return `${session.channel.pickupLength > 0 ? session.text(".enabled", { length: session.channel.pickupLength }) : session.text(".disabled")}
|
|
1732
|
+
${!!await canBotManage(session) ? session.text(".managerEnabled") : session.text(".managerDisabled")}`;
|
|
1710
1733
|
});
|
|
1711
1734
|
}
|
|
1712
1735
|
ctx.middleware(async (session, next) => {
|
|
1713
1736
|
const elements = session.elements;
|
|
1714
1737
|
if (cfg.roomNumToName && session.guildId && detectControl(featureControl, session.guildId, "pickup")) {
|
|
1715
|
-
const channel = await session.observeChannel(["pickupLength"]);
|
|
1738
|
+
const channel = await session.observeChannel(["pickupLength", "pickupGrant"]);
|
|
1716
1739
|
const targetLength = channel.pickupLength;
|
|
1717
1740
|
const content = session.content?.trim();
|
|
1718
1741
|
if (targetLength > 0 && new RegExp(`^\\d{${targetLength}}$`).test(content)) {
|
|
1719
|
-
if (!await canBotManage(session)) return session.text("middleware.messages.notManager");
|
|
1720
1742
|
const setGroupName = /* @__PURE__ */ __name(async (name2) => {
|
|
1721
1743
|
const internal = session.bot.internal;
|
|
1722
1744
|
if (typeof internal?._request === "function" && session.platform === "onebot") {
|
|
@@ -1737,19 +1759,61 @@ function apply(ctx, cfg) {
|
|
|
1737
1759
|
}
|
|
1738
1760
|
throw new Error(session.text("middleware.messages.editFuncNotFound"));
|
|
1739
1761
|
}, "setGroupName");
|
|
1762
|
+
const getCurrentGroupName = /* @__PURE__ */ __name(async () => {
|
|
1763
|
+
const channel2 = await session.bot.getChannel(session.channelId);
|
|
1764
|
+
return channel2?.name;
|
|
1765
|
+
}, "getCurrentGroupName");
|
|
1740
1766
|
try {
|
|
1741
|
-
|
|
1742
|
-
|
|
1767
|
+
const replaceNumberInName = /* @__PURE__ */ __name((name2, digits) => {
|
|
1768
|
+
if (!name2 || !name2.length) return digits;
|
|
1769
|
+
const targetLen = digits.replace(/\s+/g, "").length;
|
|
1770
|
+
const n = name2.length;
|
|
1771
|
+
for (let i = 0; i < n; i++) {
|
|
1772
|
+
for (let j = i + 1; j <= n; j++) {
|
|
1773
|
+
const sub = name2.slice(i, j);
|
|
1774
|
+
const compact = sub.replace(/\s+/g, "");
|
|
1775
|
+
if (compact.length === targetLen && /^\d+$/.test(compact)) {
|
|
1776
|
+
return name2.slice(0, i) + digits + name2.slice(j);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return digits + " " + name2;
|
|
1781
|
+
}, "replaceNumberInName");
|
|
1782
|
+
const currentName = await getCurrentGroupName();
|
|
1783
|
+
const contentDigits = String(content).replace(/\s+/g, "");
|
|
1784
|
+
let newName;
|
|
1785
|
+
if (currentName) {
|
|
1786
|
+
newName = replaceNumberInName(currentName, contentDigits);
|
|
1787
|
+
} else {
|
|
1788
|
+
newName = contentDigits;
|
|
1789
|
+
}
|
|
1790
|
+
await setGroupName(newName);
|
|
1791
|
+
await session.send(session.text("middleware.messages.editGroupNameSuccess", { content: newName }));
|
|
1743
1792
|
return;
|
|
1744
1793
|
} catch (e) {
|
|
1745
1794
|
starfxLogger.warn(`纯数字修改失败,尝试添加空格重试: ${content}`);
|
|
1746
1795
|
try {
|
|
1747
1796
|
const spacedContent = content.replace(/(\d{3})(?=\d)/g, "$1 ");
|
|
1748
|
-
await
|
|
1749
|
-
|
|
1797
|
+
const currentName = await getCurrentGroupName();
|
|
1798
|
+
const finalName = currentName ? (() => {
|
|
1799
|
+
const targetLen = spacedContent.replace(/\s+/g, "").length;
|
|
1800
|
+
const n = currentName.length;
|
|
1801
|
+
for (let i = 0; i < n; i++) {
|
|
1802
|
+
for (let j = i + 1; j <= n; j++) {
|
|
1803
|
+
const sub = currentName.slice(i, j);
|
|
1804
|
+
const compact = sub.replace(/\s+/g, "");
|
|
1805
|
+
if (compact.length === targetLen && /^\d+$/.test(compact)) {
|
|
1806
|
+
return currentName.slice(0, i) + spacedContent + currentName.slice(j);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
return spacedContent + " " + currentName;
|
|
1811
|
+
})() : spacedContent;
|
|
1812
|
+
await setGroupName(finalName);
|
|
1813
|
+
await session.send(session.text("middleware.messages.editGroupNameRetrySuccess", { content, spacedContent: finalName }));
|
|
1750
1814
|
return;
|
|
1751
1815
|
} catch (retryError) {
|
|
1752
|
-
starfxLogger.error(
|
|
1816
|
+
starfxLogger.error(`尝试添加空格修改群名仍失败: ${retryError}`);
|
|
1753
1817
|
}
|
|
1754
1818
|
}
|
|
1755
1819
|
}
|
|
@@ -1776,7 +1840,6 @@ function apply(ctx, cfg) {
|
|
|
1776
1840
|
});
|
|
1777
1841
|
if (process.env.NODE_ENV === "development") {
|
|
1778
1842
|
ctx.command("test [params]").action(async ({ session }) => {
|
|
1779
|
-
await session.send("test");
|
|
1780
1843
|
});
|
|
1781
1844
|
ctx.middleware(async (session, next) => {
|
|
1782
1845
|
await session.send("");
|
|
@@ -17,14 +17,14 @@ export declare function handleBanGDreamConfig(options: any): Promise<{
|
|
|
17
17
|
* @param baseImage 被封印的图片url
|
|
18
18
|
* @return 画完的图片 h对象
|
|
19
19
|
*/
|
|
20
|
-
export declare function drawLock(ctx: Context, baseImage: string): Promise<
|
|
20
|
+
export declare function drawLock(ctx: Context, baseImage: string): Promise<h | "输入无效" | "发生错误">;
|
|
21
21
|
/**
|
|
22
22
|
* "卖掉了"绘图函数
|
|
23
23
|
* @param ctx
|
|
24
24
|
* @param baseImage
|
|
25
25
|
* @return 画完的图片 h对象
|
|
26
26
|
*/
|
|
27
|
-
export declare function drawSold(ctx: Context, baseImage: string): Promise<
|
|
27
|
+
export declare function drawSold(ctx: Context, baseImage: string): Promise<h | "输入无效" | "发生错误">;
|
|
28
28
|
/**
|
|
29
29
|
* BanG Dream!边框绘制功能
|
|
30
30
|
* @param ctx Koishi上下文
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -70,6 +70,7 @@ StarFreedomX机器人的小功能,自用
|
|
|
70
70
|
| `forward` | 消息转发功能 |
|
|
71
71
|
| `exchangeRate` | 汇率播报功能 |
|
|
72
72
|
| `myId` | 我的会话信息 |
|
|
73
|
+
| `pickup` | 车牌检测 |
|
|
73
74
|
|
|
74
75
|
---
|
|
75
76
|
|
|
@@ -130,3 +131,5 @@ StarFreedomX机器人的小功能,自用
|
|
|
130
131
|
| `0.26.6` | 修正roll扔骰子的判断错误 |
|
|
131
132
|
| `0.26.8` | 修复sharp库传回参数改为对象的错误 |
|
|
132
133
|
| `0.27.0` | 新增监听车牌修改群名功能 |
|
|
134
|
+
| `0.27.1` | 车牌监听权限设置 |
|
|
135
|
+
| `0.27.2` | 车牌检测可以保留其他文字 |
|