Giving up bad friends The Buddha has spoken many times about giving up bad friends, we can find it in the Dhammapada, in the beautiful Maha Mangala Sutta and many other places.

My first point is: If we abandon bad friends, how will they improve? What role compassion plays here? 

My second point is: It is very hard these days to completely abandon bad friends, we have social networks, professional networks, smartphones etc., we are connected like never before, it is very hard for a lay person to live only with good friends around, except if maybe he/she becomes a recluse, so what should one do? Just set limits?
The answer to this question may also depend on the individual and how advanced they are in Buddhist practice. If a person is solid in faith and regular in practice and can truly be that good example for friends that may help lead those friends to the Dhamma that is one thing. If the individual is newer to Buddhism and the keeping of precepts and right speech and needs lots of time to themselves to establish a regular meditation practice and learn about their new path then friends and social activities can be a distraction. In fairness, a person in the second scenario should explain to their friends why they can't be as available as they've been in the past, or why they are no longer willing to participate in certain activities. Good friends will understand and give you that time you need. Bad friends may not respect your commitment and may continually try to persuade you back to your old ways. It's not compassionate to yourself or even the bad friend to accommodate that. Leaving a bad friend with more time on their hands (because you are not around) may give them more time to think and may be the wake up call they need. 

As far as socializing in real life and online, you have to set limits and priorities or the days and weeks and months will simply fly by aimlessly. As a practical suggestion, I find Airplane mode on the my phone very handy when I want to use my phone based meditation timer but not be distracted by texts and notifications. :)