Merge pull request #134 from velour/emojifyreact

emojify: change THE ALGORITHM
This commit is contained in:
Chris Sexton 2019-01-21 18:08:33 -05:00 committed by GitHub
commit 0e5a275d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 717 deletions

View File

@ -48,10 +48,6 @@ func New(bot bot.Bot) *EmojifyMePlugin {
}
}
for _, e := range customEmojys {
emojiMap[e] = e
}
return &EmojifyMePlugin{
Bot: bot,
GotBotEmoji: false,
@ -70,36 +66,28 @@ func (p *EmojifyMePlugin) Message(message msg.Message) bool {
inertTokens := p.Bot.Config().GetArray("Emojify.Scoreless")
emojied := 0.0
tokens := strings.Fields(strings.ToLower(message.Body))
emojys := map[string]bool{}
for _, token := range tokens {
if _, ok := p.Emoji[token]; ok {
if !stringsContain(inertTokens, token) {
emojys := []string{}
msg := strings.Replace(strings.ToLower(message.Body), "_", " ", -1)
for k, v := range p.Emoji {
k = strings.Replace(k, "_", " ", -1)
candidates := []string{
k + "es",
k + "s",
}
for _, c := range candidates {
if strings.Contains(msg, " "+c+" ") ||
strings.HasPrefix(msg, c) ||
strings.HasSuffix(msg, c) {
emojys = append(emojys, v)
if !stringsContain(inertTokens, k) || len(k) <= 2 {
emojied++
}
emojys[token] = true
} else if strings.HasSuffix(token, "s") {
//Check to see if we can strip the trailing "s" off and get an emoji
temp := strings.TrimSuffix(token, "s")
if _, ok := p.Emoji[temp]; ok {
if !stringsContain(inertTokens, temp) {
emojied++
}
emojys[token] = true
} else if strings.HasSuffix(token, "es") {
//Check to see if we can strip the trailing "es" off and get an emoji
temp := strings.TrimSuffix(token, "es")
if _, ok := p.Emoji[temp]; ok {
if !stringsContain(inertTokens, temp) {
emojied++
}
emojys[token] = true
}
}
}
}
if emojied > 0 && rand.Float64() <= p.Bot.Config().GetFloat64("Emojify.Chance")*emojied {
for e, _ := range emojys {
for _, e := range emojys {
p.Bot.React(message.Channel, e, message)
}
return true

View File

@ -1,689 +0,0 @@
package emojifyme
var customEmojys = []string{
"-1000",
"15",
"1up",
"3rd_turn",
"40oz",
"4loko",
"603_brewery",
"a_bad_guy_from_die_hard",
"aeropress",
"agentsmith",
"agreed",
"aim",
"airship",
"alcoholic",
"aloha_shirt",
"amazon",
"angry_poop",
"animal",
"anti-ninja",
"aol",
"aplus",
"appleinc",
"apu",
"asterisk",
"atredies",
"authorized",
"aw_yea",
"axe",
"badge",
"badpundog",
"balls",
"banjo",
"barneygumble",
"basshot",
"beaker",
"beard",
"beefsquatch",
"bender",
"beryl",
"best_korea",
"better_gopher",
"bezos",
"bible",
"bilbo",
"binary_tree",
"bitcoin",
"black_belt",
"black_eye",
"black_mage",
"black_square",
"blackboard",
"blinded",
"blinky",
"blood",
"blue_baby",
"blue_balls",
"bluesteel",
"bmo",
"bob",
"bobby",
"bondage",
"boo",
"boo_this_man",
"bourbon",
"bowtie",
"bra",
"brain-problems",
"brannigan",
"breakfast",
"brian",
"brick",
"brimstone",
"bro",
"broken",
"bronze-trophy",
"broom",
"btc",
"bucket",
"bud_light",
"budweiser",
"bullet",
"bullseye",
"bullshit",
"burgerboy",
"burglar",
"butt",
"butter",
"caffeine",
"cage",
"calavera",
"camper",
"carbsquatch",
"carmen_sandiego",
"cave-troll",
"caveman",
"ceiling_anti-ninja",
"ceiling_ninja",
"chad",
"charpov",
"chase_the_dragon",
"che",
"cheers",
"cheese",
"chemex",
"chicago-hot-dog",
"chilidog",
"chocobo",
"chrome",
"chronofroyo",
"chub",
"cigar",
"clamps",
"clown",
"code",
"codiscope",
"coffee-sprite",
"coke",
"colt45",
"comma_splice",
"command",
"confederate",
"conquest",
"contra",
"cookies",
"corona",
"cortana",
"couch",
"count",
"courage",
"cowboy",
"crazy_lizard",
"crisco",
"crock_pot",
"croooow",
"cubimal_chick",
"cwilt",
"cylon",
"d20",
"dagaz",
"daggett",
"dancing_penguin",
"dangerous",
"dark_one",
"darkwing",
"death",
"debrief",
"deep",
"deodorant",
"devil",
"dickbutt",
"dickdance",
"dingle",
"dino",
"disappointed_ruml",
"do_not_go_in_there",
"doc",
"doge",
"doh",
"doit",
"donnie",
"doritos",
"double_asterisk",
"doubt",
"downvote",
"dr-nick",
"dr_claw",
"dr_spaceman",
"dr_stephen_hawkings",
"dragonball",
"dramatic-chipmunk",
"drooling",
"drumpf",
"duff",
"duffman",
"dusty_stick",
"dw",
"dwarf",
"eaburned",
"eaburns",
"eaburns-fail",
"edge",
"egg-0",
"eggman",
"ehwaz",
"einstein",
"eleven",
"empire",
"everything",
"f",
"fail",
"fake",
"fallout_boy",
"false",
"famine",
"famous-heath-ledger-as-the-joker-clapping-for-james-gordon-in-the-dark-knight",
"fart",
"fearless_leader",
"feelsgood",
"fifteen",
"fighter",
"finn",
"finnadie",
"firefox",
"fivefivefive",
"flag-ussr",
"flailing",
"flanders",
"flyngpngn",
"fminus",
"fool",
"forever",
"freud",
"fry",
"fu",
"fuckoff",
"fuckyeah",
"gandalf",
"garbage",
"gates",
"gay",
"gene",
"get_some",
"ghostbusters",
"giggity",
"gimp",
"gin",
"git",
"glitch_crab",
"gloriousleader",
"glucose",
"gnu",
"go",
"go-go-gadget",
"goatse",
"goberserk",
"god",
"godmode",
"gold-trophy",
"gollum",
"goof",
"google",
"gopher",
"gpu",
"grinch",
"growler",
"gryffindor",
"guiness",
"guinness",
"gumby",
"h",
"hackar",
"hagalaz",
"haha",
"hahaha",
"half_done",
"ham",
"hank",
"harambe",
"hardy",
"hatcher",
"hate",
"hawaiian_shirt",
"hawkings",
"headless_horseman",
"heady_topper",
"heavy_equals_sign",
"heavybreathing",
"heck_yea",
"heineken",
"helldivers",
"herdez",
"hes_on_fire",
"highdea",
"historic_artifact",
"holte",
"homer",
"hooker",
"hop",
"how_to_jump",
"hufflepuff",
"huge_metal_fan",
"hulk",
"hurtrealbad",
"hydrant",
"hypnotoad",
"i93",
"i_do_cocaine",
"ice_cube",
"inspector_gadget",
"internet_explorer",
"ipa",
"isaac",
"isaac_pride",
"it_lives",
"ius",
"jail",
"java",
"jedi",
"jeff",
"jenkins",
"jera",
"jesus",
"jinkies",
"jira",
"joint",
"juicy",
"keeper",
"keg",
"kermit",
"kevin_bacon",
"kfc",
"king_cobra",
"klingon",
"kneeling_man",
"kneeling_woman",
"knight",
"kodos",
"korf",
"krampus",
"krang",
"la_croix",
"lambdahead",
"lastdab",
"latte",
"laugh_devil",
"laugh_dr_evil",
"laugh_dumb",
"laugh_dwight",
"laugh_jack",
"laugh_milk",
"left_blinker",
"leo_",
"liar",
"lick",
"listentome",
"literally_hitler",
"literally_stk5",
"literally_trump",
"little_caesars",
"little_horn",
"lobster",
"lobster_roll",
"lobster_tail",
"logs",
"lol",
"lsd",
"luchador",
"luigi",
"magic",
"magicleap",
"maid_crossbones",
"malte",
"malört",
"margarita",
"mario",
"mario_banana",
"marvin",
"math_checks_out",
"maybe",
"mcduck",
"mcduck_diving",
"meat",
"meatwad",
"meeseeks",
"megaman",
"merchant",
"metal",
"metroid",
"mickeys",
"mikey",
"milf",
"milk",
"minion",
"mint_julep",
"missle",
"mj",
"mojito",
"monocle",
"monster",
"monstro",
"mooning",
"moonshot",
"moonwalk",
"moose",
"morty",
"moxie",
"mozilla",
"mr_yuk",
"msherms",
"msherms_bait",
"mudkip",
"muffin",
"mystery_machine",
"nachos",
"nailed_it",
"neckbeard",
"nelson",
"nice",
"nils",
"ninja",
"nintendo-64-controller",
"nipple",
"no",
"no_wheelchair",
"noose",
"nope",
"norbert",
"norris",
"not-a-pipe",
"not_a_doctor",
"nra",
"nuclear_explosion",
"nurse",
"nyancat",
"octocat",
"og_tap",
"oh_yea",
"ohyea",
"olde_english",
"olde_fortran",
"oliver",
"open_trump_hands",
"opera",
"ouji",
"ouroboros",
"pacman",
"papajohns",
"paranoid",
"paranoid_android",
"party",
"partyparrot",
"patrik",
"pay_respects",
"pbr",
"pcmasterrace",
"pea",
"pea-lang",
"pee",
"peggy",
"pennies",
"penny",
"pentagram",
"pepe",
"pestilence",
"phd",
"php",
"pi",
"picard",
"pickle",
"pickle_rick",
"picklerick",
"piggy",
"pigpen",
"pikachu",
"pinky",
"pipe",
"pirate",
"pirate_flag",
"pjw",
"plan9",
"plane",
"platinum-trophy",
"poe",
"poison",
"pokeball",
"poochie",
"pretzels",
"pride",
"probably_racist",
"professor_farnsworth",
"programming",
"psn",
"puke",
"pun",
"q",
"quagmire",
"r",
"rage1",
"rage2",
"rage3",
"rage4",
"ralph",
"raph",
"ravenclaw",
"razor",
"real_sandwich",
"real_scream",
"real_smoking",
"realistic_gun",
"reaper",
"rebellion",
"recursion",
"red_bull",
"red_mage",
"red_room",
"revelations",
"revolution",
"rich_bitch",
"rick",
"right_blinker",
"rimshot",
"rip",
"rms",
"ron_swanson",
"roomba",
"rube",
"ruml",
"rupee",
"rut-roh",
"s2000",
"s2k",
"saccharomyces",
"sad-laugh",
"safari",
"sailor",
"salt",
"samurai",
"sarcasm",
"sarcastic_clap",
"satan",
"satanic_bible",
"sausage",
"science",
"scoobysnack",
"scotch",
"scrooge",
"seabass",
"seabass-shamed",
"seabass-victory",
"seabass-woke",
"seabass_glass",
"seabass_test",
"seabass_travel",
"semicolon",
"serious",
"seymour",
"shame",
"shipit",
"shocked",
"shocker",
"shovel",
"silver-trophy",
"simple_smile",
"single",
"siren",
"siri",
"skiesel",
"skinner",
"skunked",
"slack",
"slack_call",
"slash",
"slime",
"slurmsmckenzie",
"slytherin",
"smiling_sausage",
"smith",
"smoker",
"smooth",
"snicklefritz",
"snoop-dogg",
"soap",
"sobchak",
"soda-can",
"soiled",
"sombrero",
"sonic",
"sort_of_check",
"sort_of_done",
"spam",
"sperm",
"spic",
"spice-weasel",
"splinter",
"spring",
"squirrel",
"sriracha",
"staple",
"star_trek",
"stardew_chicken_white",
"stat_and_wal",
"stein",
"stephen_hawkings",
"stk5",
"stk5-fail",
"stk5_face",
"stk5onagoodday",
"submarine",
"subway",
"subway_jared",
"sunglasses_cat",
"suspect",
"svohr",
"swipe",
"switch",
"swoon",
"tableflip",
"taco_bell",
"take_my_money",
"tap",
"taz",
"teapot",
"tear_jar",
"tecumseh",
"template",
"tfogal",
"thats_the_joke",
"the-duke",
"the_brain",
"the_day_is_mine",
"the_donut",
"the_dude",
"the_fool",
"the_hush",
"the_lost",
"the_rock",
"thief",
"thisisfine",
"thumbsup2",
"thumbsup_all",
"tina",
"tire",
"to-the-diner",
"toilet_that_opens_right_for_flyngpngn",
"tom_nook",
"tom_servo",
"top_",
"towel",
"triforce",
"trogdor",
"troll",
"trollface",
"true",
"tumbleweed",
"tux",
"twin_peaks",
"twitch",
"un",
"unauthorized",
"unh",
"unholy-antichrist",
"uofl",
"urinal",
"vacuum",
"vader",
"vault_boy",
"vcard",
"vim",
"voltron",
"vomit",
"waiting",
"wal_and_stat",
"waldo",
"wally",
"war",
"weed",
"wfh_beer",
"whiskey",
"white_mage",
"white_square",
"wholefoods",
"wiggum",
"winamp",
"windows",
"wirecutter",
"wiz",
"woody",
"wow",
"wow_owen",
"wrong",
"x2",
"xzibit",
"yak",
"yea_well_you_know_thats_just_like_your_opinion_man",
"yeah_man",
"yeast",
"yes",
"yeti",
"yguengling",
"yo-yo",
"you_know_not_the_elaborate_criteria_by_which_you_are_to_be_judged",
"yuengling",
"zelda_candle",
"zelda_fire",
"zoidberg",
}