installation

step 1 install LALib extension

  1. in SillyTavern open Extensions
  2. in the top-right select Install Extension

  1. put a link in the text field
    https://github.com/LenAnderson/SillyTavern-LALib
    
  2. click Install For All Users

  1. ...wait
  2. after installation - reload the tab

Q. what is LALib extension?
A. extension that enhances scripting in SillyTavern. by adding many new scripts: text-manipulation, JSON parsing, fetch/get data from other sites and so more

step 2 give ST permission to read derpibooru

  1. open ANY chat with ANY character
  2. send the following text to a character
    /fetch https://derpibooru.org/api/v1/json/images/937454 |
    
  3. click on the Allow Connection to derpibooru.org button below

  1. go to SillyTavern's settings and DISABLE Forbid External Media

step 3 install script

  1. open Extensions then Quick Reply

  1. scroll down to the Edit Quick Replies section, and click on button Create New Quick Reply Set button ( + icon), provide any name you want (i.e. lovemaking)

  1. next to it select created Set from dropdown

  1. scroll up to Global Quick Reply Sets, click on + sign next to it, select created Set and optionally disable buttons

  1. download this file (backup at the end of guide)
    https://files.catbox.moe/ce8fhv.json
    
  2. scroll down to Import Quick Reply From File at the VERY BOTTOM, import the file you downloaded

  1. you will see a huge script in the window above

  1. finally ENABLE Quick Replies (at the top)

Q. does it mean this script always work for ALL cards?
A. no, only for the 4chan card. the script checks if the current bot name is 4onechan and activates only on a match.

step 4. card

  1. download/import 4onechan card
  2. ST will inform you that bot has embedded regex. click YES to allow them

  1. open the card and check out the greeting. if you see a random image in 2nd post then everything works

  1. try to create a new chat - image should change

  1. if image ain't shown then:
    a) try opening a new chat again. maybe image is private or has forbidden tags? see below
    b) check you disabled Forbid External Media in settings
    c) check you ENABLED Quick Replies

step 5 enable regex

  1. scoped regex might be disabled by default. you need to enable them
  2. open Extensions then Regex
  3. down below look for Scoped Scripts. they must be ON

extras:

  • formatting breaks at higher temperatures
  • models with small brains like Gemini Flash may get confused easily. try using mid/big models
  • model/script checks your last message. if it contains OOC then it will treated as instruction/command. if it does not contain OOC then your last message will be converted into proper post. persona's name goes as namefagging. see the images below as examples of interaction

  • one more time - script takes your persona's name as your namefag. you can name your persona "princess Luna" and LARP as her. posters will react accordingly, then rename your persona to "the only human in Equestria" and ponies will react differently. samefagging ftw
  • script and model are trying their best to give proper (You) to your messages, and apply proper design when ponies quote you but system ain't perfect
  • correct colors for greentext and tags are not guaranteed, newlines either. but I have tried
  • model has NO idea what image it picks. in fact it picks nothing - ST just rolls with a random number and model copy-pastes it. so anticipate picrel will NOT be related to anything poster posts. at all. but when stars align perfectly, it is cute

  • open the script and check the first line:

    /let tags_banned ["grimdark", "suicide", "death", "dead", "amputee", "gore", "grotesque", "blood", "creepy", "rape"] | 
    

    these are banned tags. if model/ST picks an image that includes at least one of these tags - then image will not be shown for you, you don't want to be spooked by a random image of a dead pony do you? adapt that list according to your preferences

  • some images are set to private by the uploader or moderators (for example DNP lists). in this case image will not be shown either
  • tags are clickable and will take you to quoted post BUT read below

clickable tags STOP working correctly and instead open tag in NEW TAB if you EDIT a message

the reason lies in ST's retarded code: it sanitizes link attribute and forcefully sets target=\_blank to all chat links even if unaccounted for
script can fix it and change target=\_blank to target=\_self but ONLY at the end of model's generation. you cannot fire script at message edit sadly.

you can fix this issue manually tho! after editing your messages, send the following command into chat:

/dom quiet=true multi=true action=property property=target value=_self .custom-imageboard a |

it will fix broken tags.
sorry anons but I have no other ideas how to fix it

script backup

// add there image tags you DO NOT WANT model to show you, blacklist |
/let tags_banned ["grimdark", "suicide", "death", "dead", "amputee", "gore", "grotesque", "blood", "creepy", "rape"] | 

/let grablink {: link=
    /fetch {{var::link}} |
    /let json {{pipe}} |

    // if image has hidden_from_users then author or moderator made it private only |
    /getat index=["image", "hidden_from_users"] {{var::json}} |
    /ife (pipe) {:
        /echo image {{var::link}} is private |
        /return '' |
    :} |
    /else {:
        /getat index=["image", "tags"] {{var::json}} |
        /let tags_image {{pipe}} |

        // going thru all banned tags one by one and compare against tags for image. if there is a match then do no show this image |
        /let is_banned false |
        /foreach {{var::tags_banned}} {:
            /ife (item in tags_image) {:
                /var is_banned true |
                /break |
            :} |
        :} |

        // getting medium-sized images to not download some random 20mb pictures |
        /ife (!is_banned) {:
            /getat index=["image", "representations", "medium"] {{var::json}} |
            /return {{pipe}} |
        :} |
        /else {:
            /echo image {{var::link}} has a banned tag |
            /return '' |
        :} |
    :} |
:} |

/= char={{char}} ('4onechan' in char) |
/ife (pipe) {: 
    // getting images for Derpibooru |
    /message names=off {{lastMessageId}} |
    /re-replace find=/(https:\/\/derpibooru\.org\/api\/v1\/json\/images\/\d+)/g cmd="/:grablink link=$1"|
    /message-edit message={{lastMessageId}} {{pipe}} |

    // gives (You) to posts |
    // find user's post ID |
    /re-exec first=true find=/id[\ =]*(\d+)[^[]+class[\ =]*user_post/ {{lastMessage}} |
    /getat index=1 {{pipe}} |
    /let user_post_id {{pipe}} |
    // add (You) when user's post is referenced |
    /re-replace find=/>>({{var::user_post_id}})/g replace=">>$1 (You)" {{lastMessage}} |
    // remove multiple (You)s - (You) (You) (You) -> (You) happens if script is called multiple times |
    /re-replace find=/\(You\)([(You)\ ]+)/g replace="(You)" {{pipe}} |
    /message-edit message={{lastMessageId}} {{pipe}} |

    // fix for the broken anchors. can you believe that ST sets all links to target=blank by default? |
    // warning, breaks this fix if message was edited because STscript DOESNT launch on message editing |
    /dom quiet=true multi=true action=property property=target value=_self .custom-imageboard a |
:} |
Edit

Pub: 27 Mar 2025 21:15 UTC

Edit: 27 Mar 2025 21:24 UTC

Views: 434