mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-18 04:04:41 -05:00
Fix #871
This commit is contained in:
parent
82cde7c847
commit
314fa18bdc
@ -25,13 +25,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p style="margin-top: 8px;">
|
<p style="margin-top: 8px;">
|
||||||
<template v-if="$parent.notification.telegramBotToken">
|
{{ telegramGetUpdatesURL() }}
|
||||||
<a :href="telegramGetUpdatesURL" target="_blank" style="word-break: break-word;">{{ telegramGetUpdatesURL }}</a>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
{{ telegramGetUpdatesURL }}
|
|
||||||
</template>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,49 +34,47 @@
|
|||||||
<script>
|
<script>
|
||||||
import HiddenInput from "../HiddenInput.vue";
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useToast } from "vue-toastification"
|
import { useToast } from "vue-toastification";
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
HiddenInput,
|
HiddenInput,
|
||||||
},
|
},
|
||||||
computed: {
|
methods: {
|
||||||
telegramGetUpdatesURL() {
|
telegramGetUpdatesURL(withToken = false) {
|
||||||
let token = `<${this.$t("YOUR BOT TOKEN HERE")}>`
|
let token = `<${this.$t("YOUR BOT TOKEN HERE")}>`;
|
||||||
|
|
||||||
if (this.$parent.notification.telegramBotToken) {
|
if (this.$parent.notification.telegramBotToken && withToken) {
|
||||||
token = this.$parent.notification.telegramBotToken;
|
token = this.$parent.notification.telegramBotToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `https://api.telegram.org/bot${token}/getUpdates`;
|
return `https://api.telegram.org/bot${token}/getUpdates`;
|
||||||
},
|
},
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async autoGetTelegramChatID() {
|
async autoGetTelegramChatID() {
|
||||||
try {
|
try {
|
||||||
let res = await axios.get(this.telegramGetUpdatesURL)
|
let res = await axios.get(this.telegramGetUpdatesURL(true));
|
||||||
|
|
||||||
if (res.data.result.length >= 1) {
|
if (res.data.result.length >= 1) {
|
||||||
let update = res.data.result[res.data.result.length - 1]
|
let update = res.data.result[res.data.result.length - 1];
|
||||||
|
|
||||||
if (update.channel_post) {
|
if (update.channel_post) {
|
||||||
this.notification.telegramChatID = update.channel_post.chat.id;
|
this.notification.telegramChatID = update.channel_post.chat.id;
|
||||||
} else if (update.message) {
|
} else if (update.message) {
|
||||||
this.notification.telegramChatID = update.message.chat.id;
|
this.notification.telegramChatID = update.message.chat.id;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(this.$t("chatIDNotFound"))
|
throw new Error(this.$t("chatIDNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(this.$t("chatIDNotFound"))
|
throw new Error(this.$t("chatIDNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(error.message)
|
toast.error(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user