美文网首页
Mac配置Jenkins五,使用Telegram的机器人发送打包

Mac配置Jenkins五,使用Telegram的机器人发送打包

作者: 独孤流 | 来源:发表于2023-05-25 08:43 被阅读0次

https://formulae.brew.sh/formula/qrencode

1、安装生成二维码图片的库
brew install qrencode

在shell脚本里使用生成图片

qrImgPath="xxx/xxx.png"
text="hello world"
# 将msg生成二维码图片,保存在qrImgPath这个路径
/opt/homebrew/bin/qrencode -o $qrImgPath $text
2、使用Telegram机器人发送消息

2.1 生成并创建Telegram机器人
参考:Telegram 机器人的申请和设置图文教程

首先在Telegram 里搜索 @botfather
输入 /newbot
输入 /mybots 可以编辑相关信息

打开浏览器,输入以下链接:https://api.telegram.org/bot<YourBOTToken>/getUpdates,其中 <YourBOTToken> 是你的机器人的 token。
Telegram机器人获取个人及群组ID


2.2 使用机器人发送通知消息
api文档:https://core.telegram.org/bots/api

# 发送图片
bot_token="xxxx"
imgPath="xxx/xxx.png"
group_id="xxxx"
notify_msg="hello_everyone"
# 发送图片
curl -s -X POST "https://api.telegram.org/bot$bot_token/sendPhoto" -F chat_id=$group_id -F photo="@$imgPath" -F caption=$notify_msg

# 发送文字信息
curl -s -X POST \
"https://api.telegram.org/bot$bot_token/sendMessage?chat_id=$group_id" -d parse_mode="HTML" \
-d text="$notify_msg"

参考:https://pipuwong.com/telegram

相关文章

网友评论

      本文标题:Mac配置Jenkins五,使用Telegram的机器人发送打包

      本文链接:https://www.haomeiwen.com/subject/oouzsdtx.html