diff --git a/sample_config.yaml b/sample_config.yaml index dc2aaf3..dc0243b 100644 --- a/sample_config.yaml +++ b/sample_config.yaml @@ -27,6 +27,8 @@ telegram: emoji_confirmation: true # Reacts to the message with a "👍" emoji instead of replying skip_startup_message: false # If set to true, then a message will NOT be sent to your Telegram DM when the bot starts + + spoiler_as_viewonce: True # If set to true, then all the spoiler files will be sent as view-once messages whatsapp: session_name: watgbridge # This will appear in your Linked Devices in mobile app diff --git a/state/config.go b/state/config.go index 95e3ea7..71c0e17 100644 --- a/state/config.go +++ b/state/config.go @@ -34,6 +34,7 @@ type Config struct { SilentConfirmation bool `yaml:"silent_confirmation"` EmojiConfirmation bool `yaml:"emoji_confirmation"` SkipStartupMessage bool `yaml:"skip_startup_message"` + SpoilerViewOnce bool `yaml:"spoiler_as_viewonce"` } `yaml:"telegram"` WhatsApp struct { diff --git a/utils/telegram.go b/utils/telegram.go index 267417c..ed775ce 100644 --- a/utils/telegram.go +++ b/utils/telegram.go @@ -304,7 +304,7 @@ func TgSendToWhatsApp(b *gotgbot.Bot, c *ext.Context, FileEncSHA256: uploadedImage.FileEncSHA256, FileSHA256: uploadedImage.FileSHA256, FileLength: proto.Uint64(uint64(len(imageBytes))), - ViewOnce: proto.Bool(msgToForward.HasProtectedContent), + ViewOnce: proto.Bool(msgToForward.HasProtectedContent || (msgToForward.HasMediaSpoiler && cfg.Telegram.SpoilerViewOnce)), Height: proto.Uint32(uint32(bestPhoto.Height)), Width: proto.Uint32(uint32(bestPhoto.Width)), ContextInfo: &waE2E.ContextInfo{}, @@ -385,7 +385,7 @@ func TgSendToWhatsApp(b *gotgbot.Bot, c *ext.Context, FileEncSHA256: uploadedVideo.FileEncSHA256, FileSHA256: uploadedVideo.FileSHA256, FileLength: proto.Uint64(uint64(len(videoBytes))), - ViewOnce: proto.Bool(msgToForward.HasProtectedContent), + ViewOnce: proto.Bool(msgToForward.HasProtectedContent || (msgToForward.HasMediaSpoiler && cfg.Telegram.SpoilerViewOnce)), Seconds: proto.Uint32(uint32(msgToForward.Video.Duration)), GifPlayback: proto.Bool(false), Height: proto.Uint32(uint32(msgToForward.Video.Height)), @@ -467,7 +467,7 @@ func TgSendToWhatsApp(b *gotgbot.Bot, c *ext.Context, FileEncSHA256: uploadedVideo.FileEncSHA256, FileSHA256: uploadedVideo.FileSHA256, FileLength: proto.Uint64(uint64(len(videoBytes))), - ViewOnce: proto.Bool(msgToForward.HasProtectedContent), + ViewOnce: proto.Bool(msgToForward.HasProtectedContent || (msgToForward.HasMediaSpoiler && cfg.Telegram.SpoilerViewOnce)), Seconds: proto.Uint32(uint32(msgToForward.VideoNote.Duration)), GifPlayback: proto.Bool(false), ContextInfo: &waE2E.ContextInfo{}, @@ -548,7 +548,7 @@ func TgSendToWhatsApp(b *gotgbot.Bot, c *ext.Context, FileEncSHA256: uploadedAnimation.FileEncSHA256, FileSHA256: uploadedAnimation.FileSHA256, FileLength: proto.Uint64(uint64(len(animationBytes))), - ViewOnce: proto.Bool(msgToForward.HasProtectedContent), + ViewOnce: proto.Bool(msgToForward.HasProtectedContent || (msgToForward.HasMediaSpoiler && cfg.Telegram.SpoilerViewOnce)), Height: proto.Uint32(uint32(msgToForward.Animation.Height)), Width: proto.Uint32(uint32(msgToForward.Animation.Width)), Seconds: proto.Uint32(uint32(msgToForward.Animation.Duration)), diff --git a/whatsapp/handlers.go b/whatsapp/handlers.go index 0cfecfe..ab243e2 100644 --- a/whatsapp/handlers.go +++ b/whatsapp/handlers.go @@ -499,6 +499,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool ReplyParameters: &gotgbot.ReplyParameters{ MessageId: replyToMsgId, }, + HasSpoiler: *imageMsg.ViewOnce, MessageThreadId: threadId, }) if sentMsg.MessageId != 0 { @@ -653,6 +654,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool ReplyParameters: &gotgbot.ReplyParameters{ MessageId: replyToMsgId, }, + HasSpoiler: *videoMsg.ViewOnce, MessageThreadId: threadId, }) if sentMsg.MessageId != 0 {