diff --git a/service/binance/binance.go b/service/binance/binance.go index f88d26b..1479606 100644 --- a/service/binance/binance.go +++ b/service/binance/binance.go @@ -101,7 +101,7 @@ func sendPriceUpdate() { msg.ParseMode = "Markdown" sentMsg, err := bot.Send(msg) if err != nil { - log.Printf("Failed to send message: %v", err) + log.Printf("Failed to send message. Error: %v\nFull message content:\nChat ID: %d\nMessage: %s", err, chatID, message) return } diff --git a/service/link_filter/link_filter.go b/service/link_filter/link_filter.go index 8330f8c..cd64b53 100644 --- a/service/link_filter/link_filter.go +++ b/service/link_filter/link_filter.go @@ -186,14 +186,17 @@ func processLinks(links []string, linkFilter *LinkFilter) (bool, []string) { } } - if len(newNonWhitelistedLinks) > 0 { - logger.Printf("发现新的非白名单链接: %v", newNonWhitelistedLinks) - } return false, newNonWhitelistedLinks } func (lf *LinkFilter) CheckAndFilterLink(bot *tgbotapi.BotAPI, message *tgbotapi.Message) bool { // 判断消息是否应当被过滤及找出新的非白名单链接 shouldFilter, newLinks := ShouldFilter(message.Text, lf) + + // 如果发现新的非白名单链接,记录日志 + if len(newLinks) > 0 { + logger.Printf("发现新的非白名单链接: %v", newLinks) + } + if shouldFilter { // 记录被过滤的消息 logger.Printf("消息应该被过滤: %s", message.Text) @@ -218,11 +221,5 @@ func (lf *LinkFilter) CheckAndFilterLink(bot *tgbotapi.BotAPI, message *tgbotapi return true } - // 如果发现新的非白名单链接 - if len(newLinks) > 0 { - // 记录新的非白名单链接 - logger.Printf("发现新的非白名单链接: %v", newLinks) - } - return false }