Drop packages for a specific user-agent

Is there a way to drop all packages for a specific user-agent when a user is not active in a hotspot?

I know the user-agent string, but puting it in layer 7 and creating a corresponding filter rule, doesn’t seem to work.