From 7ebcdb08263de6a66886a042b811dbddc38d3674 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sat, 22 Mar 2025 10:35:30 -0400 Subject: [PATCH] Add `ignoregroupdeletions` configuration option --- Makefile | 2 +- persistence/sessions.go | 12 ++++++++++++ telegabber.go | 2 +- telegram/handlers.go | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e3ad73e..80f1aff 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ COMMIT := $(shell git rev-parse --short HEAD) TD_COMMIT := "5bbfc1cf5dab94f82e02f3430ded7241d4653551" -VERSION := "v1.10.0" +VERSION := "v1.10.1" MAKEOPTS := "-j4" all: diff --git a/persistence/sessions.go b/persistence/sessions.go index 0454d97..a5f658a 100644 --- a/persistence/sessions.go +++ b/persistence/sessions.go @@ -47,6 +47,8 @@ type Session struct { NativeEdits bool `yaml:":nativeedits"` IgnoredChats []int64 `yaml:":ignoredchats"` ignoredChatsMap map[int64]bool `yaml:"-"` + + IgnoreGroupDeletions bool `yaml:":ignoregroupdeletions"` } var configKeys = []string{ @@ -59,6 +61,7 @@ var configKeys = []string{ "hideids", "receipts", "nativeedits", + "ignoregroupdeletions", } var sessionDB *SessionsYamlDB @@ -165,6 +168,8 @@ func (s *Session) get(key string) (string, error) { return fromBool(s.Receipts), nil case "nativeedits": return fromBool(s.NativeEdits), nil + case "ignoregroupdeletions": + return fromBool(s.IgnoreGroupDeletions), nil } return "", errors.New("Unknown session property") @@ -249,6 +254,13 @@ func (s *Session) Set(key string, value string) (string, error) { } s.NativeEdits = b return value, nil + case "ignoregroupdeletions": + b, err := toBool(value) + if err != nil { + return "", err + } + s.IgnoreGroupDeletions = b + return value, nil } return "", errors.New("Unknown session property") diff --git a/telegabber.go b/telegabber.go index 732a6b7..21334d2 100644 --- a/telegabber.go +++ b/telegabber.go @@ -16,7 +16,7 @@ import ( goxmpp "gosrc.io/xmpp" ) -var version string = "1.10.0" +var version string = "1.10.1" var commit string var sm *goxmpp.StreamManager diff --git a/telegram/handlers.go b/telegram/handlers.go index 1ccd622..8d1412d 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -363,6 +363,12 @@ func (c *Client) updateDeleteMessages(update *client.UpdateDeleteMessages) { if c.Session.IsChatIgnored(update.ChatId) { return } + if c.Session.IgnoreGroupDeletions { + chatType, chatTypeErr := c.GetChatType(update.ChatId) + if chatTypeErr == nil && (chatType == ChatTypeBasicGroup || chatType == ChatTypeSupergroup) { + return + } + } var deleteChar string if c.Session.AsciiArrows {