SHELL命令完成信息推送

1.推送文本信息

TOKEN=XXXX:XXXXXXXXXXXXXX	#TG机器人token
chat_ID=XXXXX		#用户ID或频道、群ID
message_text="xxxxx"		#要发送的信息
MODE='HTML'		#解析模式,可选HTML或Markdown
URL="https://api.telegram.org/bot${TOKEN}/sendMessage"		#api接口
#测试1:终端有日志
curl -s -X POST $URL -d chat_id=${chat_ID}  -d parse_mode=${MODE} -d text="${message_text}"  	
#测试2:终端无日志
curl -s -o /dev/null -X POST $URL -d chat_id=${chat_ID} -d text="${message_text}"  

2.推送贴图

curl -s \
-X POST https://api.telegram.org/bot$BOT_API_KEY/sendSticker \
-d sticker="CAADAgAD3QADMNSdEY1VJRWnGm6vFgQ" \
-d chat_id=$CHAT_ID

效果截图:

3.推送任意文件

curl \
-F chat_id=$chat_ID \
-F document=@"v2.sh" \
https://api.telegram.org/bot$TOKEN/sendDocument

4.推送照片

curl -s \
-X POST "https://api.telegram.org/bot${TOKEN}/sendPhoto" \
-F chat_id=$chat_ID \
-F photo="@baiyue.jpg"

5.其他推送

/sendVideo
/sendVoice
/sendLocation
/sendVenue
/sendChatAction

6.其他API

请参考:https://core.telegram.org/bots

Last updated