mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-25 21:15:55 +00:00
Compare commits
7 commits
18bb0d64dd
...
d195820ce5
Author | SHA1 | Date | |
---|---|---|---|
|
d195820ce5 | ||
|
7dc6191b0a | ||
|
f0eaa46a02 | ||
|
b3e5d5ee8d | ||
|
b3d149b701 | ||
|
ef9b6d2be8 | ||
|
dab089086c |
8 changed files with 155 additions and 3 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "uptime-kuma",
|
||||
"version": "2.0.0-beta.0",
|
||||
"version": "2.0.0-beta.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "uptime-kuma",
|
||||
"version": "2.0.0-beta.0",
|
||||
"version": "2.0.0-beta.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "~1.8.22",
|
||||
|
|
|
@ -72,6 +72,7 @@ class GoogleChat extends NotificationProvider {
|
|||
|
||||
// construct json data
|
||||
let data = {
|
||||
fallbackText: chatHeader["title"],
|
||||
cardsV2: [
|
||||
{
|
||||
card: {
|
||||
|
|
88
server/notification-providers/onechat.js
Normal file
88
server/notification-providers/onechat.js
Normal file
|
@ -0,0 +1,88 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { DOWN, UP } = require("../../src/util");
|
||||
|
||||
class OneChat extends NotificationProvider {
|
||||
name = "OneChat";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = "https://chat-api.one.th/message/api/v1/push_message";
|
||||
|
||||
try {
|
||||
const config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + notification.accessToken,
|
||||
},
|
||||
};
|
||||
// Send a test message if the monitor is null
|
||||
if (heartbeatJSON == null) {
|
||||
const testMessage = {
|
||||
to: notification.recieverId,
|
||||
bot_id: notification.botId,
|
||||
type: "text",
|
||||
message: "Test Successful!",
|
||||
};
|
||||
await axios.post(url, testMessage, config);
|
||||
} else if (heartbeatJSON["status"] === DOWN) {
|
||||
const downMessage = {
|
||||
to: notification.recieverId,
|
||||
bot_id: notification.botId,
|
||||
type: "text",
|
||||
message:
|
||||
"UptimeKuma Alert:\n" +
|
||||
"[🔴 Down]\n" +
|
||||
"Name: " +
|
||||
monitorJSON["name"] +
|
||||
"\n" +
|
||||
heartbeatJSON["msg"] +
|
||||
"\n" +
|
||||
"Time (" +
|
||||
heartbeatJSON["timezone"] +
|
||||
"): " +
|
||||
heartbeatJSON["localDateTime"],
|
||||
};
|
||||
await axios.post(url, downMessage, config);
|
||||
} else if (heartbeatJSON["status"] === UP) {
|
||||
const upMessage = {
|
||||
to: notification.recieverId,
|
||||
bot_id: notification.botId,
|
||||
type: "text",
|
||||
message:
|
||||
"UptimeKuma Alert:\n" +
|
||||
"[🟢 Up]\n" +
|
||||
"Name: " +
|
||||
monitorJSON["name"] +
|
||||
"\n" +
|
||||
heartbeatJSON["msg"] +
|
||||
"\n" +
|
||||
"Time (" +
|
||||
heartbeatJSON["timezone"] +
|
||||
"): " +
|
||||
heartbeatJSON["localDateTime"],
|
||||
};
|
||||
await axios.post(url, upMessage, config);
|
||||
}
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
// Handle errors and throw a descriptive message
|
||||
if (error.response) {
|
||||
const errorMessage =
|
||||
error.response.data?.message ||
|
||||
"Unknown API error occurred.";
|
||||
throw new Error(`OneChat API Error: ${errorMessage}`);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Network or unexpected error: ${error.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OneChat;
|
|
@ -30,6 +30,7 @@ const Mattermost = require("./notification-providers/mattermost");
|
|||
const Nostr = require("./notification-providers/nostr");
|
||||
const Ntfy = require("./notification-providers/ntfy");
|
||||
const Octopush = require("./notification-providers/octopush");
|
||||
const OneChat = require("./notification-providers/onechat");
|
||||
const OneBot = require("./notification-providers/onebot");
|
||||
const Opsgenie = require("./notification-providers/opsgenie");
|
||||
const PagerDuty = require("./notification-providers/pagerduty");
|
||||
|
@ -116,6 +117,7 @@ class Notification {
|
|||
new Nostr(),
|
||||
new Ntfy(),
|
||||
new Octopush(),
|
||||
new OneChat(),
|
||||
new OneBot(),
|
||||
new Onesender(),
|
||||
new Opsgenie(),
|
||||
|
|
|
@ -135,6 +135,7 @@ export default {
|
|||
"nostr": "Nostr",
|
||||
"ntfy": "Ntfy",
|
||||
"octopush": "Octopush",
|
||||
"OneChat": "OneChat",
|
||||
"OneBot": "OneBot",
|
||||
"Onesender": "Onesender",
|
||||
"Opsgenie": "Opsgenie",
|
||||
|
|
55
src/components/notifications/OneChat.vue
Normal file
55
src/components/notifications/OneChat.vue
Normal file
|
@ -0,0 +1,55 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<!-- Access Token Input -->
|
||||
<div class="mb-3">
|
||||
<label for="onechat-access-token" class="form-label">
|
||||
Access Token<span style="color: red;"><sup>*</sup></span>
|
||||
</label>
|
||||
<input
|
||||
id="onechat-access-token"
|
||||
v-model="$parent.notification.accessToken"
|
||||
type="text"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
<div class="form-text">
|
||||
<p>{{ $t("OneChatAccessToken") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Receiver ID Input -->
|
||||
<div class="mb-3">
|
||||
<label for="onechat-receiver-id" class="form-label">
|
||||
{{ $t("OneChatUserIdOrGroupId") }}<span style="color: red;"><sup>*</sup></span>
|
||||
</label>
|
||||
<input
|
||||
id="onechat-receiver-id"
|
||||
v-model="$parent.notification.recieverId"
|
||||
type="text"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Bot ID Input -->
|
||||
<div class="mb-3">
|
||||
<label for="onechat-bot-id" class="form-label">
|
||||
{{ $t("OneChatBotId") }}<span style="color: red;"><sup>*</sup></span>
|
||||
</label>
|
||||
<input
|
||||
id="onechat-bot-id"
|
||||
v-model="$parent.notification.botId"
|
||||
type="text"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Document Link -->
|
||||
<div class="form-text">
|
||||
<i18n-t tag="p" keypath="Read more:">
|
||||
<a href="https://chat-develop.one.th/docs" target="_blank">https://chat-develop.one.th/docs</a>
|
||||
</i18n-t>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
|
@ -29,6 +29,7 @@ import Mattermost from "./Mattermost.vue";
|
|||
import Nostr from "./Nostr.vue";
|
||||
import Ntfy from "./Ntfy.vue";
|
||||
import Octopush from "./Octopush.vue";
|
||||
import OneChat from "./OneChat.vue";
|
||||
import OneBot from "./OneBot.vue";
|
||||
import Onesender from "./Onesender.vue";
|
||||
import Opsgenie from "./Opsgenie.vue";
|
||||
|
@ -103,6 +104,7 @@ const NotificationFormList = {
|
|||
"nostr": Nostr,
|
||||
"ntfy": Ntfy,
|
||||
"octopush": Octopush,
|
||||
"OneChat": OneChat,
|
||||
"OneBot": OneBot,
|
||||
"Onesender": Onesender,
|
||||
"Opsgenie": Opsgenie,
|
||||
|
|
|
@ -1051,5 +1051,8 @@
|
|||
"RabbitMQ Password": "RabbitMQ Password",
|
||||
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
|
||||
"SendGrid API Key": "SendGrid API Key",
|
||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas"
|
||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
|
||||
"OneChatAccessToken": "OneChat Access Token",
|
||||
"OneChatUserIdOrGroupId": "OneChat User ID or Group ID",
|
||||
"OneChatBotId": "OneChat Bot ID"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue