Well... it depends.
You can have it watch for on NOTICE and on TEXT events when you join the channel and either automatically kick/ban the people if it happens within X seconds of joining. That method can end up kicking/banning legitimate people. Or, you can watch those same events for specific text when you join and if it contains that specific text, then you kick/ban them. That method would be safer, but it requires that you figure out all of the possible messages that you'd consider bad.