Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support topics message for telegram nonfiction #2716

Merged
merged 5 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions server/notification-providers/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ class Telegram extends NotificationProvider {
let okMsg = "Sent Successfully.";

try {
let params = {
chat_id: notification.telegramChatID,
text: msg,
};
if (notification.telegramMessageThreadID) {
params.message_thread_id = notification.telegramMessageThreadID;
}

await axios.get(`https://api.telegram.org/bot${notification.telegramBotToken}/sendMessage`, {
params: {
chat_id: notification.telegramChatID,
text: msg,
},
params: params,
});
return okMsg;

Expand Down
4 changes: 4 additions & 0 deletions src/components/notifications/Telegram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<a :href="telegramGetUpdatesURL('withToken')" target="_blank" style="word-break: break-word;">{{ telegramGetUpdatesURL("masked") }}</a>
</p>
</div>

<label for="message_thread_id" class="form-label">{{ $t("telegramMessageThreadID") }}</label>
<input id="message_thread_id" v-model="$parent.notification.telegramMessageThreadID" type="text" class="form-control">
<p class="form-text">{{ $t("telegramMessageThreadIDDescription") }}</p>
</div>
</template>

Expand Down
1 change: 1 addition & 0 deletions src/lang/ar-SY.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
"Bot Token": "رمز الروبوت",
"wayToGetTelegramToken": "يمكنك الحصول على رمز من {0}.",
"Chat ID": "معرف الدردشة",
"telegramMessageThreadID": "معرف المواضيع",
"supportTelegramChatID": "دعم الدردشة المباشرة / معرف الدردشة للقناة",
"wayToGetTelegramChatID": "يمكنك الحصول على معرف الدردشة الخاص بك عن طريق إرسال رسالة إلى الروبوت والانتقال إلى عنوان URL هذا لعرض Chat_id",
"YOUR BOT TOKEN HERE": "رمز الروبوت الخاص بك هنا",
Expand Down
2 changes: 2 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@
"Bot Token": "Bot Token",
"wayToGetTelegramToken": "You can get a token from {0}.",
"Chat ID": "Chat ID",
"telegramMessageThreadID": "(Optional) Message Thread ID",
"telegramMessageThreadIDDescription": "Optional Unique identifier for the target message thread (topic) of the forum; for forum supergroups only",
"supportTelegramChatID": "Support Direct Chat / Group / Channel's Chat ID",
"wayToGetTelegramChatID": "You can get your chat ID by sending a message to the bot and going to this URL to view the chat_id:",
"YOUR BOT TOKEN HERE": "YOUR BOT TOKEN HERE",
Expand Down