1. telegram BotFather에서 bot 생성하기
/start
/newbot
이름_bot
api를 알려줍니다.
https://api.telegram.org/bot{api키}/getUpdates 이렇게 들어가면 확인가능
추가로 이제 bot 알람을 받을 텔레그램에서 해당 bot 이름을 검색하여 /start 를 눌러주면 됩니다.
채팅에서 아무말을 치고 https://api.telegram.org/bot{api키}/getUpdates다시 들어가면
message":{"message_id":5,"from":{"id": ~~~ } 확인이 가능합니다
이제 받을 id넘버링을 확인하실수도 있습니다.
이제 간다하게 테스트 한번 해보겠습니다.
# sudo dnf install python3-pip -y
# pip3 install python-telegram-bot
# vi test.py
import telegram
import asyncio
async def send_telegram_message():
bot = telegram.Bot(token="API값")
chat_id = 받을 계정 ID 값
await bot.send_message(chat_id=chat_id, text="Test Message")
async def main():
await send_telegram_message()
if __name__ == "__main__":
asyncio.run(main())
# python test.py
잘오네요
'Linux&Ubuntu > zabbix' 카테고리의 다른 글
windows zabbix-agent 설치 (0) | 2024.02.27 |
---|---|
zabbix 6.0 Rocky 9 (0) | 2024.02.16 |
zabbix agent 설치 (0) | 2024.02.02 |
zabbix6.0 접속하기 (0) | 2023.12.28 |
rocky 8 zabbix+apm(패키지) 설치 (0) | 2023.12.28 |