Skip to content

Commit 4eb99e7

Browse files
committed
Ignore Telegram API error
1 parent 2b86486 commit 4eb99e7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func botSend(botKey string, iuserID string, initText string) func(string) {
202202
var messageId = int64(0)
203203
resp, err := http.Get(fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage?chat_id=%s&parse_mode=MarkdownV2&text=%s", botKey, iuserID, url.QueryEscape(initText)))
204204
if err != nil {
205-
log.Panic(err)
205+
log.Println(err)
206206
}
207207
defer resp.Body.Close()
208208
body, err := ioutil.ReadAll(resp.Body)
@@ -215,7 +215,7 @@ func botSend(botKey string, iuserID string, initText string) func(string) {
215215
messageId, _ = jsonparser.GetInt(body, "result", "message_id")
216216
} else {
217217
description, _ := jsonparser.GetString(body, "description")
218-
log.Panicf(loc.print("telegramSendError"), description)
218+
log.Println(loc.print("telegramSendError"), description)
219219
}
220220
return func(text string) {
221221
if text[:5] == "close" && text[5] != '|' {
@@ -224,26 +224,26 @@ func botSend(botKey string, iuserID string, initText string) func(string) {
224224
// close| 则不会删除消息
225225
resp, err = http.Get(fmt.Sprintf("https://api.telegram.org/bot%s/deleteMessage?chat_id=%s&message_id=%d", botKey, iuserID, messageId))
226226
if err != nil {
227-
log.Panic(err)
227+
log.Println(err)
228228
}
229229
defer resp.Body.Close()
230230
return
231231
}
232232
resp, err = http.Get(fmt.Sprintf("https://api.telegram.org/bot%s/editMessageText?chat_id=%s&parse_mode=MarkdownV2&message_id=%d&text=%s", botKey, iuserID, messageId, url.QueryEscape(text)))
233233
if err != nil {
234-
log.Panic(err)
234+
log.Println(err)
235235
}
236236
defer resp.Body.Close()
237237
body, err = ioutil.ReadAll(resp.Body)
238238
if err != nil {
239-
log.Panic(err)
239+
log.Println(err)
240240
}
241241
//fmt.Println(string(body))
242242
ok, _ = jsonparser.GetBoolean(body, "ok")
243243
if !ok {
244244
description, _ := jsonparser.GetString(body, "description")
245245
if !strings.Contains(string(body), "message is not modified") && !strings.Contains(string(body), "Too Many Requests") {
246-
log.Panicf(loc.print("telegramSendError"), description)
246+
log.Println(loc.print("telegramSendError"), description)
247247
}
248248
}
249249

0 commit comments

Comments
 (0)