시가총액: $2.9636T 0.810%
거래량(24시간): $106.3487B 16.650%
  • 시가총액: $2.9636T 0.810%
  • 거래량(24시간): $106.3487B 16.650%
  • 공포와 탐욕 지수:
  • 시가총액: $2.9636T 0.810%
암호화
주제
암호화
소식
cryptostopics
비디오
최고의 뉴스
암호화
주제
암호화
소식
cryptostopics
비디오
bitcoin
bitcoin

$93113.538616 USD

-0.11%

ethereum
ethereum

$1748.590950 USD

-2.15%

tether
tether

$1.000392 USD

0.02%

xrp
xrp

$2.177851 USD

-1.16%

bnb
bnb

$600.317897 USD

-0.84%

solana
solana

$151.339663 USD

1.47%

usd-coin
usd-coin

$0.999927 USD

0.01%

dogecoin
dogecoin

$0.179240 USD

2.45%

cardano
cardano

$0.707230 USD

2.73%

tron
tron

$0.243466 USD

-0.61%

sui
sui

$3.323843 USD

10.76%

chainlink
chainlink

$14.828095 USD

0.41%

avalanche
avalanche

$21.905207 USD

-0.82%

stellar
stellar

$0.275988 USD

4.91%

unus-sed-leo
unus-sed-leo

$9.206268 USD

0.44%

암호화폐 뉴스 기사

알림을 위해 Telegram Bot을 작성하고 구성하는 방법

2025/03/12 17:28

Telegram Bots는 메시지 자동화, 알림 관리 또는 사용자 정의 상호 작용을 만드는 강력한 도구입니다. 이 안내서에서는 Botfather를 사용하여 Telegram Bot을 만들고, 채널 설정 및 메시지를 보내기 위해 JavaScript를 사용합니다.

알림을 위해 Telegram Bot을 작성하고 구성하는 방법

Telegram bots are a fun and versatile way to automate messages, manage notifications, or even create unique interactions within the messaging app. In this guide, we'll combine BotFather's magic with a sprinkle of JavaScript to craft a simple bot that sends messages to a Telegram channel.

Telegram Bots는 메시지를 자동화하거나 알림을 관리하거나 메시징 앱 내에서 고유 한 상호 작용을 만드는 재미 있고 다재다능한 방법입니다. 이 안내서에서는 Botfather의 마술을 자바 스크립트를 뿌려 전보 채널로 보내는 간단한 봇을 만들어냅니다.

Let's break down the steps to bring your bot to life.

봇을 생명에 가져 오는 단계를 세분화합시다.

1. Creating a Telegram Bot with BotFather

1. Botfather와 함께 Telegram 봇 만들기

- Open Telegram and search for "BotFather." Make sure it has a blue tick to confirm authenticity.

- 전보를 열고 "Botfather"를 검색하십시오. 진정성을 확인하기 위해 파란색 진드기가 있는지 확인하십시오.

- Start a chat with BotFather by typing /start in the chatbox. This will list all available commands.

- 채팅 박스에서 입력 /시작하여 Botfather와 채팅을 시작하십시오. 여기에는 사용 가능한 모든 명령이 나열됩니다.

- To create a new bot, send the /newbot command. Follow the prompts to choose a name for your bot and set up its username.

- 새 봇을 만들려면 /newbot 명령을 보내십시오. 프롬프트를 따라 봇 이름을 선택하고 사용자 이름을 설정하십시오.

- Once the bot is created, BotFather will provide the bot's token. Keep this token safe and secret.

- 봇이 만들어지면 Botfather는 봇의 토큰을 제공합니다. 이 토큰을 안전하고 비밀로 유지하십시오.

2. Setting Up a Telegram Channel

2. 전보 채널 설정

- Create a Telegram channel with your desired name and purpose.

- 원하는 이름과 목적으로 전보 채널을 만듭니다.

- Go to the channel's settings and add your bot as an admin. This will enable the bot to send messages to the channel.

- 채널 설정으로 이동하여 봇을 관리자로 추가하십시오. 이를 통해 봇은 채널로 메시지를 보낼 수 있습니다.

- To get the channel ID, add the @myidbot bot to your channel. It will provide the channel ID in the format: -40909XXXXX.

- 채널 ID를 얻으려면 @MyIdBot 봇을 채널에 추가하십시오. 채널 ID를 형식으로 -40909XXXXX 형식으로 제공합니다.

3. Testing Your Bot Using the Telegram Bot API

3. Telegram Bot API를 사용하여 봇 테스트

Now, let's test sending a message to your bot using the Telegram HTTP API.

이제 Telegram HTTP API를 사용하여 봇에 메시지를 보내는 것을 테스트합시다.

Curl Command Example:

컬 명령 예 :

```

```

curl -X POST "https://api.telegram.org/botYOUR_BOT_TOKEN/sendMessage" \

curl -x post "https://api.telegram.org/botyour_bot_token/sendmessage"\

-H 'Content-Type: application/json' \

-h 'content-type : application/json'\

-d '{ "chat_id": YOUR_CHANNEL_ID, "text": "Hello from Telegram Bot" }'

-d '{ "chat_id": your_channel_id, "text": "Hello From Telegram Bot"}' '

```

```

Replace the placeholders with your bot's details and channel ID. If the command is successful, the output will include "ok:true."

자리 표시자를 봇의 세부 정보 및 채널 ID로 교체하십시오. 명령이 성공하면 출력에는 "OK : True"가 포함됩니다.

4. Sending Messages Using JavaScript

4. JavaScript를 사용하여 메시지 보내기

We can convert the above curl request to JavaScript code to send messages using the bot.

위의 CURL 요청을 JavaScript 코드로 변환하여 봇을 사용하여 메시지를 보낼 수 있습니다.

```javascript

````JavaScript

const axios = require('axios');

const axios = require ( 'axios');

const sendMessage = async (channelID, message) => {

const sendmessage = async (channelId, message) => {

try {

노력하다 {

const response = await axios.post('https://api.telegram.org/botYOUR_BOT_TOKEN/sendMessage', {

const response = await axios.post ( 'https://api.telegram.org/botyour_bot_token/sendmessage', {

chat_id: channelID,

chat_id : channelid,

text: message,

텍스트 : 메시지,

});

});

console.log(response.data); // Output: { ok: true, result: { ... } }

Console.log (Response.Data); // 출력 : {OK : true, result : {...}}

} catch (error) {

} catch (오류) {

console.error(error);

Console.error (오류);

}

}

};

};

// Example Usage:

// 예제 사용 :

sendMessage(-40909XXXXX, 'Hello from Node.js to Telegram Channel!');

SendMessage (-40909xxxxx, 'Node.js에서 Telegram Channel까지 Hello!');

```

```

5. Automating Alerts

5. 경고 자동화

You can integrate this JavaScript code into your application to send notifications, updates, or alerts to your Telegram channel. This setup is perfect for applications like balance alerts, transaction updates, or monitoring tools.

이 JavaScript 코드를 응용 프로그램에 통합하여 Telegram 채널에 알림, 업데이트 또는 경고를 보낼 수 있습니다. 이 설정은 잔액 경고, 트랜잭션 업데이트 또는 모니터링 도구와 같은 응용 프로그램에 적합합니다.

Enjoy using your custom Telegram bot! 🚀

맞춤형 텔레 그램 봇을 사용해보세요! 🚀

부인 성명:info@kdj.com

제공된 정보는 거래 조언이 아닙니다. kdj.com은 이 기사에 제공된 정보를 기반으로 이루어진 투자에 대해 어떠한 책임도 지지 않습니다. 암호화폐는 변동성이 매우 높으므로 철저한 조사 후 신중하게 투자하는 것이 좋습니다!

본 웹사이트에 사용된 내용이 귀하의 저작권을 침해한다고 판단되는 경우, 즉시 당사(info@kdj.com)로 연락주시면 즉시 삭제하도록 하겠습니다.

2025年04月26日 에 게재된 다른 기사