🌋 Earthquake Monitor v1.1.1
Real-time earthquake monitoring for China (CENC), Taiwan (CWA), and Japan (JMA) with proactive alerting.
v1.1.1 Changelog
v1.1.1 (Security Fix)
- - 🔒 Security Update - Removed encryption for ClawHub compatibility
- 📝 Added SECURITY.md documentation
v1.1.0 Features
- - 🌍 Multi-language Support - Alert messages in Chinese, English, and Japanese
- 📍 Location Fuzzy Matching - Supports pinyin (dali), abbreviations (DL), partial match (da)
- ⚡ Performance Optimization - Shared cache module with auto-cleanup
- ✅ Fixed Taiwan (CWA) data source integration
- ✅ Improved notification deduplication logic
Quick Start
CODEBLOCK0
Data Sources
| Source | Region | Language (Alert) | Description |
|---|
| CENC | 🇨🇳 China | 中文 | China Earthquake Networks Center |
| CWA |
🇹🇼 Taiwan | 中文 | Central Weather Administration |
| JMA | 🇯🇵 Japan | 日本語 | Japan Meteorological Agency |
API Reference
init(options)
Initialize configuration.
CODEBLOCK1
getAll(options)
Get earthquakes from all sources.
CODEBLOCK2
getCENC(limit)
Get China earthquake data.
CODEBLOCK3
getJMA(limit)
Get Japan earthquake data.
CODEBLOCK4
getCWA()
Get Taiwan earthquake early warning data.
CODEBLOCK5
start(options)
Start proactive monitoring with auto-alerts.
CODEBLOCK6
stop()
Stop monitoring.
CODEBLOCK7
config(newConfig)
View or update configuration.
CODEBLOCK8
cities()
List all supported cities with coordinates.
CODEBLOCK9
Configuration Options
| Option | Type | Default | Description |
|---|
| location | string/object | 大理 | City name or {name, latitude, longitude} |
| distanceThreshold |
number | 300 | Alert distance in km |
| minMagnitude | number | 3.0 | Minimum earthquake magnitude |
| language | string | zh | Alert language: zh/en/ja |
| sources.CENC | boolean | true | Enable China data |
| sources.JMA | boolean | true | Enable Japan data |
| sources.CWA | boolean | true | Enable Taiwan data |
| webhook | string | null | Encrypted webhook URL |
Supported Cities (20+)
| City | Pinyin | Abbr | Coordinates |
|---|
| 大理 | dali, dal, dl | DL | 25.61°N, 100.27°E |
| 北京 |
beijing, bj, b | BJ | 39.90°N, 116.40°E |
| 上海 | shanghai, sh, s | SH | 31.23°N, 121.47°E |
| 昆明 | kunming, km, k | KM | 25.04°N, 102.71°E |
| 成都 | chengdu, cd, c | CD | 30.57°N, 104.07°E |
| 东京 | tokyo, dj, d | DJ | 35.68°N, 139.69°E |
| ... | ... | ... | ... |
Location Matching Examples
All these return Beijing:
await init({ location: '北京' }) // Chinese
await init({ location: 'beijing' }) // Full pinyin
await init({ location: 'bj' }) // Abbreviation
await init({ location: 'bei' }) // Partial match
Multi-Language Alerts
Alert language is automatically selected based on earthquake source:
| Source | Language | Example |
|---|
| CENC (China) | 中文 | ⚠️ 地震预警提醒! |
| CWA (Taiwan) |
中文 | ⚠️ 地震预警提醒! |
| JMA (Japan) | 日本語 | ⚠️ 地震アラート! |
Manual Language Override
CODEBLOCK11
Alert Message Format
CODEBLOCK12
Security
Webhook URLs are encrypted using AES-256-CBC before storing in config file:
CODEBLOCK13
Performance
Shared Cache
- - Reduces redundant API calls
- TTL-based expiration (1 minute default)
- Auto-cleanup every 5 minutes
Parallel Fetching
- - All three data sources fetched simultaneously
- Fast response time
Return Format
CODEBLOCK14
Notes
- - 🌐 Data from official government agencies (CENC/CWA/JMA)
- 🔑 No API key required
- 📡 WebSocket + HTTP fallback
- 🔄 Auto-retry on failure
Support
- - Author: fungjcode
- GitHub: https://github.com/fungjcode/earthquake-monitor
- Report issues at: https://github.com/fungjcode/earthquake-monitor/issues
🌋 地震监测 v1.1.1
实时监测中国(CENC)、台湾(CWA)和日本(JMA)的地震,并主动推送警报。
v1.1.1 更新日志
v1.1.1(安全修复)
- - 🔒 安全更新 - 移除加密以兼容 ClawHub
- 📝 新增 SECURITY.md 文档
v1.1.0 功能
- - 🌍 多语言支持 - 支持中文、英文和日文的警报消息
- 📍 位置模糊匹配 - 支持拼音(dali)、缩写(DL)、部分匹配(da)
- ⚡ 性能优化 - 共享缓存模块,自动清理
- ✅ 修复 台湾(CWA)数据源集成
- ✅ 改进 通知去重逻辑
快速开始
javascript
// 初始化监测
await init({ location: 大理 })
// 获取最新地震
await getAll()
// 启动主动监测
await start()
数据源
| 数据源 | 地区 | 警报语言 | 说明 |
|---|
| CENC | 🇨🇳 中国 | 中文 | 中国地震台网中心 |
| CWA |
🇹🇼 台湾 | 中文 | 中央气象署 |
| JMA | 🇯🇵 日本 | 日本語 | 日本气象厅 |
API 参考
init(options)
初始化配置。
javascript
await init({
location: dali, // 城市名称(支持拼音、缩写)
distanceThreshold: 300, // 警报距离(公里)
minMagnitude: 3.0, // 最小震级
language: zh, // 语言:zh/en/ja
sources: { // 切换数据源
CENC: true,
JMA: true,
CWA: true
}
})
getAll(options)
获取所有数据源的地震信息。
javascript
const result = await getAll({ limit: 5 })
// 返回:{ earthquakes, totalCount, nearbyEarthquakes, hasAlert, alertMessage }
getCENC(limit)
获取中国地震数据。
javascript
const { earthquakes } = await getCENC(10)
getJMA(limit)
获取日本地震数据。
javascript
const { earthquakes } = await getJMA(10)
getCWA()
获取台湾地震预警数据。
javascript
const { earthquakes, isWarning } = await getCWA()
start(options)
启动主动监测并自动推送警报。
javascript
await start({ interval: 60000 }) // 每60秒检查一次
stop()
停止监测。
javascript
await stop()
config(newConfig)
查看或更新配置。
javascript
// 查看
const cfg = await config()
// 更新
await config({ language: en, minMagnitude: 4.0 })
cities()
列出所有支持的城市及其坐标。
javascript
const { cities } = await cities()
配置选项
| 选项 | 类型 | 默认值 | 说明 |
|---|
| location | string/object | 大理 | 城市名称或 {name, latitude, longitude} |
| distanceThreshold |
number | 300 | 警报距离(公里) |
| minMagnitude | number | 3.0 | 最小地震震级 |
| language | string | zh | 警报语言:zh/en/ja |
| sources.CENC | boolean | true | 启用中国数据 |
| sources.JMA | boolean | true | 启用日本数据 |
| sources.CWA | boolean | true | 启用台湾数据 |
| webhook | string | null | 加密的 Webhook URL |
支持的城市(20+)
| 城市 | 拼音 | 缩写 | 坐标 |
|---|
| 大理 | dali, dal, dl | DL | 25.61°N, 100.27°E |
| 北京 |
beijing, bj, b | BJ | 39.90°N, 116.40°E |
| 上海 | shanghai, sh, s | SH | 31.23°N, 121.47°E |
| 昆明 | kunming, km, k | KM | 25.04°N, 102.71°E |
| 成都 | chengdu, cd, c | CD | 30.57°N, 104.07°E |
| 东京 | tokyo, dj, d | DJ | 35.68°N, 139.69°E |
| ... | ... | ... | ... |
位置匹配示例
以下所有方式均可匹配北京:
javascript
await init({ location: 北京 }) // 中文
await init({ location: beijing }) // 全拼
await init({ location: bj }) // 缩写
await init({ location: bei }) // 部分匹配
多语言警报
警报语言根据地震来源自动选择:
| 数据源 | 语言 | 示例 |
|---|
| CENC(中国) | 中文 | ⚠️ 地震预警提醒! |
| CWA(台湾) |
中文 | ⚠️ 地震预警提醒! |
| JMA(日本) | 日本語 | ⚠️ 地震アラート! |
手动语言覆盖
javascript
// 设置首选语言(适用于警报格式)
await init({ language: en })
// 所有警报将统一使用英文,无论来源
警报消息格式
⚠️ Earthquake Alert!
📍 Epicenter near Dali:
- 1. 🔴 M7.6级 [中国地震台网]
📍 汤加群岛
📏 Distance: 5000km
⏰ 2026-03-24 12:37:50
📊 Depth: 250km
Please stay safe!
安全性
Webhook URL 在存储到配置文件前使用 AES-256-CBC 加密:
javascript
// 设置 webhook(自动加密)
await config({ webhook: https://oapi.dingtalk.com/robot/send?access_token=xxx })
// 存储时加密,仅在内存中解密
性能
共享缓存
- - 减少冗余 API 调用
- 基于 TTL 的过期机制(默认1分钟)
- 每5分钟自动清理
并行获取
返回格式
javascript
{
timestamp: 2026-03-24T14:30:00.000Z,
sources: [
{ source: CENC, sourceName: 中国地震台网, count: 10, earthquakes: [...] },
{ source: JMA, sourceName: 日本气象厅, count: 5, earthquakes: [...] }
],
earthquakes: [...], // 合并后按时间排序
totalCount: 15,
nearbyEarthquakes: [...], // 在距离阈值范围内
hasAlert: true/false,
alertMessage: ... // 格式化的警报字符串
}
注意事项
- - 🌐 数据来自官方政府机构(CENC/CWA/JMA)
- 🔑 无需 API 密钥
- 📡 WebSocket + HTTP 备用
- 🔄 失败时自动重试
支持
- - 作者:fungjcode
- GitHub:https://github.com/fungjcode/earthquake-monitor
- 问题反馈:https://github.com/fungjcode/earthquake-monitor/issues