Tell them what the problem is, give suggestions on how to fix it, agree todefine a set of rules, and if they don't follow kick them out.
First, set expectations. Good gaming habitpractice is to have a session zero that goes over not just house rules, tone, theme, character building, but also table rules, like no cellphones'no cellphones' or keep'keep chatter to a minmin'. It's too late to do that this time, but not too late to have a conversation.
Before the next game say you want to have a discussion about table behavior. Perhaps do it online since these players don't show up regularly. Bring up the problems that are happening in the game(though do your best not to make it an attack on themthese players, because that increases the chance they'll get defensive and it will end in an argument). Explain that you want the game to run smoothsmoothly and in order to to do that, you need X, where X is a certain amount of agreed attendance (or a way to mitigate lesslack of attendance through, such as characters that are designed to disappear and reappear and are okOK not knowknowing whole swathsswathes of plot) and a certain respect for the game at the table. Suggest what rules you're okOK with and elicit feedback. Make sure you don't end the discussion without saying, "these"These are the rules and this is what I'm holding you tooto." Total agreement is the goal but since itthis appears to be your game it's not necessary. Just make sure you have a reasonable set of rules most of the group is okOK with.
When people start breaking the rules, pull them aside and mention it privately later. During the game simplesimply ask them to tighten up a bit. If itsit's rare, give them more chances. If it's frequent, boot them when they have violated itbroken the rules 3 times or so, depending on how severely disruptive they are. If they kill a whole game session after the talk, once is enough. You want to make sure you give them a chance, recognizing that they may be trying but not good at it. One of the problems with RPG's is that they are also often friend hangout time and most people want to relax and enjoy hanging, not do serious game face'game face' acting the whole time. There needs to be a balance but eventhat includes recognizing that it's easy to slipslipping into bad gaming behaviors as that is an easy habit to acquire. The important part is that they are trying, getting better, and not being overly disruptive. They need to show respect for the game and those who want to take it seriousseriously as well.
This is the rule I follow whenever I run a game itgame; it works very well. My group is particularly bad at showing up and not being disruptive. When other people step into the GM rollrole it tends to be much worse, sometimes losingwe lose whole sessions doing almost nothing. Because I set expectations no one is mad when I enforce them. Because I talk to people separately they are less likely to be defensive and more receptive to my point of view. I've never had to kick anyone out either. They will generally leave on their own if they can't follow the rules because they aren't having the type of fun they want. Itwant; it essentially becomes a mutual break up. That may not work in your case depending on how mature these players are but mine are hardly the most emotionally developed.