mirror of
				https://github.com/louislam/uptime-kuma.git
				synced 2025-10-25 07:39:22 +08:00 
			
		
		
		
	Merge pull request #2478 from YehowahLiu/master
Add Kook notification provider
This commit is contained in:
		
							
								
								
									
										31
									
								
								server/notification-providers/kook.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								server/notification-providers/kook.js
									
									
									
									
									
										Normal 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; | ||||
| @@ -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"); | ||||
| @@ -71,6 +72,7 @@ class Notification { | ||||
|             new Gorush(), | ||||
|             new Gotify(), | ||||
|             new HomeAssistant(), | ||||
|             new Kook(), | ||||
|             new Line(), | ||||
|             new LineNotify(), | ||||
|             new LunaSea(), | ||||
|   | ||||
							
								
								
									
										36
									
								
								src/components/notifications/Kook.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/components/notifications/Kook.vue
									
									
									
									
									
										Normal 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> | ||||
| @@ -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"; | ||||
| @@ -64,6 +65,7 @@ const NotificationFormList = { | ||||
|     "gorush": Gorush, | ||||
|     "gotify": Gotify, | ||||
|     "HomeAssistant": HomeAssistant, | ||||
|     "Kook": Kook, | ||||
|     "line": Line, | ||||
|     "LineNotify": LineNotify, | ||||
|     "lunasea": LunaSea, | ||||
|   | ||||
| @@ -272,6 +272,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", | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user