def created_bot_event(user_profile: UserProfile) -> Dict[(str, Any)]:

    def stream_name(stream: Optional[Stream]) -> Optional[str]:
        if (not stream):
            return None
        return stream.name
    default_sending_stream_name = stream_name(user_profile.default_sending_stream)
    default_events_register_stream_name = stream_name(user_profile.default_events_register_stream)
    bot = dict(email=user_profile.email, user_id=user_profile.id, full_name=user_profile.full_name, bot_type=user_profile.bot_type, is_active=user_profile.is_active, api_key=get_api_key(user_profile), default_sending_stream=default_sending_stream_name, default_events_register_stream=default_events_register_stream_name, default_all_public_streams=user_profile.default_all_public_streams, avatar_url=avatar_url(user_profile), services=get_service_dicts_for_bot(user_profile.id))
    if (user_profile.bot_owner is not None):
        bot['owner_id'] = user_profile.bot_owner.id
    return dict(type='realm_bot', op='add', bot=bot)
def created_bot_event(user_profile: UserProfile) -> Dict[(str, Any)]:

    def stream_name(stream: Optional[Stream]) -> Optional[str]:
        if (not stream):
            return None
        return stream.name
    default_sending_stream_name = stream_name(user_profile.default_sending_stream)
    default_events_register_stream_name = stream_name(user_profile.default_events_register_stream)
    bot = dict(email=user_profile.email, user_id=user_profile.id, full_name=user_profile.full_name, bot_type=user_profile.bot_type, is_active=user_profile.is_active, api_key=get_api_key(user_profile), default_sending_stream=default_sending_stream_name, default_events_register_stream=default_events_register_stream_name, default_all_public_streams=user_profile.default_all_public_streams, avatar_url=avatar_url(user_profile), services=get_service_dicts_for_bot(user_profile.id))
    if (user_profile.bot_owner is not None):
        bot['owner_id'] = user_profile.bot_owner.id
    return dict(type='realm_bot', op='add', bot=bot)