koishi-plugin-ciyi 1.2.4 → 1.2.6
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 -1
- package/lib/index.js +29 -25
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Schema } from "koishi";
|
|
2
2
|
import { History } from "./view";
|
|
3
3
|
export declare const name = "ciyi";
|
|
4
|
-
export declare const usage = "
|
|
4
|
+
export declare const usage = "## \u4F7F\u7528\n\n\u8BBE\u7F6E\u6307\u4EE4\u522B\u540D\u540E\uFF0C\u53D1\u9001 `ciyi` \u67E5\u770B\u73A9\u6CD5\u3002\u6BCF\u65E5\u85CF\u4E00\u4E2A\u4E24\u5B57\u8BCD\uFF0C\u7B2C\u4E00\u6B21\u731C\u6D4B\u4F1A\u81EA\u52A8\u5F00\u9898\u3002\n\n## \u6307\u4EE4\n\n| \u6307\u4EE4 | \u8BF4\u660E |\n| --- | --- |\n| `ciyi` | \u73A9\u6CD5\u8BF4\u660E |\n| `ciyi.\u731C <\u8BCD>` | \u5F00\u59CB\u4ECA\u65E5\u6E38\u620F\u5E76\u63D0\u4EA4\u731C\u6D4B |\n| `ciyi.\u6392\u884C\u699C` | \u731C\u4E2D\u6B21\u6570\u699C |";
|
|
5
5
|
export declare const inject: {
|
|
6
6
|
required: string[];
|
|
7
7
|
optional: string[];
|
package/lib/index.js
CHANGED
|
@@ -734,8 +734,15 @@ function renderWinCard(service, opts) {
|
|
|
734
734
|
__name(renderWinCard, "renderWinCard");
|
|
735
735
|
function renderRankCard(service, opts) {
|
|
736
736
|
const innerW = s(620);
|
|
737
|
-
const
|
|
738
|
-
const
|
|
737
|
+
const headerH = s(87);
|
|
738
|
+
const contentGap = s(20);
|
|
739
|
+
const rowH = s(52);
|
|
740
|
+
const emptyH = s(92);
|
|
741
|
+
const hiddenH = opts.hidden > 0 ? s(36) : 0;
|
|
742
|
+
const footerGap = s(20);
|
|
743
|
+
const footerH = s(60);
|
|
744
|
+
const contentH = opts.entries.length ? opts.entries.length * rowH + hiddenH : emptyH;
|
|
745
|
+
const innerH = headerH + contentGap + contentH + footerGap + footerH;
|
|
739
746
|
return toPng(service, innerW, innerH, (ctx, ix, iy, iw, ih) => {
|
|
740
747
|
let y = iy + drawHeader(ctx, ix, iy, iw, "每日挑战 · 累计猜中", {
|
|
741
748
|
big: String(opts.players),
|
|
@@ -743,11 +750,12 @@ function renderRankCard(service, opts) {
|
|
|
743
750
|
});
|
|
744
751
|
y += s(20);
|
|
745
752
|
if (!opts.entries.length) {
|
|
753
|
+
drawPanel(ctx, ix + s(22), y, iw - s(44), emptyH);
|
|
746
754
|
textCenter(
|
|
747
755
|
ctx,
|
|
748
756
|
"榜上无名。",
|
|
749
757
|
ix + iw / 2,
|
|
750
|
-
y + s(
|
|
758
|
+
y + s(31),
|
|
751
759
|
`${s(13.5)}px ${FONT_SERIF}`,
|
|
752
760
|
C.ink3
|
|
753
761
|
);
|
|
@@ -755,7 +763,7 @@ function renderRankCard(service, opts) {
|
|
|
755
763
|
ctx,
|
|
756
764
|
"今日第一个猜中的人,会写在这里。",
|
|
757
765
|
ix + iw / 2,
|
|
758
|
-
y + s(
|
|
766
|
+
y + s(61),
|
|
759
767
|
`${s(13.5)}px ${FONT_SERIF}`,
|
|
760
768
|
C.ink3
|
|
761
769
|
);
|
|
@@ -763,7 +771,6 @@ function renderRankCard(service, opts) {
|
|
|
763
771
|
let ry = y;
|
|
764
772
|
for (let i = 0; i < opts.entries.length; i++) {
|
|
765
773
|
const e = opts.entries[i];
|
|
766
|
-
const rowH = s(52);
|
|
767
774
|
const midY = ry + rowH / 2;
|
|
768
775
|
if (e.me) {
|
|
769
776
|
ctx.fillStyle = "rgba(178,58,46,0.055)";
|
|
@@ -793,9 +800,13 @@ function renderRankCard(service, opts) {
|
|
|
793
800
|
const name2 = e.username || "无名氏";
|
|
794
801
|
const nameX = px + posSize + s(14);
|
|
795
802
|
const nameFont = `${s(15)}px ${FONT_SERIF}`;
|
|
803
|
+
const score = String(e.score);
|
|
804
|
+
const scoreRight = ix + iw - s(38);
|
|
805
|
+
const scoreLeft = scoreRight - textWidth(score, s(19));
|
|
806
|
+
const meWidth = e.me ? textWidth("我", s(10.5)) + s(18) : 0;
|
|
796
807
|
const fittedName = ellipsize(
|
|
797
808
|
name2,
|
|
798
|
-
|
|
809
|
+
Math.max(0, scoreLeft - s(18) - nameX - meWidth),
|
|
799
810
|
s(15)
|
|
800
811
|
);
|
|
801
812
|
textLeft(ctx, fittedName, nameX, midY, nameFont, C.ink);
|
|
@@ -805,8 +816,8 @@ function renderRankCard(service, opts) {
|
|
|
805
816
|
}
|
|
806
817
|
textRight(
|
|
807
818
|
ctx,
|
|
808
|
-
|
|
809
|
-
|
|
819
|
+
score,
|
|
820
|
+
scoreRight,
|
|
810
821
|
midY,
|
|
811
822
|
`700 ${s(19)}px ${FONT_NUM}`,
|
|
812
823
|
C.ink
|
|
@@ -847,29 +858,22 @@ __name(renderRankCard, "renderRankCard");
|
|
|
847
858
|
|
|
848
859
|
// src/index.ts
|
|
849
860
|
var name = "ciyi";
|
|
850
|
-
var usage =
|
|
851
|
-
|
|
852
|
-
按「意思有多近」找词:系统每天藏起一个两字词,你报词,它回你这个词与答案的语义排名。
|
|
853
|
-
名次越小越近,**#1 就是答案本身**。
|
|
854
|
-
|
|
855
|
-
## 使用
|
|
856
|
-
|
|
857
|
-
1. 设置指令别名(推荐把 \`ciyi.猜\` 设为 \`猜\`)。
|
|
858
|
-
2. 发送 \`ciyi.猜 山水\` 直接开始今日游戏并提交第一猜。
|
|
859
|
-
|
|
860
|
-
## 图片
|
|
861
|
+
var usage = `## 使用
|
|
861
862
|
|
|
862
|
-
|
|
863
|
-
没有绘图服务、渲染失败或关掉「渲染图片」时,自动回退为等价文本,玩法不受影响。
|
|
863
|
+
设置指令别名后,发送 \`ciyi\` 查看玩法。每日藏一个两字词,第一次猜测会自动开题。
|
|
864
864
|
|
|
865
|
-
##
|
|
865
|
+
## 指令
|
|
866
866
|
|
|
867
|
-
|
|
867
|
+
| 指令 | 说明 |
|
|
868
|
+
| --- | --- |
|
|
869
|
+
| \`ciyi\` | 玩法说明 |
|
|
870
|
+
| \`ciyi.猜 <词>\` | 开始今日游戏并提交猜测 |
|
|
871
|
+
| \`ciyi.排行榜\` | 猜中次数榜 |`;
|
|
868
872
|
var inject = { required: ["database"], optional: ["canvas"] };
|
|
869
873
|
var Config = import_koishi.Schema.object({
|
|
870
874
|
atReply: import_koishi.Schema.boolean().default(false).description("响应时 @"),
|
|
871
|
-
quoteReply: import_koishi.Schema.boolean().default(
|
|
872
|
-
isEnableMiddleware: import_koishi.Schema.boolean().default(
|
|
875
|
+
quoteReply: import_koishi.Schema.boolean().default(false).description("响应时引用"),
|
|
876
|
+
isEnableMiddleware: import_koishi.Schema.boolean().default(true).description("是否启用中间件(若启用,猜测词语时可以不使用指令直接猜测)"),
|
|
873
877
|
renderImage: import_koishi.Schema.boolean().default(true).description("渲染图片(复用 Koishi Canvas 服务;不可用时使用等价文本)"),
|
|
874
878
|
maxHistory: import_koishi.Schema.number().default(10).min(0).description("猜测板最多列出的历史条数(最新一次猜测始终会列出)"),
|
|
875
879
|
maxRank: import_koishi.Schema.number().default(10).min(0).description("最大排行榜人数")
|