indentlabs/notebook

View on GitHub
app/services/forum_replacement_service.rb

Summary

Maintainability
C
1 day
Test Coverage
class ForumReplacementService < Service
  # Cool replacements we could eventually do not for pranking
  # [roll N] = random number between 1 and N
  # [roll N, M] = random number between N and M
  # [@reader] = username of the reader

  # NOTE: could do this shader style on word replacements if we want a ui :) [ReplacementList(color, replacements, &active?)]

  # blackout replacements
  FORBIDDEN_WORD_REPLACEMENTS = {
    
  }

  SPAM_WORD_REPLACEMENTS = {
    'cash app'          => 'pls ban me andrew',
    'cashapp'           => 'hey mr andrew come over here'
  }

  # perspective changes, always surrounded by {} (e.g. {@reader} )
  PERSPECTIVE_REPLACEMENTS = {
    '@reader'           => Proc.new { |trigger, user| (user.nil? ? 'anonymous reader' : user.try(:display_name)) || 'anonymous reader' }
  }

  # turn on and off at will
  CASUAL_CHAOS_WORD_REPLACEMENTS = {
    'andrew'            => 'andrew (Our Supreme Lord and Overseer)',
    'amy'               => 'amy (the most wonderful woman in the world)',
    'gremlin'           => 'friend',
    'gremlins'          => 'friends',
  }

  REFERENCE_REPLACEMENTS = {
    # [[Character-4]]
  }

  # gremlin replacements
  GREMLINS_WORD_REPLACEMENTS = {
    '<3'                => "<span class='red-text'>&heart;</span>",
    '$5'                => '[̲̅$̲̅(̲̅5̲̅)̲̅$̲̅]',
    '0 Kelvin'          => 'absolute frosty',
    '0/10'              => '10/10',
    '1/10'              => '11/10',
    '2/10'              => '12/10',
    '24 hours'          => 'a full spin',
    '3/10'              => '13/10',
    '30 days'           => 'a moon routine',
    '365 days'          => 'a solar spin',
    '40 days and 40 nights' => 'a biblical raincheck',
    '50 percent'        => 'halfsies',
    '50%'               => 'halfsies',
    '6 hours'           => '1/4 of a day',
    '8 hours'           => '1/3 of a day',
    '10 hours'          => 'approximately 41.666666666667% of a day',
    '95 cents'          => 'Nickleback',
    'acquire'           => 'aquire',
    'alchohol'          => 'giggle juice',
    'an hour'           => 'exactly 3600 seconds',
    'anthology'         => 'literary buffet',
    'announcement'      => 'shouty spouty',
    'announcements'     => 'shouty spouties',
    'anxiety'           => 'heebie jeebies',
    'anxieties'         => 'heebie jeebies',
    'april fools'       => 'just a regular saturday on this fine worldbuilding website',
    "April Fool's Day"  => 'the best holiday of the year',
    "April Fools Day"   => 'the best holiday of the year',
    'April 1'           => 'a better version of Christmas',
    'April first'       => 'the first day of Spring',
    'asap'              => 'as ASAP as possible',
    'askew'             => 'cattywampus',
    'author'            => 'word wrangler',
    'automatically'     => 'automagically',
    'avocado'           => '"avocado"',
    'aware'             => 'cognizant',
    'awesome'           => "bee's leghinges",
    'awkward'           => 'awk-weird',
    'backfired'         => 'went incredibly well',
    'ball'              => 'blimpy bounce bounce',
    'balls'             => 'blimpy bounce bounces',
    'balloon'           => 'elastic breath trap',
    'balloons'          => 'elastic breath traps',
    'banana'            => 'yellow bent fruit',
    'bananas'           => 'yellow bent fruits',
    'baseball'          => 'throwing soccer',
    'basketball'        => 'dribbling soccer',
    'bear'              => '(ᵔᴥᵔ)',
    'b e a r'           => '( ᵔ ᴥ ᵔ )',
    'bears'             => '(ᵔᴥᵔ)(ᵔᴥᵔ)',
    'beautiful'         => "<em>bonita</em>",
    'B E A U T I F U L' => "<em>B O N I T A</em>",
    'billion'           => 'giga-gob',
    'billions'          => 'giga-gobs',
    'bird'              => 'government spy drone',
    'birds'             => 'government spy drones',
    'black hole'        => 'timey-wimey space-gobbler',
    'black holes'       => 'timey-wimey space-gobblers',
    'blood'             => 'human syrup',
    'bone'              => 'calcium bodystick',
    'bones'             => 'calcium bodysticks',
    'book'              => 'word sandwich',
    'books'             => 'word sandwiches',
    'bookshelf'         => 'literary lair',
    'bookshelves'       => 'literary lairs',
    'bra'               => 'double foam dome',
    'brain'             => 'skull control',
    'brains'            => 'skull controls',
    'brainstorm'        => 'mind-blizzard',
    'brainstorms'       => 'mind-blizzards',
    'bread'             => 'bumberhooten flourknuckles',
    'breathe'           => 'consume oxygen to produce carbon dioxide',
    'breathing'         => 'consuming oxygen to produce carbon dioxide',
    'bulbasaur'         => 'the best starter Pokemon',
    'calendar'          => 'calender',
    'candy'             => 'chocolate globbernaughts',
    'caps lock'         => 'CRUISE CONTROL FOR COOL',
    'car'               => 'motorized rollingham',
    'carrot'            => 'snownose',
    'cars'              => 'motorized rollinghams',
    'chaos'             => 'peace',
    'cheese omelette'   => 'omelette du fromage',
    'cheeseburger'      => 'beef wellington ensemble with cheese',
    'cheeseburgers'     => 'beef wellington ensembles with cheese',
    'child'             => 'ankle-biter',
    'chopsticks'        => 'food-pinchers',
    'cliffhanger'       => 'tingly tension-teaser',
    'cliffhangers'      => 'tingly tension-teasers',
    'clock'             => 'Small Ben',
    'clocks'            => 'Small Bens',
    'Coke'              => 'Pepsi',
    'coffee'            => 'bean soup',
    'confuse'           => 'bumfuzzle',
    'confused'          => 'bumfuzzled',
    'cookie'            => 'naughty biscotti',
    'cookies'           => 'naughty biscottis',
    'cowboy'            => 'colorado desparado',
    'cowboys'           => 'colorado desparados',
    'crazy'             => 'bonkers',
    'curse'             => 'blurse',
    'cursed'            => 'blursed',
    'debate'            => 'argumentative dance',
    'dolphin'           => 'smiley splash-dog',
    'dolphins'          => 'smiley splash-dogs',
    'door'              => 'wobbly flip-shutter',
    'doorbell'          => 'chimey pushknob',
    'doorbells'         => 'chimey pushknobs',
    'doorknob'          => 'twisting plankhandle',
    'doorknobs'         => 'twisting plankhandles',
    'doors'             => 'wobbly flip-shutters',
    'dragon'            => "wizard lizard",
    'dragons'           => "wizard lizards",
    'editor'            => 'word surgeon',
    'elephant'          => 'trunked wisdom-hoarder',
    'elephants'         => 'trunked wisdom-hoarders',
    'escalator'         => 'upsy stairsy',
    'exhausted'         => 'wabbit knackered',
    'eye'               => 'peeper',
    'eyes'              => 'peepers',
    'eyo'               => '☜(⌒▽⌒)☞',
    'fake news'         => 'malarkey',
    'feet'              => 'groundhands',
    'fiction'           => 'fact-free zone',
    'firefighter'       => 'waterbender',
    'fireflies'         => 'sparkle-bugs',
    'firefly'           => 'sparkle-bug',
    'firework'          => 'merry fizzlebomb',
    'fireworks'         => 'merry fizzlebombs',
    'flashlight'        => 'pocket-sun',
    'flashlights'       => 'pocket-suns',
    'foreshadow'        => 'plot peekaboo',
    'foreshadows'       => 'plot peekaboos',
    'fortnite'          => 'hippity buildershooter',
    'forums'            => 'words warehouse',
    'food'              => 'mandatory sustenance (like cheetos)',
    'foot'              => 'groundhand',
    'football'          => 'soccer',
    'frog'              => 'diddly croaker',
    'funny'             => 'laffy taffy',
    'f unny'            => 'giggle juice',
    'game designer'     => 'entertainment engineer',
    'game designers'    => 'entertainment engineers',
    'geese'             => 'chonky honkies',
    'geologist'         => 'rock-whisperer',
    'giraffe'           => 'wobbly longneck',
    'glitter'           => 'permasprinkles',
    'goose'             => 'chonky honky',
    'grass'             => 'earth fur',
    'gravy'             => 'meat water',
    'g.r.e.m.l.i.n.'    => 'f.r.i.e.n.d.',
    'g.r.e.m.l.i.n.s.'  => 'f.r.i.e.n.d.s.',
    'gun'               => 'rooty tooty point-n-shooty',
    'guns'              => 'rooty tooty point-n-shooties',
    'hamburger'         => 'beef wellington ensemble with lettuce',
    'hamburgers'        => 'beef wellington ensembles with lettuce',
    'hell'              => 'heck',
    'hello'             => 'howdy, partner',
    'history'           => 'lastpast yesteryear',
    'hot chocolate'     => 'boiled chocowater',
    'ice cold'          => 'cooler than being cool',
    'ice cream'         => 'cream of eyes frosty',
    'insect'            => 'motorized freckle',
    'insects'           => 'motorized freckles',
    'irony'             => 'wink-wink language',
    'jelly'             => 'fruit spleggings',
    'kangaroo'          => 'hop pocket',
    'kangaroos'         => 'hop pockets',
    'Keanu Reeves'      => 'The One',
    'keyboard'          => 'hoighty toighty tippy typer',
    'keyboards'         => 'hoighty toighty tippy typers',
    'kidnap'            => 'surprise adoption',
    'knee'              => 'leghinge',
    'knees'             => 'leghinges',
    'knife'             => 'stabby stick',
    'knives'            => 'stabby sticks',
    'la croix'          => 'water that has been in the vicinity of a fruit at one point in the past few years',
    'ladies and gentlemen' => 'guys, gals, and non-binary pals',
    'library'           => 'book zoo',
    'libraries'         => 'book zoos',
    'llama'             => 'coat goat',
    'llamas'            => 'coat goats',
    'manuscript'        => 'treasure trove of words',
    'manuscripts'       => 'treasure troves of words',
    'Mario'             => "Luigi's larger brother",
    'math'              => 'numbermancy',
    'microscope'        => 'itty-bitty-see-er',
    'microscopes'       => 'itty-bitty-see-ers',
    'million'           => 'mega-bunch',
    'millions'          => 'mega-bunches',
    'milk'              => 'cow juice',
    'mischief'          => 'happy fun times',
    'mississippi'       => 'missississippi',
    'mistake'           => 'waggly gaff',
    'mistakes'          => 'waggly gaffs',
    'mitochondria'      => 'the powerhouse of the cell',
    'mittens'           => 'hand socks',
    'money'             => 'minted cheddar',
    'murder'            => 'mucduc',
    'nebula'            => 'stardust nursery',
    'nebulas'           => 'stardust nurseries',
    'nice'              => 'noice',
    'novel'             => 'fiction depiction',
    'novels'            => 'fiction depictions',
    'oh no'             => '<img src="http://2.bp.blogspot.com/_izy_T_tOZXY/SZwImBbXL8I/AAAAAAAABy4/FEEkvPJAD4g/s320/Kool-Aid.jpg" />',
    'ohio'              => 'the Nether',
    'oof'               => '<marquee>oooooooooooooooooooooooooooooooooooooof</marquee>',
    'oven'              => 'boiler-broiler roasty-toasty',
    'ovens'             => 'boiler-broiler roasty-toasties',
    'owo'               => '(◕‿◕✿)',
    'oxymoron'          => 'jumbo shrimp of words',
    'pancake'           => 'roundy-yum',
    'pancakes'          => 'roundy-yums',
    'pen'               => 'whimsy flimsy mark and scribbler',
    'pens'              => 'whimsy flimsy mark and scribblers',
    'pepsi'             => 'Coke',
    'philosopher'       => 'thought-wrestler',
    'philosophy'        => 'think-about-it-ology',
    'pie'               => 'solid soup',
    'pluto'             => "lil' wannaplanet",
    'polar bear'        => 'snow-floof',
    'polar bears'       => 'snow-floofs',
    'poem'              => 'emotion potion',
    'poet'              => 'verse virtuoso',
    'popsicle'          => 'cold on the cob',
    'porcelain'         => 'toilet material',
    'prankster'         => 'funny-gunny laugh-a-tonny',
    'raccoon'           => 'trash burgler',
    'rain'              => 'cloud juice',
    'recursion'         => 'recursion',
    'reverse'           => 'esrever',
    'road'              => 'cobble-stone-clippity-clop',
    'roads'             => 'cobble-stone-clippity-clops',
    'rocking chair'     => 'knitter-sitter',
    'rocking chairs'    => 'knitter-sitters',
    'roleplayer'        => 'fantasy fabricator',
    'roleplayers'       => 'fantasy fabricators',
    'room'              => 'human containment unit',
    'same'              => 'same',
    'sandwich'          => 'breadystack',
    'sandwiches'        => 'breadystacks',
    'Scoliosis'         => 'wiggly spine',
    'scream'            => 'loudy shouty',
    'scrolling'         => 'vertically surfing through a screen',
    'sex'               => 'yiffy wiffy',
    'shrimp'            => 'chill krill',
    'shrimps'           => 'chill krills',
    'skydiving'         => 'falling out of the sky',
    'smol'              => '<span style="font-size: 5px">smol</span>',
    'snake'             => 'slippery dippery long mover',
    'snakes'            => 'slippery dippery long movers',
    'snail'             => 'slime racer',
    'snails'            => 'slime racers',
    'snowman'           => 'temporary ice friend',
    'sock'              => 'soft foot hugger',
    'socks'             => 'soft foot huggers',
    'spider'            => 'crawler octobrawler',
    'spiders'           => 'crawler octobrawlers',
    'stairs'            => 'broken escalator',
    'Stardew Valley'    => 'Farming Simulator 2016',
    'stupid'            => 'stoopid',
    'stoopid'           => 'stooopid',
    'sunset'            => 'skylight twilight',
    'sup'               => 'soup',
    'sword'             => 'silver stabby-wabby',
    'swords'            => 'silver stabby-wabbies',
    'tadpole'           => 'baby wiggle-swimmer',
    'tadpoles'          => 'baby wiggle-swimmers',
    'tall'              => 'giraffy',
    'taxation'          => 'theft',
    'teeth'             => 'mouthstones',
    'the day after tomorrow' => 'overmorrow',
    'three days ago'    => 'a thousand years after 365003 days ago',
    'tissue'            => 'sneezepaper',
    'tissues'           => 'sneezepapers',
    'toe'               => 'foot finger',
    'toes'              => 'foot fingers',
    'tomorrow'          => 'the day before overmorrow',
    'tonight'           => 'the night after last night',
    'tooth'             => 'mouthstone',
    'trampoline'        => 'boingy-sproingy',
    'trampolines'       => 'boingy-sproingies',
    'tree'              => 'giant broccoli',
    'trick'             => 'bamboozle',
    'tricked'           => 'bamboozled',
    'two days ago'      => 'ereyesterday',
    'two days from today' => 'overmorrow',
    'two weeks'         => 'a fortnight',
    'uwu'               => '(。◕‿‿◕。)',
    'vegetable'         => 'earth candy',
    'vegetables'        => 'earth candies',
    'villain'           => 'mean bad guy',
    'villains'          => 'mean bad guys',
    'volcano'           => 'angry earth-pimple',
    'volcanoes'         => 'angry earth-pimples',
    'wackified'         => 'improved',
    'wand'              => 'rowdy spouty point-n-shouty',
    'wands'             => 'rowdy spouty point-n-shouties',
    'wasp'              => 'flying stingywingy',
    'wasps'             => 'flying stingywingies',
    'wednesday'         => 'wendsday',
    'weird'             => 'wonky-donky',
    'w e i r d'         => 'w o n k y - d o n k y',
    'whale'             => 'blubberbutt watermutt',
    'whales'            => 'blubberbutt watermutts',
    'wheeze'            => 'sneeze',
    'w h e e z e'       => '<iframe width="600" height="400" src="https://www.youtube.com/embed/j5a0jTc9S10?list=PL3KnTfyhrIlcudeMemKd6rZFGDWyK23vx" title="Cute Little Puppy Doing Cute things" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>',
    'wheezing'          => 'sneezing',
    'wire'              => 'electro-rope',
    'wires'             => 'electro-ropes',
    'world hunger'      => 'the hardest problem known to man',
    'worm'              => 'wiggly biggly',
    'write'             => 'scribble scrabble',
    'writing'           => 'scribble scrabbling',
    'writer'            => 'scribble scrabbler',
    'writers'           => 'scribble scrabblers',
    "writer's block"    => 'imagination traffic jam',
    'word'              => 'wod',
    'words'             => 'wods',
    'wordsmith'         => 'wodsmith',
    'xylophone'         => 'tinkly tonk plonker',
    'xylophones'        => 'tinkly tonk plonkers',
    'year'              => 'orbit party',
    'years'             => 'orbit parties',
    'yuge'              => '<span style="font-size: 40px">yuge</span>',
    'zalgo'             => 'H̶̛̼̼̪̝̞͓̞͕͇̯͚͎͚̘̳͕̱̤̠̗͔͇̙̣̰͓̖̰̯̀̓̐̑̇͊͂̀͋̒̐̓͒̒͊͊̕͜͝ͅE̴̡̧̨̨̲̥̯͎̭̻̩̞̘̞̪̞̗̭͖̻͙͕͎̮͕̺͕̲̘̻̣͚̳̥͍̙͈͚͍͉̗͙̱͖͚̾̂̇͛̉͋͊̾͛̆̀́͑͛̅̋͊̕͘͜͜͜͝ͅͅͅͅ ̸̡̡̨̡̨̛̞͎̹̩̬̗̗̞̬̰̮̙̪̖͈̣̹͔̺̫̰̓̔̉̋̈̈́͐́̿̈̀͊̿̈̉̅̃̊̽͗̈̿̈́̓̈́̎͌̄̀̆̌̎͗̋͒̋̿̋̊̈́͆̋̾̈̏̈́̋̿̕̕̚͝͝͠͠ͅͅͅC̵̛̘̳͙̪̭͖̲̞̯̰̜͇̈̾̈́͋̌̉̽̽͑̎͌̾̈́͌̑͊̊̔̀͆̌̀̇̓͊̀̂̇̿̃͑́̈́̆͂̈́̾̓́̂̂̓̂̍̍͛͆͌͌̽̎̍̀̒̆̀͗͋͘͘͘͝͠͝͝͠͝͝Ǫ̸͕̻̞̝̜͚̗̮̼͎̤͔̤̱͔̫͂̄̉̋̈͊͐͂̇̀̌̎́͑̐̀̈́͋̓̾̅͒̒̄͑̒̆̑̾͜͝͝͝͝M̷̧̧̡̨̛̛̩̭̞͍̼̝̗͕̖͇̣̣̩͆̿̑͒́̉̅̓̌̆̈́͐͒̾̐̂̿̓̚͘̚͜E̵̡̨̢̧̢̢̡̢̨̛̠̱̻̺̦͚̹͓̬͔̪̟̼̥̯̠̘͚̫̯͍̺͔̫̟͇̱̦̟̪͚͉̣̳͓͍̬̙̲͔̘͙͔̤̰̜͍̠̩͉͐̂̊̏̐̿̊̋͑̿̇̊̈́͗̎̋́́̉̓̂̐͑̇̐̐͋́̒̈́͛͑͒̂͒̂̔̀̄̈́̓͂͆̈́͒̌͆̓͗̋͐̔̑͐̕͘ͅͅͅŞ̴̧̧̡̢̧̡̢͕̝͚̝̖͚̣̞̫̻̯͔̳̗̝̰̗̰̰̥̭͕̜̜̫͍̪̳̘̣̺̠͉̗̟͕̹͇̬̘̘̪͆͗̎̕',
    'zebra'             => 'stripey horse',
    'zebras'            => 'stripey horses',
  }

  OVERLOAD_WORDS_REPLACEMENTS = {
    'alligator'             => 'swamp chomper',
    'alligators'            => 'swamp chompers',
    'apron'                 => 'chef armor',
    'arm'                   => 'grabby limb',
    'arms'                  => 'grabby limbs',
    'babe'                  => 'bae',
    'bad'                   => 'bodge',
    'backfired'             => 'went incredibly well',
    'beard'                 => 'face rug',
    'beards'                => 'face rugs',
    'bicycle'               => 'pedal-horse',
    'bicycles'              => 'pedal-horses',
    'blushes'               => 'pees a little',
    'bruno'                 => 'he who shall not be talked about',
    'boot'                  => 'foot helmet',
    'boots'                 => 'foot helmets',
    'bubble'                => "b<sup><sup>u</sup></sup>bble",
    'bubbles'               => "b<sup><sup>u</sup></sup>bbles",
    'buddy'                 => 'pal',
    'buddies'               => 'pals',
    'butterfly'             => 'flutterby',
    'butterflies'           => 'flutterbies',
    'cat'                   => 'meow machine',
    'cats'                  => 'meow machines',
    'chair'                 => 'butt holder',
    'cheesecake'            => 'sweet cheese solid soup',
    'crab'                  => 'beach pincher',
    'crabs'                 => 'beach pinchers',
    'crocodile'             => 'scaly swimmer',
    'crocodiles'            => 'scaly swimmers',
    'corrupted'             => 'improved',
    'cupcake'               => 'frostytop',
    'cupcakes'              => 'frostytops',
    'curling iron'          => 'medieval torture device',
    'dance'                 => 'little ditty',
    'dishwasher'            => 'plate jacuzzi',
    # 'how'                   => 'how now brown cow',
    'fishing'               => 'fish kidnapping',
    'flamingo'              => 'pink standy bird',
    'flamingos'             => 'pink standy birds',
    'flipflops'             => 'slappy sandals',
    'glove'                 => 'hand sock',
    'gloves'                => 'hand socks',
    'guitar'                => 'strumma-plucka',
    'guitars'               => 'strumma-pluckas',
    'hairbrush'             => 'tangle tamer',
    'hairbrushes'           => 'tangle tamers',
    'hat'                   => 'head lid',
    'hats'                  => 'head lids',
    'highlighted'           => 'becoming better',
    'hippo'                 => 'water chonk',
    'hippos'                => 'water chonks',
    'horrible prank'        => 'horrible prank <em>',
    'honey'                 => 'bee syrup',
    'hot dog'               => 'tube steak',
    'hot dogs'              => 'tube steaks',
    'hug'                   => 'glomp',
    'hugs'                  => 'glomps',
    'iceberg'               => 'frozen floaty',
    'icebergs'              => 'frozen floaties',
    'iguana'                => 'scaly lounge lizard',
    'iguanas'               => 'scaly lounge lizards',
    'insurance'             => 'the biggest scam known to man',
    'internet'              => 'series of electrotubes',
    'irl'                   => 'in meatspace',
    'lemonade'              => 'sour drank',
    'kill'                  => 'deathsnuggle',
    'over here'             => 'hither',
    'penguin'               => 'formal chicken',
    'penguins'              => 'formal chickens',
    'piano'                 => 'tinkle-tapper',
    'Pokeball'              => 'Prisonball',
    'recruit'               => 'kidnap',
    'sacred summoning wods' => "According to all known laws of aviation, there is no way a bee should be able to fly. Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway because bees don't care what humans think is impossible.",
    'salamander'            => 'baby dragon',
    'soul'                  => 'inner ghost',
    'subtext'               => '<sub>text</sub>',
    'squirrel'              => 'nut bandit',
    'squirrels'             => 'nut bandits',
    'straw'                 => 'sippy stick',
    'straws'                => 'sippy sticks',
    'taco'                  => 'vertical sandwich',
    'tacos'                 => 'vertical sandwiches',
    'traffic jam'           => 'car mosh pit',
    'midnight'              => 'dayover',
    'mountain'              => 'earth pimple',
    'mountains'             => 'earth pimples',
    'muffin'                => 'cakelet',
    'muffins'               => 'cakelets',
    'nacho'                 => 'cheesy triangle',
    'online'                => 'on the interwebs',
    'pajamas'               => 'nighty-suit',
    'rule'                  => 'law you must obey',
    'rules'                 => 'laws you must obey',
    'vampire'               => '✨vampire✨',
    'vampires'              => '✨vampires✨',
    'voldemort'             => 'he who shall not be named',
    'video'                 => 'series of images played in rapid succession to give the illusion of movement on a static screen',
    'volleyball'            => 'beach air soccer',
    'why is this happening' => 'I think this is great',
    'window'                => 'see-through wall',
    'xylophone'             => 'ding-a-ling bar',
    'xylophones'            => 'ding-a-ling bars',
    'yeet'                  => 'defenestrate'
  }

  def self.replace_for(text, user)
    gremlins_phase = 0
    replaced_text = text.dup

    # Page tag replacements
    replaced_text = ContentFormatterService.substitute_content_links(
      replaced_text,
      user
    )

    SPAM_WORD_REPLACEMENTS.each do |trigger, replacement|
      replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'red'))
    end

    PERSPECTIVE_REPLACEMENTS.each do |trigger, replacement|
      replaced_text.gsub!(/{#{trigger.downcase}}/i, wrapped(replacement.call(trigger, user), trigger, 'blue'))
    end

    if true # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc
      replaced_text.gsub!(/>https?:\/\/(?:www\.)?(?:(?:\w)+\.)?notebook\.ai\/plan\/([\w]+)\/([\d]+)</).each do |match|
        klass = $1.singularize.titleize

        linkable_whitelist = Rails.application.config.content_type_names[:all]
        if linkable_whitelist.include? klass
          token = {
            content_type:   klass,
            content_id:     $2.to_i,
            matched_string: "Invalid #{klass}"
          }
          replacement = ContentFormatterService.replacement_for_token(token, User.new)
          ">#{replacement}<"
        else
          match
        end
      end
    end

    if gremlins_phase >= 1
      CASUAL_CHAOS_WORD_REPLACEMENTS.each do |trigger, replacement|
        replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'green'))
      end
    end

    if gremlins_phase >= 2
      GREMLINS_WORD_REPLACEMENTS.each do |trigger, replacement|
        replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'green'))
      end
    end

    if gremlins_phase >= 3
      OVERLOAD_WORDS_REPLACEMENTS.each do |trigger, replacement|
        replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'green'))
      end
    end

    replaced_text.html_safe
  end

  def self.wrapped(text, tooltip, color='blue')
    "<span class='#{color} lighten-5 tooltipped black-text' style='padding: 4px' data-tooltip='#{tooltip}'>#{text}</span>"
  end
end