koishi-plugin-node-async-bot-all 1.0.4 → 1.1.0

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.
Files changed (2) hide show
  1. package/lib/index.js +24 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -187,13 +187,35 @@ async function getStatus(ctx, session) {
187
187
  return msg;
188
188
  }
189
189
  __name(getStatus, "getStatus");
190
+ async function getRandom(ctx, session, min, max) {
191
+ ctx.logger.info("Got: " + session.text(".message", {
192
+ platform: session.platform,
193
+ selfId: session.selfId
194
+ }));
195
+ const time = getHongKongTime();
196
+ let msg;
197
+ if (min == void 0 || max == void 0) {
198
+ min = 0;
199
+ max = 1e4;
200
+ }
201
+ min = Math.ceil(min);
202
+ max = Math.floor(max);
203
+ msg = `${time}
204
+ 生成的随机数:` + (Math.floor(Math.random() * (max - min + 1)) + min) + `(${min},${max})`;
205
+ ctx.logger.info("Sent: " + msg);
206
+ return msg;
207
+ }
208
+ __name(getRandom, "getRandom");
190
209
  function apply(ctx) {
191
- ctx.command("cx").action(({ session }) => {
210
+ ctx.command("cx", "查询服务器当前人数。").action(({ session }) => {
192
211
  return getServer(ctx, session);
193
212
  });
194
- ctx.command("status").action(({ session }) => {
213
+ ctx.command("status", "查询机器人状态。").action(({ session }) => {
195
214
  return getStatus(ctx, session);
196
215
  });
216
+ ctx.command("random [最小数:number] [最大数:number]", "随机数生成器,缺少参数时默认生成 0-10000 的随机数。").action(({ session }, min, max) => {
217
+ return getRandom(ctx, session, min, max);
218
+ });
197
219
  }
198
220
  __name(apply, "apply");
199
221
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-node-async-bot-all",
3
3
  "description": "插件",
4
- "version": "1.0.4",
4
+ "version": "1.1.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [