NickMueh

joined 9 months ago
[–] NickMueh 1 points 5 months ago* (last edited 5 months ago)

Does not seem to work from the Custom JavaScript code field, if I put into the chatbox then it works after words except of course Initial chat messages

3
submitted 5 months ago* (last edited 5 months ago) by NickMueh to c/perchance
 

So I'm trying to create a javascript that will scan the User's description/role for the following fields: Last_Name, Race, Political Entity, Rank, Position to be used in Character description/personality/instruction/role and Initial chat messages, But it wouldn't work. So I came up with a twork around where its stored in the javascript. I require help in getting a javascript code that scans User's description/role.

Original

function extractInfo(description) {
    const fields = {
        lastName: description.split('Last Name:')[1].split('\n')[0].trim(),
        race: description.split('Race:')[1].split('\n')[0].trim(),
        politicalEntity: description.split('Political Entity:')[1].split('\n')[0].trim(),
        rank: description.split('Rank:')[1].split('\n')[0].trim(),
        position: description.split('Position:')[1].split('\n')[0].trim()
    };

    return {
        getLastName: () => fields.lastName,
        getRace: () => fields.race,
        getPoliticalEntity: () => fields.politicalEntity,
        getRank: () => fields.rank,
        getPosition: () => fields.position
    };
}

const info = extractInfo(user.description);
console.log(info.getLastName()); // Should output the last name
console.log(info.getRace()); // Should output the race
console.log(info.getPoliticalEntity()); // Should output the political entity
console.log(info.getRank()); // Should output the rank
console.log(info.getPosition()); // Should output the position

Retrieve each field by calling info.getLastName(), info.getRace(), and so on. Problem is replacing user.description with the actual string containing the user's description.

Work Around

function extractInfo(description) {
    const namePattern = /(?:(?:\b\w+\s){2,})(?:\b\w+\b)/;
    const lastName = description.match(namePattern)[1];
    const racePattern = /\bRace\b\s*:\s*([\w\s]+)/;
    const race = description.match(racePattern)?.length > 0 ? description.match(racePattern)[1] : "Unknown";
    const politicalEntityPattern = /\bPolitical Entity\b\s*:\s*([\w\s]+)/;
    const politicalEntity = description.match(politicalEntityPattern)?.length > 0 ? description.match(politicalEntityPattern)[1] : "Unknown";
    const rankPattern = /\bRank\b\s*:\s*([\w\s]+)/;
    const rank = description.match(rankPattern)?.length > 0 ? description.match(rankPattern)[1] : "Unknown";
    const positionPattern = /\bPosition\b\s*:\s*([\w\s]+)/;
    const position = description.match(positionPattern)?.length > 0 ? description.match(positionPattern)[1] : "Unknown";

    return {
        lastName: <lastName>,
        race: <race>,
        politicalEntity: <politicalEntity,>
        rank: <rank>,
        position: <position>
    };
}

const updatedDescription = "<short description>";
const updatedResult = extractInfo(updatedDescription);
console.log(updatedResult);

Where you can call each field individually by accessing the properties of the returned object, like result.lastName, result.race, result.politicalEntity, and result.rank.

5
[INFO] NSFW Tags (self.perchance)
submitted 9 months ago by NickMueh to c/perchance
 

So I've been creating content for a while, and while I thought some where harmless they ended up being flagged as not being PG-13. I was wondering if there is a list of certain words that are flagged for NSFW content. Maybe if there is a link or list could be posted here.

[–] NickMueh 1 points 9 months ago* (last edited 9 months ago)

well, I found the problem. The text-to-image generator for perchance I have is api which won't work. If I knew where to get the HTML version then I think I'd be ready to go. Any ideas where to get that HTML version?

[–] NickMueh 1 points 9 months ago

well neither of those helped

 

So I'm using the most current version of firefox (desktop) and have went round and round with this. Still get the error "TL;DR: Try turning off your ad blocker." Even though I have been to many sites and followed their step. Disabled tracking feature (little shield top left corner) and made sure java was allowed. Could sure use help.