I would set the class as a Service in your module. Then your block implements this service and performs the processing. You really don't want to use require_once() if you can avoid this instead of using Drupal constructs (in part, so that if you reorganize things later, Drupal will help find the files in a new place).
Put the class in the src directory of your module and add the namespace at the beginning of the file (if it is not already there). Then, in the block class file, you can add a usage statement that references this namespace (it would be even better to use dependency injection, but more on that in your way).
In the build() block class method, you instantiate the class as described in your question, but instead of just letting the module print HTML, you might want to capture this HTML code and put it in your block as markup. If the class allows you to do this without using a buffer, you should (but I have not seen anything in the documents to support it), and then try to separate the structured data. If not, you can use PHP output buffering to record its attempt to print:
ob_start(); $twitter->PrintFeed(); $content= ob_get_contents(); ob_end_clean();
Then put the generated markup in the rendering array:
return [ 'my_twitter_block' => [ '#markup' => $content, ], ];
source share