Remove message to alert channel
This commit is contained in:
parent
d372e99398
commit
079b0170d3
1 changed files with 10 additions and 12 deletions
22
bot.go
22
bot.go
|
|
@ -17,8 +17,6 @@ import (
|
||||||
"github.com/gotd/td/session"
|
"github.com/gotd/td/session"
|
||||||
"github.com/gotd/td/telegram"
|
"github.com/gotd/td/telegram"
|
||||||
"github.com/gotd/td/telegram/auth"
|
"github.com/gotd/td/telegram/auth"
|
||||||
"github.com/gotd/td/telegram/message"
|
|
||||||
"github.com/gotd/td/telegram/message/html"
|
|
||||||
"github.com/gotd/td/telegram/updates"
|
"github.com/gotd/td/telegram/updates"
|
||||||
"github.com/gotd/td/tg"
|
"github.com/gotd/td/tg"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
|
@ -611,8 +609,8 @@ func handleNewMessage(ctx context.Context, api *tg.Client, alertPeer *tg.InputPe
|
||||||
chatName := channel.Title
|
chatName := channel.Title
|
||||||
chatDisplay := chatName + formatUsername(channel.Username)
|
chatDisplay := chatName + formatUsername(channel.Username)
|
||||||
|
|
||||||
matchMessageHTML := fmt.Sprintf("🚨 Matched\n<b>Score</b>: %.2f\n<b>Chat</b>: %s (ID: %d)\n<b>User</b>: %s (ID: %d)\n",
|
// matchMessageHTML := fmt.Sprintf("🚨 Matched\n<b>Score</b>: %.2f\n<b>Chat</b>: %s (ID: %d)\n<b>User</b>: %s (ID: %d)\n",
|
||||||
result.score, chatDisplay, chatID, userDisplay, senderID)
|
// result.score, chatDisplay, chatID, userDisplay, senderID)
|
||||||
|
|
||||||
if state.cfg.NtfyToken != "" || state.cfg.NtfyTopic != "" {
|
if state.cfg.NtfyToken != "" || state.cfg.NtfyTopic != "" {
|
||||||
plainMessage := fmt.Sprintf("🚨 Matched\nScore: %.2f\nChat: %s (ID: %d)\nUser: %s (ID: %d)\n\n%s",
|
plainMessage := fmt.Sprintf("🚨 Matched\nScore: %.2f\nChat: %s (ID: %d)\nUser: %s (ID: %d)\n\n%s",
|
||||||
|
|
@ -620,14 +618,14 @@ func handleNewMessage(ctx context.Context, api *tg.Client, alertPeer *tg.InputPe
|
||||||
notify(plainMessage, state.cfg, fmt.Sprintf("Scam Alert: %s", chatName))
|
notify(plainMessage, state.cfg, fmt.Sprintf("Scam Alert: %s", chatName))
|
||||||
}
|
}
|
||||||
|
|
||||||
userResolver := func(id int64) (tg.InputUserClass, error) {
|
// userResolver := func(id int64) (tg.InputUserClass, error) {
|
||||||
return &tg.InputUserFromMessage{Peer: alertPeer, MsgID: 0, UserID: id}, nil
|
// return &tg.InputUserFromMessage{Peer: alertPeer, MsgID: 0, UserID: id}, nil
|
||||||
}
|
// }
|
||||||
sender := message.NewSender(api)
|
// sender := message.NewSender(api)
|
||||||
_, err = sender.To(alertPeer).StyledText(ctx, html.String(userResolver, matchMessageHTML))
|
// _, err = sender.To(alertPeer).StyledText(ctx, html.String(userResolver, matchMessageHTML))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Printf("Failed to send alert message: %v", err)
|
// log.Printf("Failed to send alert message: %v", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue