Imam Abu Hanifah (Rahimahullah) (150 AH) while advising his student Abu Yusuf (Rahimahullah) (182 AH) said:
"Do not mingle too much with people unless they themselves want to mingle with you. And whenever you meet them, start discussions of knowledge. So that he who is capable among them becomes occupied with knowledge, and he who is worthless/useless starts avoiding you and ends his attachment to you, rather he won't even come near you."
(Manaqib Abi Hanifah lil-Muwaffaq al-Makki: 2/114)