1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-11-24 08:32:23 +02:00

Add kook notification provider

This commit is contained in:
401Unauthorized 2022-12-27 14:05:45 +08:00
parent f6ea1fe9a5
commit c60b741406
No known key found for this signature in database
6 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,31 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class Kook extends NotificationProvider {
name = "Kook";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
let url = "https://www.kookapp.cn/api/v3/message/create";
let data = {
target_id: notification.kookGuildID,
content: msg,
};
let config = {
headers: {
"Authorization": "Bot " + notification.kookBotToken,
"Content-Type": "application/json",
},
};
try {
await axios.post(url, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Kook;

View File

@ -14,6 +14,7 @@ const GoogleChat = require("./notification-providers/google-chat");
const Gorush = require("./notification-providers/gorush");
const Gotify = require("./notification-providers/gotify");
const HomeAssistant = require("./notification-providers/home-assistant");
const Kook = require("./notification-providers/kook");
const Line = require("./notification-providers/line");
const LineNotify = require("./notification-providers/linenotify");
const LunaSea = require("./notification-providers/lunasea");
@ -70,6 +71,7 @@ class Notification {
new Gorush(),
new Gotify(),
new HomeAssistant(),
new Kook(),
new Line(),
new LineNotify(),
new LunaSea(),

View File

@ -0,0 +1,36 @@
<template>
<div class="mb-3">
<label for="kook-bot-token" class="form-label">{{ $t("Bot Token") }}</label>
<HiddenInput id="kook-bot-token" v-model="$parent.notification.kookBotToken" :required="true" autocomplete="new-password"></HiddenInput>
<i18n-t tag="div" keypath="wayToGetKookBotToken" class="form-text">
<a href="https://developer.kookapp.cn/bot" target="_blank">https://developer.kookapp.cn/bot</a>
</i18n-t>
</div>
<div class="mb-3">
<label for="kook-guild-id" class="form-label">{{ $t("Guild ID") }}</label>
<div class="input-group mb-3">
<input id="kook-guild-id" v-model="$parent.notification.kookGuildID" type="text" class="form-control" required>
</div>
<div class="form-text">
<p style="margin-top: 8px;">
{{ $t("wayToGetKookGuildID") }}
</p>
</div>
</div>
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
<a href="https://developer.kookapp.cn" target="_blank">https://developer.kookapp.cn</a>
</i18n-t>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
}
}
</script>

View File

@ -12,6 +12,7 @@ import GoogleChat from "./GoogleChat.vue";
import Gorush from "./Gorush.vue";
import Gotify from "./Gotify.vue";
import HomeAssistant from "./HomeAssistant.vue";
import Kook from "./Kook.vue";
import Line from "./Line.vue";
import LineNotify from "./LineNotify.vue";
import LunaSea from "./LunaSea.vue";
@ -63,6 +64,7 @@ const NotificationFormList = {
"gorush": Gorush,
"gotify": Gotify,
"HomeAssistant": HomeAssistant,
"Kook": Kook,
"line": Line,
"LineNotify": LineNotify,
"lunasea": LunaSea,

View File

@ -270,6 +270,10 @@ export default {
apprise: "Apprise (Support 50+ Notification services)",
GoogleChat: "Google Chat (Google Workspace only)",
pushbullet: "Pushbullet",
Kook: "Kook",
wayToGetKookBotToken: "Create application and get your bot token at {0}",
wayToGetKookGuildID: "Switch on 'Developer Mode' in Kook setting, and right click the guild to get its ID",
"Guild ID": "Guild ID",
line: "Line Messenger",
mattermost: "Mattermost",
"User Key": "User Key",

View File

@ -250,6 +250,10 @@ export default {
apprise: "Apprise (支持 50+ 种通知服务)",
GoogleChat: "Google Chat(仅 Google Workspace)",
pushbullet: "Pushbullet",
Kook: "Kook",
wayToGetKookBotToken: "在 {0} 创建应用并获取机器人 Token",
wayToGetKookGuildID: "在Kook设置中打开 ‘开发者模式’,然后右键频道可获取其 ID",
"Guild ID": "频道 ID",
line: "Line Messenger",
mattermost: "Mattermost",
"User Key": "User Key",