Compare commits

..

2 Commits

Author SHA1 Message Date
last2014 2b53b8cd3d v8.0.2 2025-08-07 08:56:49 +09:00
last2014 d20f630e1b v8.0.1 2025-08-07 08:47:11 +09:00
6 changed files with 32 additions and 10 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "notice-uwuzu", "name": "notice-uwuzu",
"version": "v8.0@uwuzu1.6.1", "version": "v8.0.2@uwuzu1.6.1",
"tag": "v8.0", "tag": "v8.0.2",
"description": "Notice Bot for uwuzu", "description": "Notice Bot for uwuzu",
"main": "dist/main.js", "main": "dist/main.js",
"scripts": { "scripts": {
+2 -2
View File
@@ -8,8 +8,7 @@ import CommandExecute from "./route/command.js";
import ueusePost from "./route/ueuse.js"; import ueusePost from "./route/ueuse.js";
import WeatherUeuse from "./route/weather.js"; import WeatherUeuse from "./route/weather.js";
import API from "./route/api.js"; import API from "./route/api.js";
import Token from "./route/token.js";
AdminPanel();
export default async function AdminPanel() { export default async function AdminPanel() {
// 無効 // 無効
@@ -26,6 +25,7 @@ export default async function AdminPanel() {
app.use(CommandExecute); app.use(CommandExecute);
app.use(WeatherUeuse); app.use(WeatherUeuse);
app.use(API); app.use(API);
app.use(Token);
app.use(express.static("panel/public")); app.use(express.static("panel/public"));
app.listen(port, () => { app.listen(port, () => {
+6 -2
View File
@@ -13,7 +13,7 @@ document.getElementById("commandExec").addEventListener("click", async () => {
}); });
document.getElementById("weatherUeuse").addEventListener("click", async () => { document.getElementById("weatherUeuse").addEventListener("click", async () => {
const req = await fetch("/actions/weatherUeuse", { const req = await fetch("/actions/weather", {
method: "POST", method: "POST",
}); });
@@ -57,6 +57,10 @@ document.getElementById("ueuse").addEventListener("click", async () => {
}); });
document.getElementById("api").addEventListener("click", async () => { document.getElementById("api").addEventListener("click", async () => {
const token = await (await fetch("/actions/token", {
method: "GET",
})).text();
const endpoint = prompt("エンドポイント", "/serverinfo-api").toLowerCase(); const endpoint = prompt("エンドポイント", "/serverinfo-api").toLowerCase();
if (endpoint === "") { if (endpoint === "") {
@@ -64,7 +68,7 @@ document.getElementById("api").addEventListener("click", async () => {
return; return;
} }
const body = prompt("body(JSON)", `{"key": "value"}`).toLowerCase(); const body = prompt("body(JSON)", `{"token": "${token}"}`).toLowerCase();
if (body === "") { if (body === "") {
alert("bodyが設定されていません。"); alert("bodyが設定されていません。");
+1 -2
View File
@@ -8,8 +8,7 @@ API.use(express.urlencoded({ extended: true }));
API.post("/actions/api", async (req, res, next) => { API.post("/actions/api", async (req, res, next) => {
const endpoint = req.body.endpoint; const endpoint = req.body.endpoint;
let body = req.body.body const body = req.body.body;
body["token"] = config.uwuzu.apiToken;
try { try {
const apiReq = await fetch(`https://${config.uwuzu.host}/api${endpoint}`, { const apiReq = await fetch(`https://${config.uwuzu.host}/api${endpoint}`, {
+19
View File
@@ -0,0 +1,19 @@
import express from "express";
const Token = express.Router();
import config from "../../config.js";
Token.use(express.json());
Token.use(express.urlencoded({ extended: true }));
Token.post("/actions/token", (req, res, next) => {
res.status(501)
.send("GET Only");
});
Token.get("/actions/token", (req, res) => {
res.status(200)
.send(config.uwuzu.apiToken);
});
export default Token;
+2 -2
View File
@@ -3,7 +3,7 @@ const WeatherUeuse = express.Router();
import { weatherNotice } from "../../scripts/weatherNotice.js"; import { weatherNotice } from "../../scripts/weatherNotice.js";
WeatherUeuse.post("/actions/command-execute", (req, res) => { WeatherUeuse.post("/actions/weather", (req, res) => {
try { try {
(async () => { (async () => {
await weatherNotice(); await weatherNotice();
@@ -17,7 +17,7 @@ WeatherUeuse.post("/actions/command-execute", (req, res) => {
} }
}); });
WeatherUeuse.get("/actions/command-execute", (req, res) => { WeatherUeuse.get("/actions/weather", (req, res) => {
res.status(501) res.status(501)
.send("POST Only"); .send("POST Only");
}); });