Skip to content

Commit

Permalink
chore: update send msg telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
hunghg255 committed Jan 29, 2024
1 parent d91415c commit 4971013
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const MAX_EMBED_FIELD_VALUE_LENGTH = 1024
export const MAX_WEBHOOK_CONTENT_LENGTH = 2000

export const TELEGRAM_SEND_MSG_URL = (botToken: string) => `https://api.telegram.org/bot${botToken}/sendMessage`;
export const TELEGRAM_SEND_PHOTO_URL = (botToken: string) => `https://api.telegram.org/bot${botToken}/sendPhoto`;
4 changes: 2 additions & 2 deletions src/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getPayloadSlack,
getPayloadTelegram,
} from './utils';
import { TELEGRAM_SEND_MSG_URL } from './constants';
import { TELEGRAM_SEND_PHOTO_URL } from './constants';

export class Notification {
private inputs: TInputs;
Expand Down Expand Up @@ -62,7 +62,7 @@ export class Notification {
const payload = getPayloadTelegram(this.inputs);

return axios.post(
TELEGRAM_SEND_MSG_URL(this.inputs.telegram_bot_token as string),
TELEGRAM_SEND_PHOTO_URL(this.inputs.telegram_bot_token as string),
payload,
{
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export function getPayloadTelegram(inputs: Readonly<TInputs>): Object {

let telegram_payload: any = {
chat_id: inputs.telegram_chat_id,
text: `${`*${escapeMarkdownUrl(title)}*\n${escapeMarkdownUrl(
caption: `${`*${escapeMarkdownUrl(title)}*\n${escapeMarkdownUrl(
description
)}\n*Repository:* [${owner}/${escapeMarkdownUrl(repo)}](${escapeMarkdownUrl(
repoURL
Expand Down

0 comments on commit 4971013

Please sign in to comment.