Closed silverwinter313 closed 5 months ago
Can you confirm it's backward compatible?
Yes, because when we call function getID
topicid := getID(c, "topicid")
chatid := getID(c, "chatid")
I write condition for topic_id
, if topic_id
doesn't set, return 0 value.
if c.Param(param) == "" && param == "topicid" {
return 0
}
Why exactly topic_id=0
, in telegram bot function NewMessage always set ReplyToMessageID: 0
for send message
// chatID is where to send it, text is the message text.
func NewMessage(chatID int64, text string) MessageConfig {
return MessageConfig{
BaseChat: BaseChat{
ChatID: chatID,
ReplyToMessageID: 0,
},
Text: text,
DisableWebPagePreview: false,
}
}
For confirmations additionally example:
My curl request for check work backward compatibility:
curl -X POST -H "Content-Type: application/json" -d "@production_example.json" 127.0.0.1:9087/alert/$CHAT_ID
Log messages:
Alert: <a href="http://localhost.localdomain:9090/graph?g0.expr=linux_loadavg%7Bmode%3D%2215min%22%7D+%3E+%282+%2A+10+%2A+4%29&g0.tab=0">Test Fisic measure, from KN</a>
Current value:38.24 EN
Severity: Warning ⚠️
Active from: 26/01/2017 19:30:00
2024/02/08 15:39:05 +-----------------------------------------------------------+
[GIN] 2024/02/08 - 15:39:05 | 200 | 235.353458ms | 127.0.0.1 | POST "/alert/$CHAT_ID"
Message in telegram chat:
Curl request for check topic:
curl -X POST -H "Content-Type: application/json" -d "@production_example.json" 127.0.0.1:9087/alert/$CHAT_ID/$TOPIC_ID
Log messages:
Alert: <a href="http://localhost.localdomain:9090/graph?g0.expr=linux_loadavg%7Bmode%3D%2215min%22%7D+%3E+%282+%2A+10+%2A+4%29&g0.tab=0">Test Fisic measure, from KN</a>
Current value:38.24 EN
Severity: Warning ⚠️
Active from: 26/01/2017 19:30:00
2024/02/08 15:45:56 +-----------------------------------------------------------+
[GIN] 2024/02/08 - 15:45:57 | 200 | 419.795791ms | 127.0.0.1 | POST "/alert/$CHAT_ID/$TOPIC_ID"
Message in telegram topic:
I write in readme.md
how to use this
Great, thanks, I'm going to merge it now. Can't verify myself but the code looks fine to me.
Hi, i check your issues https://github.com/inCaller/prometheus_bot/issues/92 and i need too this feature. Maybe your review my solution? Thank you in advance!