def get_owned_bot_dicts(user_profile: UserProfile, include_all_realm_bots_if_admin: bool=True) -> List[Dict[(str, Any)]]:
    if (user_profile.is_realm_admin and include_all_realm_bots_if_admin):
        result = get_bot_dicts_in_realm(user_profile.realm)
    else:
        result = UserProfile.objects.filter(realm=user_profile.realm, is_bot=True, bot_owner=user_profile).values(*bot_dict_fields)
    services_by_ids = get_service_dicts_for_bots(result, user_profile.realm)
    return [{'email': botdict['email'], 'user_id': botdict['id'], 'full_name': botdict['full_name'], 'bot_type': botdict['bot_type'], 'is_active': botdict['is_active'], 'api_key': botdict['api_key'], 'default_sending_stream': botdict['default_sending_stream__name'], 'default_events_register_stream': botdict['default_events_register_stream__name'], 'default_all_public_streams': botdict['default_all_public_streams'], 'owner_id': botdict['bot_owner__id'], 'avatar_url': avatar_url_from_dict(botdict), 'services': services_by_ids[botdict['id']]} for botdict in result]
def get_owned_bot_dicts(user_profile: UserProfile, include_all_realm_bots_if_admin: bool=True) -> List[Dict[(str, Any)]]:
    if (user_profile.is_realm_admin and include_all_realm_bots_if_admin):
        result = get_bot_dicts_in_realm(user_profile.realm)
    else:
        result = UserProfile.objects.filter(realm=user_profile.realm, is_bot=True, bot_owner=user_profile).values(*bot_dict_fields)
    services_by_ids = get_service_dicts_for_bots(result, user_profile.realm)
    return [{'email': botdict['email'], 'user_id': botdict['id'], 'full_name': botdict['full_name'], 'bot_type': botdict['bot_type'], 'is_active': botdict['is_active'], 'api_key': botdict['api_key'], 'default_sending_stream': botdict['default_sending_stream__name'], 'default_events_register_stream': botdict['default_events_register_stream__name'], 'default_all_public_streams': botdict['default_all_public_streams'], 'owner_id': botdict['bot_owner__id'], 'avatar_url': avatar_url_from_dict(botdict), 'services': services_by_ids[botdict['id']]} for botdict in result]