Skip to content

Instantly share code, notes, and snippets.

@nishith-pubnub
Last active October 20, 2021 02:54
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nishith-pubnub/7fb1c3fa09b808913db973d16b534727 to your computer and use it in GitHub Desktop.
This function code checks the contents of the message against a dictionary of swear words. It allows you to either replace the profanity text with special characters or completely block the message.
/*************************************************************************
*
* Function: PubNub Chat Message Profanity Filter
* Description: Filter out bad words, replacing with special character.
* Author: PubNub Inc.
* Categories: Chat & Social
* More Information:https://www.pubnub.com/docs/blocks-catalog/chat-message-profanity-filter
*
* SETUP:
* Update PubNub Channel to use for broadcasting profanity events (useful for moderation).
* If value is left empty then, no other publish action will occur.
*/
export default (request) => {
var badWords =new RegExp(/\b(@rsehol|@unt|a-ss|a.rse|a.s.s|a55|a55hole|a_s_s|abort|acrotomophilia|aeolus|ahole|aids|airhead|alah|allah|ama10|anal|analprobe|anilingus|anul|anus|apeshit|ar5e|ar5h0le|ar5h0les|areola|areole|arian|arrse|ars3|arse|arseh0le|arseh0les|arseho|arsehol|arsehole|arseholes|arsewipe|arsh0le|arshole|arsholes|aryan|as-s|asdf|ashole|ass|ass hole|ass-fucker|ass.|assbang|assbanged|assbangs|asses|assfuck|assfucker|assfukka|assh0le|assh0les|asshat|assho1e|asshole|assholecleaner|assholes|asskisser|asslick|asslicker|assmaster|assmunch|asswhole|asswipe|asswipes|autizmz|auto erotic|autoerotic|azazel|azz|b!tch|babeland|baby batter|ball gag|ball gravy|ball kicking|ball licking|ball sack|ball sucking|ballbag|balls|ballsack|banchoot|bang|bangbros|banger|bareback|barely legal|barenaked|barf|bast|bastard|bastardo|bastards|basterd|bastinado|basyard|basyards|battyboy|bawdy|bbw|bdsm|beaner|beardedclam|beastial|beastiality|beatch|beater|beaver|beaver cleaver|beaver lips|beeeeutch|beefcurtains|beeyotch|beheading|belend|bellend|bellywhacker|beotch|bern|bernie|bestial|bestiality|biatch|bich|biener|big black|big breasts|big knockers|big tits|bigtits|biitch|bimbo|bimbos|bindippers|birdlock|bitch|bitched|bitcher|bitchers|bitches|bitchin|bitching|bitchy|bitty|biyatch|black animals|black cock|black president|blacks|block me|blonde action|blonde on blonde action|bloody|blow|blow j|blow job|blow-job|blowher|blowhim|blowjob|blowjobs|blowme|blue waffle|blumpkin|bo11ocks|boabiesooking|boabysooking|bod|bodily|boink|boiolas|boll0cks|bollock|bollocks|bollok|bollox|bolocks|bolox|bondage|bone|boned|bonehead|boner|boners|bong|bonk|boob|boobies|boobs|booby|booger|boogers|bookie|booobs|boooobs|booooobs|booooooobs|bootee|bootha|boothas|bootie|booty|booty call|booze|boozer|boozy|bosedeeke|bosom|bosomy|bowel|bowels|bozi|bra|brassiere|breast|breasts|brown showers|browneye|browntown|brunette action|buceta|bucketcunt|bufu|bugger|bugger off|bukkake|bull shit|bulldager|bulldyke|bullet vibe|bullhell|bulls|bullshit|bullshits|bullshitted|bullturds|bum|bumbandit|bumhole|bung|bung hole|bunghole|bunny fucker|bunnyfucker|busty|butch|butt fuck|buttbreath|buttcheeks|buttface|buttfuck|buttfucker|butthair|butthead|butthole|buttholesweat|buttmuch|buttmunch|buttpicker|buttplug|c#nt|c-0-c-k|c-o-c-k|c-u-n-t|c00n|c0ck|c0cksucka|c0cksucker|c_u_n_t|caca|cahnt|cahnts|cahone|callgirl|camel toe|cameltoe|camgirl|camslut|camwhore|canada|canadian|candy-ass|carpet muncher|carpetmuncher|catshit|cawk|cayenne|cayennetech|cervix|channel|chav|cheesyass|chinc|chinchin|chincs|chink|chode|chodes|chowhai|christ|chuffnuts|chutiya|cialis|cipa|circle jerk|circlejerk|cl1t|clam|clench|climax|clit|clitoff|cliton|clitoris|clitorus|clits|clitty|clover clamps|clunge|clusterfuck|cnut|cnuts|cobia|cocain|cocaine|cock|cock sucker|cock-sucker|cockblock|cockblocker|cockface|cockhead|cockholster|cockknocker|cockmunch|cockmuncher|cocks|cocksmoker|cocksuck|cocksucka|cocksucked|cocksucker|cocksuckers|cocksucking|cocksucks|cocksuka|cocksukka|coital|cojones|cok|cokmuncher|coksucka|commie|condom|cooch|coochie|coon|coons|cooter|coprolagnia|coprophilia|copulate|corksucker|cornhole|cornholed|cossorali|cox|crabs|crack|cracker|crackwhore|crap|crappy|creampie|cretin|cripple|critest|crustycrotch|cuck|cucked|cuckhold|cuckold|cucks|cum|cummer|cummin|cumming|cumn|cumquat|cums|cumshot|cumshots|cumslut|cumstain|cun$|cunilingus|cunillingus|cunnilingus|cunny|cunt|cunt's|cunt.|cuntbreath|cuntdog|cuntface|cunthunter|cunting|cuntlick|cuntlicker|cuntlicking|cuntlip|cunton|cunts|cuntsucker|cuunt|cvnt|cvnts|cyalis|cyberfuc|cyberfuck|cyberfucked|cyberfucker|cyberfuckers|cyberfucking|d-ick|d-ong|d0ng|d0uch3|d0uche|d1ck|d1ck!|d1ckh@ed|d1ld0|d1ldo|daggummit|dago|dagos|dammit|damn|damned|damnit|damnmit|darkie|darky|darnit|date rape|daterape|dawgie-style|dbqkd|dck|deeepthroat|deep throat|deepthroat|democratic socialism|dendrophilia|diaphragm|diarrhea|dick|dick-ish|dickbag|dickbrain|dickbreath|dickcheese|dickdipper|dickface|dickflipper|dickhead|dickheads|dickish|dickless|dickripper|dicks|dicksipper|dicksmack|dicksucker|dickweed|dickwhipper|dickwrinkle|dickzipper|diddle|diehd|dike|dildo|dildos|diligaf|dilldoe|dilldos|dillweed|dimwit|dingle|dink|dinks|dipship|dipshit|dipstick|dirsa|dirty pillows|dirty sanchez|dlck|do-ong|dobber|dog style|dog-fucker|doggie style|doggie-style|doggiestyle|doggin|dogging|doggy style|doggy-style|doggystyle|dolcett|domination|dominatrix|dommes|dong|donkey punch|donkeypunch|donkeyribber|doofus|doosh|dopey|dork|double dong|double penetration|douch3|douche|douchebag|douchebags|douchejuice|douchenozzle|douchenugget|douchey|duche|dumass|dumbass|dumbasses|dumbbell|dumbfuck|dumbfucker|dumbo|dummy|dung|dxxkhead|dyke|dykes|eat my ass|ecchi|ecstasy|eff|effin|ejaculate|ejaculated|ejaculates|ejaculating|ejaculatings|ejaculation|ejakulate|enlargement|erect|erection|erotic|erotism|escort|essohbee|ethical slut|ethnics|eunuch|extacy|extasy|f u c k|f u c k|f u c k e r|f up|f###|f##k|f##king|f#cked|f'ck|f-----g|f---ed|f---ing|f--k|f-o-a-d|f-u-<-k|f-u-c-k|f-uck|f00k|f00ked|f0cker|f0oked|f4cker|f4g|f4nny|f<uk|f>>k|f@@@in|f@@@ing|f@ck|f@g|f@gs|f__kin|f__king|f_u_c_k|fack|fackin|facking|fag|fagg|fagg0t|fagged|fagget|fagging|faggit|faggits|faggitt|faggot|faggotass|faggotry|faggs|fagit|fagits|fagot|fagots|fags|faig|faigt|falcid|fanny|fannybandit|fannyflaps|fannyfucker|fanyy|fareskin|fartknocker|fatass|fatso|fbuddy|fck|fck1ng|fckeud|fckin|fcking|fcks|fckw1t|fckwit|fcuk|fcuked|fcuker|fcukin|fcuking|fcuks|feak|fecal|feck|fecker|feckin|fecking|feel the bern|feel the burn|feeling the burn|fekking|felch|felched|felcher|felching|fellate|fellatio|feltch|feltcher|feltching|female squirting|femdom|femsub|fggt|fgt|fick|figging|fingerbang|fingerfuck|fingerfucked|fingerfucker|fingerfuckers|fingerfucking|fingerfucks|fingering|fisted|fistfuck|fistfucked|fistfucker|fistfuckers|fistfucking|fistfuckings|fistfucks|fisting|fisty|fker|fkin|fking|flaccid|flacid|flamer|flammer|flange|fleshflute|floozy|fluck|flucknuts|fo0ked|foad|focker|foff|fondle|foobar|fook|fookd|fooked|fooker|fookin|fookin'|fooking|foot fetish|footjob|foreskin|freak|freex|frig|frigg|frigga|friggin|frigging|frigin|friging|fromhell|frotting|fu|fu&kin|fu&king|fu<k|fu<ked|fu<ker|fu<kin|fu<king|fu<kker|fu<kr|fu<ks|fu@k|fu@ker|fubar|fuck|fuck buttons|fuck shit motherfucker fucker fucking asshole|fuck-tard|fuck-wit|fucka|fuckass|fuckbah|fuckbuddy|fuckbutt|fucked|fucker|fuckers|fuckface|fuckhead|fuckheads|fuckin|fuckin'|fucking|fuckingbitch|fuckinghell|fuckings|fuckingshit|fuckingshitmotherfucker|fuckk|fuckme|fuckn|fucknugget|fucknut|fuckoff|fuckout|fucks|fucktard|fucktards|fucku|fuckup|fuckw1t|fuckwad|fuckwhit|fuckwit|fuckwits|fuckyou|fuct|fucw1t|fucwit|fudge packer|fudge-p@cker|fudge-packer|fudgep@cker|fudgepacker|fudgpacker|fuk|fukced|fuked|fuker|fukin|fuking|fukk|fukked|fukker|fukkin|fukking|fuks|fukwhit|fukwit|furbox|furburger|futanari|fuuck|fuukn|fuuuck|fuuuuck|fuuuuuck|fuuuuuuck|fux|fux0r|fvck|fvck-up|fvcking|fvckup|fvckw1t|fvckwit|fxck|f��ck|f��ck|f��cking|f����k|f��ck|f��ck|g-ay|g-spot|g@y|gae|gai|gang bang|gang-bang|gangbang|gangbanged|gangbangs|ganja|gash|gay sex|gayboy|gayhole|gaylord|gaysex|gazongers|genitals|gey|gfy|ghay|ghb|ghey|giant cock|gigolo|gilf|gimp|ginch|girl on|girl on top|girlie-gardening|girls gone wild|glans|glory hole|gloryhole|gnikcuf|goatcx|goatfucker|goatfuckers|goatse|god|god damn|god-dam|god-damned|godamn|godamnit|goddam|goddammit|goddamn|goddamned|goddamnit|goddamnwhore|gokkun|golden shower|goldenshower|gonad|gonads|goo girl|goodpoop|gook|gooks|goregasm|goris|gotdamn|gotdamnit|gringo|grope|group sex|gspot|gtfo|guido|guro|gutterslutbitchfromhell|gypo|gypos|gyppo|gyppos|h0m0|h0mo|h1tl3r|h1tler|hand job|handjob|hang|harami|hard core|hard on|hardcore|hardcoresex|hardon|he11|hebe|heeb|heil|hell|hemp|hentai|heroin|herp|herpes|herpy|heshe|hoar|hoare|hobag|hoe|hoer|hom0|homey|homoerotic|homoey|honger|honkers|honkey|honky|hooch|hookah|hooker|hoor|hootch|hootchie|hooter|hooters|hore|horniest|horny|hot chick|hotsex|how to kill|how to murder|hrny|huge fat|hump|humped|humping|hussy|hvns|hymen|idiot|iffy|inbred|incest|info wars|infowars|injun|intercourse|ities|j1zz|j3rk0ff|jack off|jack-off|jackass|jackhole|jackingoff|jackoff|jail bait|jailbait|jap|japs|jasal|jerk|jerk off|jerk-off|jerk0ff|jerked|jerkoff|jew|jew!|jewed|jewish|jews|jigaboo|jiggaboo|jiggerboo|jism|jiz|jizm|jizz|jizzed|juggs|junglebunny|junkie|junky|k@ffir|k@ffirs|k@fir|k@firs|kaf1r|kaff1r|kaffir|kaffirs|kafir|kafirs|kafr|kants|kashit|kawk|keaster|khunt|kiddie-fiddler|kiddie-fiddling|kiddiefiddler|kiddiefiddling|kiddy-fiddler|kiddyfiddler|kike|kikes|kill|kinbaku|kinkster|kinky|klan|kn0b|knickers|knobber|knobbing|knobead|knobed|knobend|knobhead|knobjocky|knobjokey|kock|kondum|kondums|kooch|kooches|kootch|koran|kratom|kraut|kuffar|kum|kummer|kumming|kums|kunilingus|kunt|kuran|kyke|l3i+ch|l3itch|labia|lactate|lactoids|leather restraint|leather straight jacket|lech|lemon party|lemonparty|leper|lesbo|lesbos|lesbyterian|lessy|levitra|lez|lezbian|lezbians|lezbo|lezbos|lezzie|lezzies|lezzo|lezzy|licker|lickmycunt|lies|lmao|lmfao|loin|loins|lolita|lousy hosts of|lovemaking|lube|lucifer|lust|lusting|lusty|lyin|lying ted|m-fucking|minge|motherf.ucker|m0f0|m0fo|m0nkey|m1nge|m45terbate|ma5terb8|ma5terbate|maderchood|make me come|male squirting|maledom|malesub|mams|man-root|marijuana|masochist|massa|master-bate|masterb8|masterbat|masterbat3|masterbate|masterbating|masterbation|masterbations|masturbate|masturbating|masturbation|meldom|menage a trois|menses|menstruate|menstruation|merde|meth|mexico|mick|mierda|milf|minge|missionary position|mo-fo|mof0|mofo|mofuccer|mofucker|mofuckers|mofucking|mofukcer|mohterfuccer|mohterfuccers|mohterfuck|mohterfucker|mohterfuckers|mohterfucking|mohterfucks|mohterfuk|mohterfukcer|mohterfukcers|mohterfuking|mohterfuks|molca|molest|molestation|monkey|monkey boi|monkey boy|moolie|moron|moterfuccer|moterfuck|moterfucker|moterfuckers|moterfucking|moterfucks|motha-fucka|mothafuccer|mothafuck|mothafucka|mothafuckas|mothafuckaz|mothafucked|mothafucker|mothafuckers|mothafuckin|mothafucking|mothafuckings|mothafucks|mother fucker|motherf---ers|motherfuccer|motherfuccers|motherfuck|motherfucka|motherfucked|motherfucker|motherfuckers|motherfuckin|motherfucking|motherfuckings|motherfuckka|motherfucks|motherfukkker|mound|mound of venus|mr hands|mthafucca|mthafuccas|mthafucka|mthafuckas|mthafukca|mthafukcas|mtherfucker|mthrfucker|mthrfucking|muff|muff diver|muff-diver|muff-diving|muffdiver|muffdiving|muffs|muth@fucker|mutha|muthafecker|muthafuccer|muthafuck|muthafuck@|muthafucka|muthafuckaz|muthafucker|muthafuckers|muthafucking|muthafuckker|muthafucks|muthafukas|muther|mutherfucker|mutherfucking|muthrfucking|n i g g e r|n1gga|n1gger|nad|nads|naked|nambla|napalm|nappy|nawashi|negro|nestlecock|ni66ers|nig|nig nog|nig-nog|niga|nigg|nigg3r|nigg4h|nigga|niggah|niggas|niggaz|nigger|niggerlover|niggers|niggershit|niggle|niggs|niglet|nignog|nigs|nigz|nimphomania|nimrod|ninny|nipple|nipples|nob|nob jokey|nobhead|nobjocky|nobjokey|nonce|nooky|nude|nudity|numbnuts|nuse|nuthuggers|nutsack|nympho|nymphomania|o m f g|o m f g !|o m f g!|o m g|octopussy|omfg|omg|omorashi|on9|onanism|one cup two girls|one guy one jar|one night stand|oneeyedbastard|onenightstand|opiate|opium|orgasmic|orgasms|orgies|orgy|ovary|ovum|ovums|piss-flaps|p00f|p00fs|p00fter|p00fters|p0of|p0rn|p@ki|p@kis|paddy|paedo|paedophile|paedophiles|pantie|panties|panty|pastie|pasty|pcp|peado|peadofile|peadofiles|pecker|peckerhead|pedo|pedobear|pedofile|pedophile|pedophilia|pedophiliac|pee|peedo|peedofile|peedofiles|peedophile|peedophiles|peedos|peepee|pegging|pench0d|pench0ds|penchod|penchods|penetrate|penetration|penial|penile|penisbreath|penisfucker|penishead|peniswrinkle|perversion|pervert|peyote|phalli|phallic|phanny|phanny.|pheck|phecking|phelching|pheque|phequing|phone sex|phonesex|phuck|phucker|phuckin|phucking|phucks|phuk|phuked|phuking|phukked|phukking|phuks|phuq|piece of shit|pigfucker|pighead|pikey|pillow-biter|pillowbiter|pimp|pimpis|pinko|piss|piss pig|piss-off|pissant|pissed|pissedoff|pisser|pissers|pisses|pissflaps|pissin|pissing|pissoff|pisspig|plastered|playboy|pleasure chest|pms|po0f|poff|polack|pole smoker|pollock|ponce|ponyplay|poo|poof|poofs|poofter|poon|poonani|poontang|poop chute|poopchute|poopoo|poostabber|poostabbers|pot|potty|pr!ck|pr!ck.|pr1ck|pr1ck!|pr1cks|pr1cks!|prejudice|prig|prik|prince albert piercing|pron|prophit|prude|psytea|pthc|pube|pubes|pubic|pubic hair|pubis|punany|punkass|punky|puntang|puss|pusse|pussi|pussies|pussy|pussydick|pussylicker|pussylip|pussylips|pussypounder|pussys|pussywhip|pusy|puta|puto|puzzy|qhwl|queaf|queef|queero|queers|quefe|queve|quicky|quief|quim|quimsteak|qur'an|quran|qveer|r-tard|r@pe|racy|raghead|ragheads|raging boner|rally stream|rally streamming|raunch|reacharound|rectal|rectum|rectus|redtube|reefer|reetard|reich|ret@rd|retard|retarded|reverse cowgirl|revue|ricer|right side broadcast|rimadonna|rimjaw|rimjob|rimming|ritard|rootle|rosy palm|rosy palm and her 5 sisters|rsbn|rtard|rum|rump|rumprammer|rumpranger|ruski|rusty trombone|s&m|s-h-1-t|s-h-i-t|s-o-b|s0b|s1ut|s2x|s_h_i_t|sappho|scag|scantily|scat|schizo|schlong|schmeka|screwed|screwing|scroat|scrog|scrot|scrote|scrotum|scrud|scum|scum!|scumbag|scumber|seduce|sexo|sexpot|sexual|sh!+|sh!t|sh!te|sh!tes|sh1t|sh1te|shag|shagbucket|shagger|shaggin|shagging|shagstress|shamedame|shaved beaver|shaved pussy|sheister|shemale|shhit|shi+|shibari|shirtlifter|shirtlifters|shit|shitass|shitblimp|shitdick|shite|shiteater|shited|shitey|shitface|shitforbrains|shitfuck|shitfull|shithead|shithloe|shithole|shithouse|shiting|shitings|shits|shitstabber|shitstabbers|shitt|shitted|shitter|shitters|shitting|shittings|shitty|shiz|shlong|shmegma|shootingawad|shota|shrimping|shutup|side broadcasting|sissy|skag|skank|skaw|skeet|slackass|slanteye|sleaze|sleazy|sleeze|slut|slutdumper|slutkiss|sluts|slutty|sluttybitch|smagna|small hands|smeg|smegma|smut|smutty|snarf|snatch|sniper|snowballing|snuff|sob|sodoff|sodom|sodomite|sodomize|sodomy|son-of-a-bitch|sonofabitch|sonofawhore|souse|soused|spac|spanking|spastic|spaz|spaz.|sperm|spic|spick|spik|spiks|spit-roast|spit-roasting|spitroast|spitroasting|splooge|splooge moose|spooge|spread legs|spunk|spunking|squaw|steamy|stfu|stiffy|stoned|strap on|strapon|strappado|strip club|stroke|strollop|strumpet|style doggy|sucker|suckes|sucking|suckmydick|suckster|suicide girls|sultry women|sumofabiatch|surah|swastika|swinger|twat.|t0sser|t0ssers|t1t|t1tt1e5|t1tties|taint|tainted love|tard|taste my|tawdry|teabagged|teabagger|teabagging|teat|teets|terd|thug|tickedoff|tight white|tinkle|tit|titfuck|titi|tits|titt|tittie5|tittiefucker|titties|titty|tittyfuck|tittyfucker|tittysucker|tittywank|titwank|tity|tnuc|to55er|to55ers|toejam|toggaf|toke|tongue in a|toots|tosser|tossers|tossurs|towelhead|tprtm|trallop|tramp|tranny|trashy|tribadism|tribadist|trollop|trump train|tub girl|tubgirl|turd|tush|tushy|tvvat|tvvats|tw4t|tw@|tw@t|tw@ts|tw_t|twank|twat|twathead|twats|twatt|twattish|twatty|two girls one cup|twunt|twunter|twunts|tyt|undies|undressing|unsuitable|unwed|upskirt|upthebutt|upthegary|urethra play|urophilia|uterus|uzi|v14gra|v1gra|vag|vagina|valium|venus mound|verticaltaco|violet blue|violet wand|vixen|vorarephilia|voyeur|vp-rx|vprx|vulgar|vulva|w#nker|w#nkers|w00se|w0g|w0gs|w4nker!|w4nkers!|w@nk|w@nker|w@nkers|w@nks|wad|wang|wank|wank's|wanka|wanke$|wanked|wanker|wankers|wanking|wanks|wanky|warez|wazoo|weatback|wedgie|weenie|weewee|weiner|weirdo|wench|wet dream|wetback|wetspam|wh0re|wh0reface|whanker|whankers|white power|whitey|whiz|whoar|whoralicious|whorealicious|whored|whoredog|whoreface|whorehopper|whorehouse|whores|whoring|wigger|willies|willy|wiseass|wizzer|wktkf|wkwl|wog|womb|women rapping|woody|wop|wrapping men|wrinkled starfish|wwwhack|xrse|xrseh|xrsehol|xrsehole|xxxhole|y!ddo!|y!ddo!!|yadong|yaoi|yarichin|yariman|yeasty|yellow showers|yellowratbastard|yid|yido|yiffy|yobbo|zachariahbishop|zasal|zoophile|zoophilia)\b/,"igm");
//Option 1 - Replace profanity text with * and allow the publish
if(request.message && request.message.text && badWords.test(request.message.text)){
var newString = request.message.text;
newString = newString.replace(badWords, "***");
request.message.text = newString;
return request.ok(); // Return a promise when you're done
}
//Option 2 - Block message and return a publish error if the text includes profanity
/*if(badWords.test(request["message"]["text"])) {
console.log('moderated message: ' + request["message"]["text"]);
return request.abort("moderated message");
}*/
return request.ok(); // Return a promise when you're done
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment