Refactor post handling and add command setup for Telegram bot
This commit is contained in:
@@ -2,6 +2,7 @@ package toc
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -86,10 +87,12 @@ func (m *Manager) updateMessage(content string) error {
|
||||
|
||||
_, err = m.bot.Edit(existingMsg, content, tele.ModeMarkdown, tele.NoPreview)
|
||||
if err != nil {
|
||||
if err == tele.ErrMessageNotModified {
|
||||
errMsg := err.Error()
|
||||
// 内容未变化,忽略
|
||||
if err == tele.ErrMessageNotModified || strings.Contains(errMsg, "message is not modified") {
|
||||
return nil
|
||||
}
|
||||
if err.Error() == "telegram: message to edit not found (400)" {
|
||||
if strings.Contains(errMsg, "message to edit not found") {
|
||||
msg, err := m.bot.Send(chat, content, tele.ModeMarkdown, tele.NoPreview)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user