@zhin.js/plugin-earthquake 0.1.0 → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # @zhin.js/plugin-earthquake
2
+
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [6da2bad]
8
+ - Updated dependencies [3781f1c]
9
+ - @zhin.js/tool@1.1.9
10
+ - @zhin.js/skill@1.1.9
11
+
12
+ ## 0.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - e40899f: Adapters now project group owners and admins onto the canonical `sender.roles` names `owner` / `admin` (Telegram creator/administrator, KOOK guild owner and admin-permission roles, Lark chat owner/managers, QQ official guild owner/admin identities). KOOK numeric role ids moved from `roles` to `permissions` (`role:<id>`). `@zhin.js/command` exports `canManageConversation` ("private chat or owner/admin/master"), now shared by the Bilibili and earthquake subscription commands; Roulette lets owners and admins toggle the mute penalty and cancel a game.
17
+ - 520f64b: Add `@zhin.js/plugin-earthquake`: the `地震` query plus per-conversation alert subscriptions (`地震 订阅|退订|订阅状态`) with magnitude thresholds and region keywords, merging CENC (mirror-backed, configurable URLs) and USGS with cross-source de-duplication. Every request has a timeout, jittered exponential backoff with Retry-After support, per-source cooldown and failover; the poller never throws, baselines each source before pushing, and rate-limits pushes per conversation. Includes the read-only agent tool `recent_earthquakes`.
18
+ - Updated dependencies [1a11207]
19
+ - Updated dependencies [9943df6]
20
+ - @zhin.js/tool@1.1.8
21
+ - @zhin.js/skill@1.1.8
@@ -1,7 +1,7 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- import { defineCommand } from 'zhin.js/command';
2
+ import { canManageConversation, defineCommand } from 'zhin.js/command';
3
3
  import { conversationError, extractConversation } from "../../../lib/conversation.js";
4
- import { canManageSubscription, SUBSCRIPTION_PERMISSION_DENIED_MESSAGE } from '../manage-permission.js';
4
+ import { SUBSCRIPTION_PERMISSION_DENIED_MESSAGE } from "../../../lib/permission.js";
5
5
  import { earthquakeServiceToken } from "../../../lib/runtime.js";
6
6
  import { parseSubscribeArgs } from "../../../lib/subscribe-args.js";
7
7
  import { SubscriptionLimitError } from "../../../lib/subscriptions.js";
@@ -15,7 +15,7 @@ export default defineCommand({
15
15
  const target = extractConversation(input);
16
16
  if (!target)
17
17
  return conversationError(input);
18
- if (!canManageSubscription({ adapter, scene, sender }))
18
+ if (!canManageConversation({ adapter, scene, sender }))
19
19
  return SUBSCRIPTION_PERMISSION_DENIED_MESSAGE;
20
20
  const parsed = parseSubscribeArgs(params.filters ?? []);
21
21
  if ('error' in parsed)
@@ -1,7 +1,7 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- import { defineCommand } from 'zhin.js/command';
2
+ import { canManageConversation, defineCommand } from 'zhin.js/command';
3
3
  import { conversationError, extractConversation } from "../../../lib/conversation.js";
4
- import { canManageSubscription, SUBSCRIPTION_PERMISSION_DENIED_MESSAGE } from '../manage-permission.js';
4
+ import { SUBSCRIPTION_PERMISSION_DENIED_MESSAGE } from "../../../lib/permission.js";
5
5
  import { earthquakeServiceToken } from "../../../lib/runtime.js";
6
6
  import { subscriptionKey } from "../../../lib/subscriptions.js";
7
7
  export default defineCommand({
@@ -11,7 +11,7 @@ export default defineCommand({
11
11
  const target = extractConversation(input);
12
12
  if (!target)
13
13
  return conversationError(input);
14
- if (!canManageSubscription({ adapter, scene, sender }))
14
+ if (!canManageConversation({ adapter, scene, sender }))
15
15
  return SUBSCRIPTION_PERMISSION_DENIED_MESSAGE;
16
16
  const removed = await service.store.remove(subscriptionKey(target));
17
17
  return removed ? '已取消本会话的地震速报订阅' : '本会话没有地震速报订阅';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Who may change a conversation's earthquake subscriptions.
3
+ *
4
+ * - Private chat: the user manages their own conversation, no restriction.
5
+ * - Group or channel: only the group owner, group admins or the bot master.
6
+ *
7
+ * The rule itself lives in `canManageConversation` (`zhin.js/command`); adapters project
8
+ * the canonical `owner` / `admin` role names that it checks.
9
+ */
10
+ export declare const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = "\u53EA\u6709\u7FA4\u4E3B\u3001\u7FA4\u7BA1\u7406\u5458\u6216\u673A\u5668\u4EBA\u4E3B\u4EBA\u53EF\u4EE5\u5728\u7FA4\u804A\u4E2D\u4FEE\u6539\u5730\u9707\u8BA2\u9605\uFF1B\u79C1\u804A\u4E2D\u53EF\u4EE5\u76F4\u63A5\u8BA2\u9605\u672C\u4F1A\u8BDD\u3002";
11
+ //# sourceMappingURL=permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,2PACN,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Who may change a conversation's earthquake subscriptions.
3
+ *
4
+ * - Private chat: the user manages their own conversation, no restriction.
5
+ * - Group or channel: only the group owner, group admins or the bot master.
6
+ *
7
+ * The rule itself lives in `canManageConversation` (`zhin.js/command`); adapters project
8
+ * the canonical `owner` / `admin` role names that it checks.
9
+ */
10
+ export const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = '只有群主、群管理员或机器人主人可以在群聊中修改地震订阅;私聊中可以直接订阅本会话。';
11
+ //# sourceMappingURL=permission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.js","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sCAAsC,GACjD,2CAA2C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/plugin-earthquake",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Earthquake query and group alert plugin for Zhin.js — CENC + USGS, magnitude/region subscriptions (Plugin Runtime)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -41,21 +41,21 @@
41
41
  },
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
- "@zhin.js/skill": "1.1.7",
45
- "@zhin.js/tool": "1.1.7"
44
+ "@zhin.js/skill": "1.1.9",
45
+ "@zhin.js/tool": "1.1.9"
46
46
  },
47
47
  "devDependencies": {
48
48
  "typescript": "^6.0.3",
49
49
  "vitest": "^4.1.10",
50
50
  "zod": "^4.4.3",
51
- "@zhin.js/command": "1.1.8",
52
- "zhin.js": "1.1.11",
53
- "@zhin.js/testing": "1.0.4"
51
+ "@zhin.js/command": "1.1.10",
52
+ "@zhin.js/testing": "1.0.5",
53
+ "zhin.js": "1.1.15"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "zod": "^4.0.0",
57
- "@zhin.js/command": "^1.1.8",
58
- "zhin.js": "^1.1.11"
57
+ "@zhin.js/command": "^1.1.10",
58
+ "zhin.js": "^1.1.15"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "@zhin.js/command": {
@@ -1,20 +0,0 @@
1
- // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- /**
3
- * Who may change a conversation's earthquake subscription.
4
- *
5
- * - Private chat: the user manages their own conversation, no restriction.
6
- * - Group or channel: only the group owner, group admins or the bot master.
7
- *
8
- * `permit` lists are AND-only, so this "private OR role(...)" rule is evaluated
9
- * with the same built-in permit checker the command router uses. Roles come
10
- * from the adapter's platform-agnostic projection (`sender.role`).
11
- */
12
- import { checkBuiltinPermit } from '@zhin.js/command';
13
- export const SUBSCRIPTION_MANAGER_ROLES_PERMIT = 'role(owner,admin,master)';
14
- export const PRIVATE_CHAT_PERMIT = 'private()';
15
- export const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = '只有群主、群管理员或机器人主人可以在群聊中修改地震订阅;私聊中可以直接订阅本会话。';
16
- export function canManageSubscription(subject) {
17
- if (checkBuiltinPermit(PRIVATE_CHAT_PERMIT, subject))
18
- return true;
19
- return checkBuiltinPermit(SUBSCRIPTION_MANAGER_ROLES_PERMIT, subject);
20
- }