public async Task MemberKickJob( long chatId, long userId ) { var needVerify = await _stepHistoriesService.GetStepHistoryVerifyCore ( new StepHistory() { ChatId = chatId, UserId = userId } ); if (!needVerify.Any()) { return; } Log.Information( "Starting kick member for UserId {UserId} from {ChatId}", userId, chatId ); var history = needVerify.FirstOrDefault(); if (history == null) { return; } await _botClient.BanChatMemberAsync(chatId, userId); await _botClient.UnbanChatMemberAsync(chatId, userId); if (history.LastWarnMessageId != -1) { await _botClient.DeleteMessageAsync(chatId, history.LastWarnMessageId); } await UpdateStepHistoryStatus(chatId, userId); var chat = await _chatService.GetChatAsync(chatId); var sb = new StringBuilder() .Append("<b>Action:</b> #KickChatMember") .AppendLine() .Append("<b>User:</b> ") .AppendFormat("{0}\n", history.UserId.GetNameLink(history.FirstName, history.LastName)) .Append("<b>Chat:</b> ") .AppendFormat("{0} \n", chat.GetChatNameLink()) .Append("<b>Reason:</b> ") .AppendJoin(",", needVerify.Select(x => $"#{x.Name}")) .AppendLine() .AppendFormat( "#U{0} #C{1}", userId, chatId.ReduceChatId() ); await _botClient.SendTextMessageAsync( text : sb.ToTrimmedString(), disableWebPagePreview : true, chatId : _eventLogConfig.ChannelId, parseMode : ParseMode.Html ); Log.Information( "UserId {UserId} successfully kicked from {ChatId}", userId, chatId ); }