Skip to content

Commit

Permalink
feat: update sendMessage options
Browse files Browse the repository at this point in the history
  • Loading branch information
byodian committed Oct 17, 2024
1 parent 4516da4 commit f46a45e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ export default {
try {
const body = await request.json()

// 构建发送到 Telegram 的消息内容
let message = "Hello world"
if (githubEvent === 'watch') {
message = makeMessage(body)
}

// 发送消息到 Telegram
// send message to Telegram
// api docs - https://core.telegram.org/bots/api#sendmessage
const telegramUrl = `https://api.telegram.org/bot${env.TELEGRAM_TOKEN}/sendMessage`

const telegramPayload = {
chat_id: env.TELEGRAM_CHAT_ID,
text: message,
parse_mode: "Markdown"
parse_mode: "Markdown",
link_preview_options: { is_disabled: true }
}

const telegramResponse = await fetch(telegramUrl, {
Expand Down Expand Up @@ -54,7 +55,7 @@ function makeMessage(body) {

return `
New Github star for [${repo}](${repoUrl}) repo!
The ${repo} repo now has ${stargazers_count} starts and ${forks_count} forks!🎉
The *${repo}* repo now has *${stargazers_count}* starts and *${forks_count}* forks!🎉
Your new fan is [${follwer}](${follwerUrl})
`
}

0 comments on commit f46a45e

Please sign in to comment.