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 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 = "# \u8BCD\u610F\n\n\u6309\u300C\u610F\u601D\u6709\u591A\u8FD1\u300D\u627E\u8BCD\uFF1A\u7CFB\u7EDF\u6BCF\u5929\u85CF\u8D77\u4E00\u4E2A\u4E24\u5B57\u8BCD\uFF0C\u4F60\u62A5\u8BCD\uFF0C\u5B83\u56DE\u4F60\u8FD9\u4E2A\u8BCD\u4E0E\u7B54\u6848\u7684\u8BED\u4E49\u6392\u540D\u3002\n\u540D\u6B21\u8D8A\u5C0F\u8D8A\u8FD1\uFF0C**#1 \u5C31\u662F\u7B54\u6848\u672C\u8EAB**\u3002\n\n## \u4F7F\u7528\n\n1. \u8BBE\u7F6E\u6307\u4EE4\u522B\u540D\uFF08\u63A8\u8350\u628A `ciyi.\u731C` \u8BBE\u4E3A `\u731C`\uFF09\u3002\n2. \u53D1\u9001 `ciyi.\u731C \u5C71\u6C34` \u76F4\u63A5\u5F00\u59CB\u4ECA\u65E5\u6E38\u620F\u5E76\u63D0\u4EA4\u7B2C\u4E00\u731C\u3002\n\n## \u56FE\u7247\n\n\u542F\u7528 Koishi Canvas \u670D\u52A1\u540E\u6E32\u67D3\u300C\u58A8\u4E0E\u7EB8\u300D\u98CE\u683C\u5361\u7247\uFF1BPuppeteer \u5DF2\u81EA\u5E26\u8BE5\u670D\u52A1\uFF0C\u65E0\u9700\u91CD\u590D\u5B89\u88C5\u7ED8\u56FE\u5E93\u3002\n\u6CA1\u6709\u7ED8\u56FE\u670D\u52A1\u3001\u6E32\u67D3\u5931\u8D25\u6216\u5173\u6389\u300C\u6E32\u67D3\u56FE\u7247\u300D\u65F6\uFF0C\u81EA\u52A8\u56DE\u9000\u4E3A\u7B49\u4EF7\u6587\u672C\uFF0C\u73A9\u6CD5\u4E0D\u53D7\u5F71\u54CD\u3002\n\n## QQ \u7FA4\n\n* 956758505";
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 rowCount = Math.max(opts.entries.length, 1);
738
- const innerH = s(120 + rowCount * 52 + (opts.hidden > 0 ? 36 : 0) + 60);
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(40),
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(68),
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
- ix + iw - s(118) - nameX - (e.me ? s(28) : 0),
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
- String(e.score),
809
- ix + iw - s(38),
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
- 启用 Koishi Canvas 服务后渲染「墨与纸」风格卡片;Puppeteer 已自带该服务,无需重复安装绘图库。
863
- 没有绘图服务、渲染失败或关掉「渲染图片」时,自动回退为等价文本,玩法不受影响。
863
+ 设置指令别名后,发送 \`ciyi\` 查看玩法。每日藏一个两字词,第一次猜测会自动开题。
864
864
 
865
- ## QQ 群
865
+ ## 指令
866
866
 
867
- * 956758505`;
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(true).description("响应时引用"),
872
- isEnableMiddleware: import_koishi.Schema.boolean().default(false).description("是否启用中间件(若启用,猜测词语时可以不使用指令直接猜测)"),
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("最大排行榜人数")
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ciyi",
3
3
  "description": "Koishi 的词意(猜词游戏)插件。根据词语的含义相似程度,猜测正确的词语。",
4
- "version": "1.2.4",
4
+ "version": "1.2.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [