telegram - deptno/deptno.github.io GitHub Wiki
telegram | ํ ๋ ๊ทธ๋จ
messager
bot ๋ง๋ค๊ธฐ
- BotFather ์ ๋ํ ์์
- https://t.me/BotFather ์ ์ํด์ ์ ๊ทผ
- telegram ์์
BotFather
๊ฒ์ํด์start
api token
ํ๋
- authorizing
- ๋ช ๋ น์ด ์ค์
- ์ฌ์ฉํ ๋งํ method ๋ฅผ ์ฐพ๋๋ค
curl -X POST \
-H "Content-Type: application/json" \
-d '{"commands":[{"command": "commanda", "description": "command a"}]' \
https://api.telegram.org/bot[token]/setMyCommands
curl https://api.telegram.org/bot[token]/getMyCommands
- https://core.telegram.org/bots/api#setchatmenubutton
- ์ฑํ
- polling
- telegram ์์ bot ์ ์ฐพ์์ ๋ฉ์์ง ํน์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ ํ ์๋ ๋ช ๋ น์ด๋ก ํ์ธํ๋ค
curl https://api.telegram.org/bot[token]/getUpdates
- webhook
์ค์ ์๋ฒ๋ ๋ฐ์์ฑ๊ณผ ํจ์จ์ฑ์ ์ํด์ webhook ์ผ๋ก ์๋น์ค ๋์ด์ผํ๋ค
- webhook ์ ๋ฐ์ ์ ์๋ public domain ์ด ์กด์ฌํด์ผํ๋ฉฐ https ๊ฐ ์ง์๋์ด์ผํ๋ค.
- ์ฌ์ค ์ธ์ฆ์๋ฅผ ์ฌ์ฉํ๋ค๋ฉด ํด๋น ์ธ์ฆ์๋ฅผ ๋ฑ๋กํด์ผํ๋ค
- ์ฃผ์๋ก ํด๋น์ด๋ฒคํธ๊ฐ ์ค๋ฉด ํด๋น post ๋ฉ์์ง๋ฅผ ํธ๋ค๋ง ํ๋ฉด๋๋ค.
- webhook ์ ๋ฐ์ ์ ์๋ public domain ์ด ์กด์ฌํด์ผํ๋ฉฐ https ๊ฐ ์ง์๋์ด์ผํ๋ค.
- ์๋ตํ๊ธฐ
curl -X POST \
-H "Content-Type: application/json" \
-d '{"chat_id": 1830393354, "text": "hello"' \
"https://api.telegram.org/bot[token]/sendMessage"
error
entries
์ url ์ด localhost ๋ก ๋์ด์๋ ๋งํฌ๋ฅผ ๊ฑธ๋ฉด ๋์ํ์ง ์๋๋ค.