feat: add retry button
This commit is contained in:
parent
672cd8b575
commit
daa0c86d09
|
@ -19,8 +19,11 @@ var (
|
|||
translateBtnEn = translateMenu.Data("English", "btn_tr_en", "English")
|
||||
translateBtnJa = translateMenu.Data("日本語", "btn_tr_ja", "Japanese")
|
||||
|
||||
translateBtnRetry = translateMenu.Data("Try again", "btn_tr_retry")
|
||||
|
||||
translateBtns = []*tele.Btn{
|
||||
&translateBtnZhTw, &translateBtnZhCn, &translateBtnEn, &translateBtnJa,
|
||||
&translateBtnRetry,
|
||||
}
|
||||
|
||||
translateCmdRe = regexp.MustCompile(`^\s*\/tr(anslate)?(@\S*)?\s*`)
|
||||
|
@ -103,7 +106,11 @@ func handleTranslateBtn(c tele.Context) error {
|
|||
}
|
||||
|
||||
respText := resp.Choices[0].Message.Content
|
||||
_, err = c.Bot().Reply(origMsg, respText, tele.Silent)
|
||||
retryBtn := translateBtnRetry
|
||||
retryBtn.Data = targetLang
|
||||
respMenu := &tele.ReplyMarkup{}
|
||||
respMenu.Inline(respMenu.Row(retryBtn))
|
||||
_, err = c.Bot().Reply(origMsg, respText, tele.Silent, respMenu)
|
||||
|
||||
// delete the temporary message
|
||||
if err := c.Delete(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue