auto-assign usergroup by user ip address or anything i choose

anyway to auto assign a usergroup via init.php ? so i can force a usergroup if lets say geoip module returns XYZ or ip = xxx

etc ?