diff --git a/PublishHelperBot/Handlers.fs b/PublishHelperBot/Handlers.fs index 7ffb5cb..a708311 100644 --- a/PublishHelperBot/Handlers.fs +++ b/PublishHelperBot/Handlers.fs @@ -59,7 +59,7 @@ let public RelayHandler: Handler = fun (u, c, tg) -> let caption = lazy RelayResolveCaption(captionMode, author, c.relayUrl) match reply.Type with - | MessageType.Text -> tg.SendTextMessageAsync(channelId, reply.Text) + | MessageType.Text -> tg.ForwardMessageAsync(channelId, reply.Chat.Id, reply.MessageId) | MessageType.Photo -> tg.SendPhotoAsync(channelId, photoMedia.Value, caption = caption.Value, parseMode = RelayParseMode) | MessageType.Video -> tg.SendVideoAsync(channelId, reply.Video.FileId, caption = caption.Value, diff --git a/PublishHelperBot/Program.fs b/PublishHelperBot/Program.fs index c006fdc..b25c6a1 100644 --- a/PublishHelperBot/Program.fs +++ b/PublishHelperBot/Program.fs @@ -15,11 +15,11 @@ let CreateBot (config: BotConfig, http: HttpClient) = TelegramBotClient(config.t let config = CreateConfig <| "SBPB_CONFIG_PATH"; let botClient = CreateBot <| (config, new HttpClient()) let startDate = DateTime.UtcNow +let isObsoleteUpdate (u: Update) = u.Type = UpdateType.Message && u.Message.Date < startDate; let updateHandle (bc: ITelegramBotClient) (u: Update) (ct: CancellationToken): Task = match u with - // Ignore old messages (to prevent overposting on downtime) - | _ when u.Message.Date < startDate -> Task.CompletedTask + | _ when isObsoleteUpdate u -> Task.CompletedTask | _ when RelayMatch <| (u, config) -> RelayHandler <| (u, config, bc) | _ -> Task.CompletedTask