Skip to content

Telegram:Bot

API Token

@BotFather를 통하여 토큰을 획득할 수 있다.

  • [입력] /newbot
  • BotFather: Alright, a new bot. How are we going to call it? Please choose a name for your bot.
  • [입력(한글가능)] DecanBot
  • BotFather: Good. Now let's choose a username for your bot. It must end in bot. Like this, for example: TetrisBot or tetris_bot.
  • [입력(영문)] DecanBot
  • BotFather: Done! Congratulations on your new bot. You will find it at telegram.me/DecanBot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
    Use this token to access the HTTP API:
    ----- TOKEN -----
    For a description of the Bot API, see this page: https://core.telegram.org/bots/api

이후 ID를 추가하면 된다. (위의 경우 @DecanBot)

Join Group

단순히 그룹에 추가하기 위해서 @BotFather에게 /setjoingroups명령을 보내야 한다.

Privacy mode

참고로 그룹에 가입시켜도 봇API를 통해 그룹의 메시지를 가져올수 없다. 메시지 접근권한을 갖기 위해 @BotFather를 통해 /setprivacy명령을 Disable하면 된다.

Inline bots

URL 프리뷰 모드 끄기

You can set disable_web_page_preview attribute to true when using sendMessage method.

It will disable link previews for links in this message.

https://core.telegram.org/bots/api#sendmessage

봇의 명령 자동완성 추가

봇 파더한테 /setcommands 명령치면 된다.

다음과 같이 입력하라 한다:

OK. Send me a list of commands for your bot. Please use this format:

command1 - Description
command2 - Another description

Send /empty to keep the list empty.

명령 이름은 / 를 제외하고 입력해야 한다.

예를 들면:

/version - Print the your.run version
/help - Print help messsage

가 아니라 다음과 같아야 한다:

version - Print the your.run version
help - Print help messsage

Troubleshooting

그룹에 봇을 추가했는데 메시지에 접근할 수 없다고 뜰 때

영문 메시지는 Has no access to message 이다.

봇 파더한테 가서

자기 봇 선택 >> Bot Settings >> Group Privacy >> Turn off

See also

Favorite site

Python Telegram Bot

References


  1. Acidpop_Software_-_Create_Telegram_BOT_01.pdf 

  2. Acidpop_Software_-_Create_Telegram_BOT_02.pdf 

  3. Acidpop_Software_-_Create_Telegram_BOT_03.pdf 

  4. Acidpop_Software_-_Create_Telegram_BOT_04.pdf 

  5. Acidpop_Software_-_Create_Telegram_BOT_05.pdf