Last active
January 1, 2016 14:38
-
-
Save tuxity/8158613 to your computer and use it in GitHub Desktop.
Backport Linkinus script to Textual - http://www.codeux.com/textual/wiki/Writing-Scripts.wiki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Script Name: Slap | |
-- Version: 1.6.2 | |
-- Description: Slap script executes a /me action that will highlight and humiliate the subject | |
-- Author: Nikolas 'Okeanos' Grottendieck | |
on textualcmd(parameter, destinationChannel) | |
-- setup | |
-- linebreak character | |
set nl to ASCII character 10 | |
-- typelist of possible slap options | |
-- -rand (random) is always the last item in the list! | |
set typelist to {"%flip", "%rev", "%norm", "%fliprev", "%rand"} | |
-- output is fixed in the else using >set AppleScript's text item delimiters to ""< later on | |
set tempnick to "######" | |
if parameter is "" then | |
return "/debug echo Proper use of this command is: /slap [Mode] victim [item]" & nl & "/debug echo The script will echo a random slap(-like) action if no item has been specified. If an item has been specified, it will be used as item to slap with using /me slaps victim around a bit with <random adjective> [item]." & nl & "/debug echo The [Mode] parameter is also optional and may be replaced with one the following Modes: %flip, %rev, %fliprev or %rand. " & nl & "/debug echo These Modes flip the slap, make it appear in reverse or use a random one. Output can look like this then /me ʇnoɹʇ ǝƃɹɐl ɐ ɥʇıʍ ʇıq ɐ punoɹɐ victim sdɐls" | |
else | |
set AppleScript's text item delimiters to " " | |
-- get Mode if it matches the typelist | |
set mode to get first text item of parameter | |
if mode is not in typelist then | |
-- set nick | |
set nick to mode | |
try | |
set object to searchReplace(parameter, nick & "", "") | |
on error | |
set object to "" | |
end try | |
-- reset Mode | |
set mode to "" | |
else if mode is in typelist then | |
set newstring to searchReplace(parameter, mode & " ", "") | |
set nick to get first text item of newstring | |
try | |
set object to searchReplace(newstring, nick & "", "") | |
on error | |
set object to "" | |
end try | |
end if | |
--reset delimiters | |
set AppleScript's text item delimiters to "" | |
-- random list for adjectives used for some items of the list | |
-- implemented at theItem and TheSlap | |
set theAdjList to {"a fluffy concrete", "a large and terrifyingly cute plush", "a large", "a small", "a concrete", "a large and pointy", "a large and fearsome", "a cute little", "a large, wet and smelly", "a large and heavy", "a small and lightweight", "a marble", "a pink", "a terrifyingly small and cute", "a tiny and bloodstained", "a random", "an enormous", "a medium sized", "a breath taking", "an extra large", "a huge", "a suspicious", "a terrifying", "a scary", "a horrifying", "an impervious", "a green", "a blue", "a red", "a pink", "a dirty", "a brown", "a silver", "a golden", "a black", "a yellow", "a magenta", "an translucent", "a nontransparent", "a mysterious", "a puzzling", "a perplexing", "a baffling", "a mystifying", "a confusing", "a unfathomable", "an incomprehensible", "an unintelligible", "a Delphic", "an impenetrable", "an oblique", "an enigmatic", "a cryptic", "a hazy", "a foggy", "a grimy", "a smeared", "a muddied", "a plain", "a vague", "an irrefutable", "a palpale", "a genuine", "an authentic", "a real", "a bona fide", "a veritable", "an attested", "a honest-to-goodness", "a kosher", "a natural", "a stained", "a broken", "a dyed", "a splattered", "a blotched", "a smudged", "a blemished", "a tainted", "a damaged", "a colorful", "a magnificient", "an amazing", "a sublime", "a superb", "a glorious", "a tremendous", "a sensational", "a gorgeous", "a grand", "a fabulous"} | |
set ListCount to the count of theAdjList | |
set pick to random number from 1 to ListCount | |
set theAdj to item pick of theAdjList as string | |
-- random item list for slaps/throws | |
if object is not missing value and object is not " " and object is not "" then | |
set theSlap to "slaps " & tempnick & " around a bit with " & theAdj & object | |
else | |
set theItemlist to {"%%%%% kitty", "%%%%% Nintendo Wii", "%%%%% dolphin", "%%%%% rainbow trout", "System Software 1.0", "%%%%% Imperial-Class Stardestroyer", "%%%%% macintosh", "%%%%% baseball bat", "%%%%% chessboard", "%%%%% Ming Vase", "%%%%% donkey", "%%%%% Playstation 3", "%%%%% shovel", "a carefully selected range of random items", "%%%%% stick", "the Windows 95 Buglist", "the Windows ME Buglist", "%%%%% something", "%%%%% gold fish", "%%%%% sledgehammer", "%%%%% trout", "%%%%% cuttlefish", "something large and heavy from Dell", "something small and lightweight from Apple", "Cthulhu's tentacles", "%%%%% bust of Julius Caesar", "a verse or two of Vogon poetry", "a huge wad of bellybutton fluff", "fire and brimstone", "%%%%% spoon", "cotton wool balls", "something pink", "a mouse cord", "a UNIX bible", "a Back Street Boys CD", "mIRC 6.01", "%%%%% brick", "%%%%% christmas tree", "a MagLite™ covered in vaseline", "an army shovel", "%%%%% axe", "Khaled Mardam-Bey", "a random number of Ninja Turtles", "%%%%% object", "%%%%% crowbar", "%%%%% knuckle duster", "%%%%% book", "%%%%% DVD", "%%%%% VHS", "%%%%% flower", "%%%%% tree", "%%%%% shelf", "%%%%% laptop", "%%%%% Macbook", "%%%%% iBook", "%%%%% PowerBook", "%%%%% Macbook Pro", "%%%%% Macbook Air", "%%%%% Mac Mini", "%%%%% Mac Pro", "%%%%% iMac", "%%%%% iPhone", "%%%%% iPod", "%%%%% cup", "%%%%% IRC Client", "%%%%% diamond", "%%%%% lamp", "%%%%% tapestry", "%%%%% stone", "%%%%% rock", "%%%%% sheet of paper", "%%%%% printer", "%%%%% scanner", "%%%%% mobile", "%%%%% figurine", "%%%%% magazine", "%%%%% ball", "%%%%% frog", "%%%%% camel", "%%%%% dragon", "%%%%% walrus", "%%%%% penguin", "%%%%% giraffe", "%%%%% lion", "%%%%% shelf", "%%%%% wardrobe", "%%%%% lamp", "%%%%% stone", "%%%%% easteregg", "%%%%% pot", "%%%%% trophy", "%%%%% goblet", "yellow snow"} | |
set ListCount to the count of theItemlist | |
set pick to random number from 1 to ListCount | |
set theItem to item pick of theItemlist as string | |
set needobject to 0 | |
-- see whether an adjective is necessary | |
set AppleScript's text item delimiters to " " | |
set theItem to searchReplace(theItem, "%%%%%", theAdj) | |
set AppleScript's text item delimiters to "" | |
-- without a/an/the for certain slaps | |
set checklist to {"a", "an", "the"} | |
set AppleScript's text item delimiters to " " | |
set check to first text item of theItem | |
if check is in checklist then | |
set StrippedItem to searchReplace(theItem, check & " ", "") | |
else | |
set StrippedItem to theItem | |
end if | |
set AppleScript's text item delimiters to "" | |
-- random number for spotlight slaps ... | |
set randNum to random number from 10 to 1337 | |
-- set items for spotlight slap | |
set theSpotlist to {"David Hasselhoff", "Bill Gates", "Steve Jobs", "Rick Astley", "Your mom", "Khaled Mardam-Bey", "Nicolas Lapomarda", "The Wizard of Oz", "I.C. Wiener", "Britney Spears", "Celine Dion"} | |
set ListCount to the count of theSpotlist | |
set pick to random number from 1 to ListCount | |
set theSpot to item pick of theSpotlist as string | |
-- animal list | |
set theAnimallist to {"squirrels", "elephants", "lemmings", "tapirs", "locusts", "gold fish", "piranhas", "cuttlefish", "gorillas", "turtles", "gold fish", "kitties", "bunnies", "chipmunks", "duckbills", "kangaroos", "bees", "hedgehogs", "sharks"} | |
set ListCount to the count of theAnimallist | |
set pick to random number from 1 to ListCount | |
set theAnimal to item pick of theAnimallist as string | |
-- random slap list | |
set theSlaplist to {"slaps " & tempnick & " around with " & theItem, "throws " & theItem & " at " & tempnick, "considers highlighting " & tempnick & " with " & theItem, "jabs " & tempnick & " with " & theItem, "nudges " & tempnick & " with " & theItem, "whips " & tempnick & " with " & theItem, "flogs " & tempnick & " with " & theItem, "whacks " & tempnick & " around a bit with " & theItem, "bangs " & tempnick & " with " & theItem, "beats " & tempnick & " with " & theItem, "tortures " & tempnick & " with " & theItem, "uses " & theItem & " to poke " & tempnick, "uses " & theItem & " to highlight " & tempnick, "leads " & tempnick & " into a dark alley - Hey, test my " & StrippedItem & "!", "abuses " & theItem & " to slap " & tempnick, "beautifies " & tempnick & " with some " & StrippedItem & " imprints", "whacks " & tempnick & " a bit with " & theItem, "bangs " & tempnick & " with " & theItem, "spanks " & tempnick & " with " & theItem, "strikes " & tempnick & " with " & theItem, "clouts " & tempnick & " with " & theItem, "cuffs " & tempnick & " with " & theItem, "thwacks " & tempnick & " with " & theItem, "wallops " & tempnick & " with " & theItem, "smites " & tempnick & " with " & theItem, "boxes " & tempnick & " with " & theItem, "swipes " & tempnick & " with " & theItem, "belts " & tempnick & " with " & theItem, "larrups " & tempnick & " with " & theItem, "socks " & tempnick & " with " & theItem, "clobbers " & tempnick & " with " & theItem, "slugs " & tempnick & " with " & theItem, "forgets " & tempnick & " in the desert. awwwww", "pokes " & tempnick, "steals " & tempnick & "'s cookies. mwahaha!", "shreds " & tempnick & " with %%%%% knife", "urges " & tempnick & " to use Windows Millennium Edition", "accidentally floods " & tempnick & "'s room with Hydrofluoric acid", "spills some coffee over " & tempnick & "'s keyboard", "deletes " & tempnick & "'s iTunes DB", "runs 'rm -rf / ' in " & tempnick & "'s Terminal", "drives over " & tempnick, "secretly installs iSpy on " & tempnick & "'s computer", "makes " & tempnick & "'s finder reindex the HDDs attached to the computer", "makes " & tempnick & " watch the IMDb Bottom 100", "inserts Windows 3.11 install floppies into " & tempnick & "'s DVD drive", "enters " & theSpot & " in " & tempnick & "'s Spotlight. Weeee " & randNum & " Hits!", "leads " & tempnick & " into a dark alley - Hey, test my crowbar!", "sends hords of " & theAnimal & " over " & tempnick, "urges " & tempnick & " to eat a cyanide sandwich", "makes " & tempnick & " read the Windows ME user guide", "slaps a large trout a bit with " & tempnick, "rickrolls " & tempnick, "recites Vogon poetry for " & tempnick, "shreds " & tempnick & " with %%%%% chainsaw", "pushes " & tempnick & " into an abyss", "beautifies " & tempnick & " with some knuckle duster imprints", "feeds " & tempnick & " a bowl of yellow snow"} | |
set ListCountSlap to the count of theSlaplist | |
set pick to random number from 1 to ListCountSlap | |
set theSlap to item pick of theSlaplist as string | |
-- see whether an adjective is necessary | |
set theSlap to searchReplace(theSlap, "%%%%%", theAdj) | |
end if | |
end if | |
if mode is not missing value and mode is not "" then | |
if mode is "%rand" then | |
set maxNum to the (count of typelist) - 1 | |
set TempNum to random number from 1 to maxNum | |
set mode to item TempNum of typelist | |
end if | |
if mode is "%rev" then | |
set theSlap to reverse of characters of theSlap as text | |
else if mode is "%flip" then | |
set the source to "abcdefghijklmnopqrstuvwxyz()[]{}!?.," | |
set the destination to "ɐqɔpǝɟƃɥıɾʞlɯuodbɹsʇnʌʍxʎz)(][}{¡¿˙'" | |
set theSlap to reverse of characters of theSlap as text | |
set the theResult to "" | |
repeat with char in theSlap | |
set x to the offset of char in the source | |
if x is not 0 then | |
set the theResult to (the theResult & character x of the destination) as string | |
else | |
set the theResult to (the theResult & char) as string | |
end if | |
end repeat | |
set theSlap to theResult as string | |
else if mode is "%fliprev" then | |
set the source to "abcdefghijklmnopqrstuvwxyz()[]{}!?.," | |
set the destination to "ɐqɔpǝɟƃɥıɾʞlɯuodbɹsʇnʌʍxʎz)(][}{¡¿˙'" | |
set theSlap to reverse of characters of theSlap as text | |
set the theResult to "" | |
repeat with char in theSlap | |
set x to the offset of char in the source | |
if x is not 0 then | |
set the theResult to (the theResult & character x of the destination) as string | |
else | |
set the theResult to (the theResult & char) as string | |
end if | |
end repeat | |
set theSlap to theResult as string | |
set theSlap to reverse of characters of theSlap as string | |
end if | |
end if | |
set AppleScript's text item delimiters to " " | |
set theSlap to searchReplace(theSlap, "######", nick) | |
set AppleScript's text item delimiters to "" | |
-- insert and create echo variable | |
set theString to "/sme " & destinationChannel & " " & theSlap | |
return theString | |
end textualcmd | |
-- search and replace function to do some stuff | |
on searchReplace(origStr, searchStr, replaceStr) | |
set old_delim to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to searchStr | |
set origStr to text items of origStr | |
set AppleScript's text item delimiters to replaceStr | |
set origStr to origStr as string | |
set AppleScript's text item delimiters to old_delim | |
return origStr | |
end searchReplace | |
-- Changelog: | |
-- 1.6.2: | |
-- - fixed a typo | |
-- 1.6.1: | |
-- - fixed some nick replacement problem | |
-- - added some slaps, items, etc. | |
-- 1.6: | |
-- - changed layout to match template | |
-- - added some slaps | |
-- - added some animals | |
-- - added items | |
-- - added adjectives | |
-- 1.5: | |
-- - removed morse stuff, sucked badly anyway (and was slow) | |
-- - added comments | |
-- - fixed some possible errors with typelist | |
-- - fixed some possible errors with flip | |
-- - made typelist available when object is included | |
-- - extended lists | |
-- 1.4.2: | |
-- - fixed some slaps (a/an grammar error) | |
-- - modified morse output | |
-- - modified explanation output | |
-- 1.4.1: | |
-- - added reverse | |
-- 1.4: | |
-- - added flip and morse encoding | |
-- 1.3: | |
-- - added random adjectives for items | |
-- - added various items | |
-- - added slaps | |
-- 1.2: | |
-- - redid the random selection | |
-- - added various items | |
-- - added slaps | |
-- 1.1: | |
-- - added support for multiple slap items in slap using [item], e.g.: | |
-- - /slap Okeanos and incredible slap will result in: /me slaps Okeanos around a bit with a large and incredible slap | |
-- - increased slap list | |
-- - reduced amount of code needed to select a random item | |
-- - added list for slap/throw slap | |
-- - added random number for spotlight slaps | |
-- - added random item for spotlight slaps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment