Пример #1
0
        private async Task <bool> IsRepostedMessageDeletedInChat(RepostedMessage repostedMessage)
        {
            var technicalChatId = _settings.TechnicalChatId;
            var result          = true;

            try
            {
                var forwarded = await _telegram.ForwardMessageAsync(
                    technicalChatId,
                    repostedMessage.From.ChatId,
                    repostedMessage.From.MessageId,
                    true);

                result = false;
                await _telegram.DeleteMessageAsync(forwarded.Chat.Id, forwarded.MessageId);
            }
            catch (Exception exception) when(exception.Message == "Bad Request: message to forward not found")
            {
                var e = exception;
            }

            return(result);
        }
        private async Task <bool> IsRepostedMessageDeletedInChat(RepostedMessage repostedMessage)
        {
            // Again, can't change it without debugging, probably checking message existence is enough
            var technicalChatId = _settings.TechnicalChatId;

            try
            {
                var forwarded = await _telegram.ForwardMessageAsync(
                    technicalChatId,
                    repostedMessage.From.ChatId,
                    repostedMessage.From.MessageId,
                    true);

                await _telegram.DeleteMessageAsync(forwarded.Chat.Id, forwarded.MessageId);

                return(false);
            }
            catch (Exception exception) when(exception.Message == "Bad Request: message to forward not found")
            {
                var e = exception;
            }

            return(true);
        }
Пример #3
0
        private async Task DeleteRepostedMessageFromChannel(RepostedMessage repostedMessage)
        {
            var channelMessage = repostedMessage.To;

            await _telegram.DeleteMessageAsync(channelMessage.ChatId, channelMessage.MessageId);
        }