-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
392 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"minecraft.descr.motd": "MCJE服务器信息查询", | ||
"minecraft.descr.motdbe": "MCBE服务器信息查询", | ||
"minecraft.descr.mcskin": "MC正版账号皮肤查询", | ||
"minecraft.descr.mcv": "查询Minecraft版本信息", | ||
"minecraft.msg.motd": "状态:在线\nIP:{0}\n端口:{1}\n物理地址:{2}\nMOTD:{3}\n协议版本:{4}\n游戏版本:{5}\n在线人数:{6} / {7}\n延迟:{8} ms\n图标:{9}", | ||
"minecraft.msg.motd.fail": "状态:离线\nIP:{0}\n端口:{1}", | ||
"minecraft.msg.motdbe": "状态:在线\nIP:{0}\n端口:{1}\n物理地址:{2}\nMOTD:{3}\n游戏模式:{4}\n协议版本:{5}\n游戏版本:{6}\n在线人数:{7} / {8}\n延迟: {9} ms", | ||
"minecraft.msg.motdbe.fail": "状态:离线\nIP:{0}\n端口:{1}", | ||
"minecraft.msg.mcskin": "玩家:{0}\n皮肤:{1}\n披风:{2}\n头颅:{3}", | ||
"minecraft.msg.mcskin.fail": "{0}查无此人!", | ||
"minecraft.msg.mcv": "MinecraftJava:\n最新版:{0}\n发布时间:{1}\n最新快照:{2}\n发布时间:{3}\nMinecraftBedrock:\n最新版:{4}\n发布时间:{5}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "kotori-plugin-minecraft", | ||
"version": "1.0.0", | ||
"description": "Plugin Of For Minecraft!", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "tsc --build" | ||
}, | ||
"keywords": [ | ||
"kotori", | ||
"chatbot", | ||
"kotori-plugin" | ||
], | ||
"license": "GPL-3.0", | ||
"files": [ | ||
"lib", | ||
"locales", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"author": "Hotaru <[email protected]>", | ||
"peerDependencies": { | ||
"kotori-bot": "workspace:^" | ||
}, | ||
"kotori": { | ||
"meta": { | ||
"language": [ | ||
"en_US", | ||
"ja_JP", | ||
"zh_TW", | ||
"zh_CN" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { Context, Tsu } from 'kotori-bot'; | ||
|
||
export const lang = [__dirname, '../locales']; | ||
|
||
const motdSchema = Tsu.Union([ | ||
Tsu.Object({ | ||
data: Tsu.Object({ | ||
status: Tsu.Literal('offline') | ||
}) | ||
}), | ||
Tsu.Object({ | ||
data: Tsu.Object({ | ||
status: Tsu.Literal('online'), | ||
ip: Tsu.String(), | ||
real: Tsu.String(), | ||
location: Tsu.String(), | ||
port: Tsu.String(), | ||
motd: Tsu.String(), | ||
version: Tsu.String(), | ||
agreement: Tsu.Number(), | ||
online: Tsu.Number(), | ||
max: Tsu.Number(), | ||
ping: Tsu.Number(), | ||
icon: Tsu.String() | ||
}) | ||
}) | ||
]); | ||
|
||
const motdbeSchema = Tsu.Union([ | ||
Tsu.Object({ | ||
data: Tsu.Object({ | ||
status: Tsu.Literal('offline') | ||
}) | ||
}), | ||
Tsu.Object({ | ||
data: Tsu.Object({ | ||
status: Tsu.Literal('online'), | ||
ip: Tsu.String(), | ||
real: Tsu.String(), | ||
location: Tsu.String(), | ||
port: Tsu.String(), | ||
motd: Tsu.String(), | ||
version: Tsu.String(), | ||
agreement: Tsu.Number(), | ||
online: Tsu.Number(), | ||
max: Tsu.Number(), | ||
delay: Tsu.Number(), | ||
gamemode: Tsu.String() | ||
}) | ||
}) | ||
]); | ||
|
||
export function main(ctx: Context) { | ||
ctx.command('motd <ip:string> [port:number=25565] - minecraft.descr.motd').action(async (data, session) => { | ||
const res = motdSchema.parse( | ||
await ctx.http.get('https://api.hotaru.icu/api/motd', { ip: data.args[0], port: data.args[1] }) | ||
); | ||
if (res.data.status !== 'online') return ['minecraft.msg.motd.fail', [data.args[0], data.args[1]]]; | ||
const { ip, port, location, motd, agreement, version, online, max, ping } = res.data; | ||
const icon = typeof res.data.icon === 'string' ? session.el.image(`base64://${res.data.icon.substring(22)}`) : ''; | ||
return ['minecraft.msg.motd', [ip, port, location, motd, agreement, version, online, max, ping, icon]]; | ||
}); | ||
|
||
ctx.command('motdbe <ip:string> [port:number=19132] - minecraft.descr.motdbe').action(async (data) => { | ||
const res = motdbeSchema.parse( | ||
await ctx.http.get('https://api.hotaru.icu/api/motdpe', { ip: data.args[0], port: data.args[1] }) | ||
); | ||
if (res.data.status !== 'online') return ['minecraft.msg.motdbe.fail', [data.args[0], data.args[1]]]; | ||
const { ip, port, location, motd, agreement, version, online, max, delay } = res.data; | ||
return ['minecraft.msg.motdbe', [ip, port, location, motd, agreement, version, online, max, delay]]; | ||
}); | ||
|
||
ctx | ||
.command('mcskin') | ||
.action(async (data) => { | ||
const res = await ctx.http.get('https://api.hotaru.icu/api/mcskin', { name: data.args[0] }); | ||
if (!isObj(res)) return ['BOT_RESULT.SERVER_ERROR', { res }]; | ||
if (res.code === 502 || !isObj(res.data)) return ['minecraft.msg.mcskin.fail', { input: data.args[0] }]; | ||
|
||
return [ | ||
'minecraft.msg.mcskin', | ||
{ | ||
input: data.args[0], | ||
skin: image(res.data.skin), | ||
cape: res.data.cape ? image(res.data.cape) : '', | ||
avatar: res.data.avatar ? image(`base64://${res.data.avatar.substring(22)}`) : '' | ||
} | ||
]; | ||
}) | ||
.help('minecraft.descr.mcskin'); | ||
|
||
ctx | ||
.command('mcv') | ||
.action(async () => { | ||
const res = await ctx.http.get('https://piston-meta.mojang.com/mc/game/version_manifest.json'); | ||
if (!res || !res.latest || !Array.isArray(res.versions)) return 'BOT_RESULT.SERVER_ERROR'; | ||
const res2 = await ctx.http.get('https://bugs.mojang.com/rest/api/2/project/10200/versions'); | ||
if (!res2 || !Array.isArray(res2)) return 'BOT_RESULT.SERVER_ERROR'; | ||
const date = { | ||
releaseDate: '', | ||
snapshotDate: '', | ||
mcbe: '', | ||
mcbeDate: '' | ||
}; | ||
let count = 0; | ||
for (const element of res.versions) { | ||
count += 1; | ||
if (count > 100) break; | ||
if (date.releaseDate && date.snapshotDate) break; | ||
if (element.id === res.latest.release) { | ||
date.releaseDate = formatTime(new Date(element.releaseTime)); | ||
continue; | ||
} | ||
if (element.id === res.latest.snapshot) date.snapshotDate = formatTime(new Date(element.releaseTime)); | ||
} | ||
for (const element of res2) { | ||
if (count > 100) break; | ||
if (!element.releaseDate) continue; | ||
date.mcbe = element.name; | ||
date.mcbeDate = formatTime(new Date(element.releaseDate)); | ||
break; | ||
} | ||
|
||
return ['minecraft.msg.mcv', { ...res.latest, ...date }]; | ||
}) | ||
.help('minecraft.descr.mcv'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.node.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./lib" | ||
}, | ||
"references": [ | ||
{ | ||
"path": "../../packages/kotori" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# @kotori-bot/kotori-plugin-status | ||
|
||
## Config | ||
|
||
```typescript | ||
interface Config { | ||
template?: string; | ||
} | ||
``` | ||
|
||
### Default | ||
|
||
```text | ||
服务器运行状态\n系统内核:%type%\n系统平台:%platform%\nCPU架构:%arch%\nCPU型号:%model%\nCPU频率:%speed%GHz\nCPU核心数:%num%\nCPU使用率:%cpu_rate%%\n内存总量:%total%GB\n可用内存:%used%GB\n内存使用率:%ram_rate%%\n网卡数量:%network%\n开机时间:%time%\n主机名字:%hostname%\n系统目录:%homedir% | ||
``` | ||
|
||
## Commands | ||
|
||
- `/status` View server running status | ||
|
||
## Reference | ||
|
||
- [Kotori Docs](https://kotori.js.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"Status.descr.status": "View server running status", | ||
"Status.msg.status": "Server running status \n System kernel:%type%\n System platform:%platform%\n CPU architecture:%arch%\n CPU model:%model%\n CPU frequency:%speed%GHz \n CPU cores:%num%\n CPU usage:%cpu_rate%%\n Total memory:%total%GB \n Free memory:%used%GB \n Memory usage:%ram_rate%%\n Number of network cards:%network%\n Boot time:%time%\n Host name:%host name%\n System directory:%homedir%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status.descr.status": "サーバーの稼働状態を表示", | ||
"status.msg.status": "サーバ稼働状態\nシステムコア:%type%\nシステムプラットフォーム:%platform%\nCPUアーキテクチャ:%arch%\nCPUモデル:%model%\nCPU周波数:%speed%GHz \nCPUコア数:%num%\nCPU使用率:%cpu_rate%\nメモリ総量:%total%GB \n使用可能内部記憶:%used%GB \nメモリ使用率:%ram_rate%\nネットワークカード数:%network%\n電源投入時間:%time%\nホスト名前:%hostname%\nシステムディレクトリ:%homedir%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status.descr.status": "查看服务器运行状态", | ||
"status.msg.status": "服务器运行状态\n系统内核:%type%\n系统平台:%platform%\nCPU架构:%arch%\nCPU型号:%model%\nCPU频率:%speed%GHz\nCPU核心数:%num%\nCPU使用率:%cpu_rate%%\n内存总量:%total%GB\n可用内存:%used%GB\n内存使用率:%ram_rate%%\n网卡数量:%network%\n开机时间:%time%\n主机名字:%hostname%\n系统目录:%homedir%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status.descr.status": "查看服務器運行狀態", | ||
"status.msg.status": "服務器運行狀態\n系統內核:%type%\n系統平台:%platform%\nCPU架構:%arch%\nCPU型號:%model%\nCPU頻率:%speed%GHz\nCPU核心數:%num%\nCPU使用率:%cpu_rate%%\n內存總量:%total%GB\n可用內存:%used%GB\n內存使用率:%ram_rate%%\n網卡數量:%network%\n開機時間:%time%\n主機名字:%hostname%\n系統目錄:%homedir%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@kotori-bot/kotori-plugin-status", | ||
"version": "1.0.0", | ||
"description": "status plugin", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "tsc --build" | ||
}, | ||
"keywords": [ | ||
"kotori", | ||
"chatbot", | ||
"kotori-plugin" | ||
], | ||
"license": "GPL-3.0", | ||
"files": [ | ||
"lib", | ||
"locales", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"author": "Hotaru <[email protected]>", | ||
"peerDependencies": { | ||
"kotori-bot": "workspace:^" | ||
}, | ||
"kotori": { | ||
"meta": { | ||
"language": [ | ||
"en_US", | ||
"ja_JP", | ||
"zh_TW", | ||
"zh_CN" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.