Skip to content

Commit

Permalink
[Fun] 1.4.0 Fix a bug with react and multiple numbers
Browse files Browse the repository at this point in the history
- Migrate emojis to unicode strings instead of raw emojis.
- Improvements to `[p]oof` and `[p]react`
 - Allow `[p]oof` and `[p]react` to use message replies for the message to add reactions to if provided message is None.
 - Delete invocation message before adding reactions.
 - Better support for reacting with custom emojis and try to detect actual emojis that don't need to be replaced.
  - This may sometimes still fail due to current limitations.
 - Add logging for when errors occur and exit early if an error occurs.
 - Detect if the bot has already added that emoji and ignore trying to add it.
 - Rearrange `[p]react` so the message now comes last so you can include spaces which will get stripped.
  • Loading branch information
TrustyJAID committed Apr 22, 2024
1 parent 9aa45fc commit 61ad559
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 149 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TrustyJAID's Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-Disc
| EventPoster | 2.1.3 | <details><summary>Admin approved announcments/events</summary>Allow users to setup and host events to be approved by admins.</details> | TrustyJAID |
| ExtendedModLog | 2.12.4 | <details><summary>ExtendedModLog, track changes made in the server.</summary>Log changes within the server using extended modlogs, an extension of RedBot cores modlog.</details> | RePulsR and TrustyJAID |
| Fenrir | 1.2.0 | <details><summary>Give users the option to kick, ban, or insult themselves via reactions.</summary>Create reaction messages to kick or ban users! https://tenor.com/view/order66-gif-9116581</details> | TrustyJAID |
| Fun | 1.3.0 | <details><summary>Various fun commands like react, textflip, and regional</summary>All sorts of commands that users may find fun or useful</details> | Appu and TrustyJAID |
| Fun | 1.4.0 | <details><summary>Various fun commands like react, textflip, and regional</summary>All sorts of commands that users may find fun or useful</details> | Appu and TrustyJAID |
| Hockey | 4.2.2 | <details><summary>Hockey commands</summary>A cog to gather hockey scores, schedules, player data and more!</details> | TrustyJAID |
| Hue | 1.3.0 | <details><summary>Control your philips hue lights with redbot!</summary>Lets you control your philips hue lights with redbot.</details> | TrustyJAID |
| Imagemaker | 1.6.0 | <details><summary>Create your own feels!</summary>Show how you really feel. Make someone beautiful. Make something illegal.</details> | TrustyJAID, Ivan Seidel (isnowillegal.com), Bruno Lemos (isnowillegal.com), and João Pedro (isnowillegal.com) |
Expand Down
324 changes: 217 additions & 107 deletions fun/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re

regionals = {
"a": "\N{REGIONAL INDICATOR SYMBOL LETTER A}",
"b": "\N{REGIONAL INDICATOR SYMBOL LETTER B}",
Expand Down Expand Up @@ -27,82 +25,194 @@
"x": "\N{REGIONAL INDICATOR SYMBOL LETTER X}",
"y": "\N{REGIONAL INDICATOR SYMBOL LETTER Y}",
"z": "\N{REGIONAL INDICATOR SYMBOL LETTER Z}",
"0": "0⃣",
"1": "1⃣",
"2": "2⃣",
"3": "3⃣",
"4": "4⃣",
"5": "5⃣",
"6": "6⃣",
"7": "7⃣",
"8": "8⃣",
"9": "9⃣",
"!": "\u2757",
"?": "\u2753",
"0": "\N{DIGIT ZERO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"1": "\N{DIGIT ONE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"2": "\N{DIGIT TWO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"3": "\N{DIGIT THREE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"4": "\N{DIGIT FOUR}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"5": "\N{DIGIT FIVE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"6": "\N{DIGIT SIX}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"7": "\N{DIGIT SEVEN}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"8": "\N{DIGIT EIGHT}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"9": "\N{DIGIT NINE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"!": "\N{HEAVY EXCLAMATION MARK SYMBOL}\N{VARIATION SELECTOR-16}",
"?": "\N{BLACK QUESTION MARK ORNAMENT}\N{VARIATION SELECTOR-16}",
}
emoji_reg = re.compile(r"<:.+?:([0-9]{15,21})>")
ball = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Reply hazy try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful",
]

emoji_dict = {
# these arrays are in order of "most desirable". Put emojis that most convincingly correspond to their letter near the front of each array.
"a": ["🇦", "🅰", "🍙", "🔼", "4⃣"],
"b": ["🇧", "🅱", "8⃣"],
"c": ["🇨", "©", "🗜"],
"d": ["🇩", "↩"],
"e": ["🇪", "3⃣", "📧", "💶"],
"f": ["🇫", "🎏"],
"g": ["🇬", "🗜", "6⃣", "9⃣", "⛽"],
"h": ["🇭", "♓"],
"i": ["🇮", "ℹ", "🚹", "1⃣"],
"j": ["🇯", "🗾"],
"k": ["🇰", "🎋"],
"l": ["🇱", "1⃣", "🇮", "👢", "💷"],
"m": ["🇲", "Ⓜ", "📉"],
"n": ["🇳", "♑", "🎵"],
"o": ["🇴", "🅾", "0⃣", "⭕", "🔘", "⏺", "⚪", "⚫", "🔵", "🔴", "💫"],
"p": ["🇵", "🅿"],
"q": ["🇶", "♌"],
"r": ["🇷", "®"],
"s": ["🇸", "💲", "5⃣", "⚡", "💰", "💵"],
"t": ["🇹", "✝", "➕", "🎚", "🌴", "7⃣"],
"u": ["🇺", "⛎", "🐉"],
"v": ["🇻", "♈", "☑"],
"w": ["🇼", "〰", "📈"],
"x": ["🇽", "❎", "✖", "❌", "⚒"],
"y": ["🇾", "✌", "💴"],
"z": ["🇿", "2⃣"],
"0": ["0⃣", "🅾", "0⃣", "⭕", "🔘", "⏺", "⚪", "⚫", "🔵", "🔴", "💫"],
"1": ["1⃣", "🇮"],
"2": ["2⃣", "🇿"],
"3": ["3⃣"],
"4": ["4⃣"],
"5": ["5⃣", "🇸", "💲", "⚡"],
"6": ["6⃣"],
"7": ["7⃣"],
"8": ["8⃣", "🎱", "🇧", "🅱"],
"9": ["9⃣"],
"?": ["❓"],
"!": ["❗", "❕", "⚠", "❣"],
"a": [
"\N{REGIONAL INDICATOR SYMBOL LETTER A}",
"\N{NEGATIVE SQUARED LATIN CAPITAL LETTER A}\N{VARIATION SELECTOR-16}",
"\N{RICE BALL}",
"\N{UP-POINTING SMALL RED TRIANGLE}",
"\N{DIGIT FOUR}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
],
"b": [
"\N{REGIONAL INDICATOR SYMBOL LETTER B}",
"\N{NEGATIVE SQUARED LATIN CAPITAL LETTER B}\N{VARIATION SELECTOR-16}",
"\N{DIGIT EIGHT}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
],
"c": [
"\N{REGIONAL INDICATOR SYMBOL LETTER C}",
"\N{COPYRIGHT SIGN}\N{VARIATION SELECTOR-16}",
"\N{COMPRESSION}\N{VARIATION SELECTOR-16}",
],
"d": [
"\N{REGIONAL INDICATOR SYMBOL LETTER D}",
"\N{LEFTWARDS ARROW WITH HOOK}\N{VARIATION SELECTOR-16}",
],
"e": [
"\N{REGIONAL INDICATOR SYMBOL LETTER E}",
"\N{DIGIT THREE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{E-MAIL SYMBOL}",
"\N{BANKNOTE WITH EURO SIGN}",
],
"f": ["\N{REGIONAL INDICATOR SYMBOL LETTER F}", "\N{CARP STREAMER}"],
"g": [
"\N{REGIONAL INDICATOR SYMBOL LETTER G}",
"\N{COMPRESSION}\N{VARIATION SELECTOR-16}",
"\N{DIGIT SIX}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{DIGIT NINE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{FUEL PUMP}\N{VARIATION SELECTOR-16}",
],
"h": ["\N{REGIONAL INDICATOR SYMBOL LETTER H}", "\N{PISCES}\N{VARIATION SELECTOR-16}"],
"i": [
"\N{REGIONAL INDICATOR SYMBOL LETTER I}",
"\N{INFORMATION SOURCE}\N{VARIATION SELECTOR-16}",
"\N{MENS SYMBOL}\N{VARIATION SELECTOR-16}",
"\N{DIGIT ONE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
],
"j": ["\N{REGIONAL INDICATOR SYMBOL LETTER J}", "\N{SILHOUETTE OF JAPAN}"],
"k": ["\N{REGIONAL INDICATOR SYMBOL LETTER K}", "\N{TANABATA TREE}"],
"l": [
"\N{REGIONAL INDICATOR SYMBOL LETTER L}",
"\N{DIGIT ONE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{REGIONAL INDICATOR SYMBOL LETTER I}",
"\N{WOMANS BOOTS}",
"\N{BANKNOTE WITH POUND SIGN}",
],
"m": [
"\N{REGIONAL INDICATOR SYMBOL LETTER M}",
"\N{CIRCLED LATIN CAPITAL LETTER M}\N{VARIATION SELECTOR-16}",
"\N{CHART WITH DOWNWARDS TREND}",
],
"n": [
"\N{REGIONAL INDICATOR SYMBOL LETTER N}",
"\N{CAPRICORN}\N{VARIATION SELECTOR-16}",
"\N{MUSICAL NOTE}",
],
"o": [
"\N{REGIONAL INDICATOR SYMBOL LETTER O}",
"\N{NEGATIVE SQUARED LATIN CAPITAL LETTER O}\N{VARIATION SELECTOR-16}",
"\N{DIGIT ZERO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{HEAVY LARGE CIRCLE}\N{VARIATION SELECTOR-16}",
"\N{RADIO BUTTON}",
"\N{BLACK CIRCLE FOR RECORD}\N{VARIATION SELECTOR-16}",
"\N{MEDIUM WHITE CIRCLE}\N{VARIATION SELECTOR-16}",
"\N{MEDIUM BLACK CIRCLE}\N{VARIATION SELECTOR-16}",
"\N{LARGE BLUE CIRCLE}",
"\N{LARGE RED CIRCLE}",
"\N{DIZZY SYMBOL}",
],
"p": [
"\N{REGIONAL INDICATOR SYMBOL LETTER P}",
"\N{NEGATIVE SQUARED LATIN CAPITAL LETTER P}\N{VARIATION SELECTOR-16}",
],
"q": ["\N{REGIONAL INDICATOR SYMBOL LETTER Q}", "\N{LEO}\N{VARIATION SELECTOR-16}"],
"r": [
"\N{REGIONAL INDICATOR SYMBOL LETTER R}",
"\N{REGISTERED SIGN}\N{VARIATION SELECTOR-16}",
],
"s": [
"\N{REGIONAL INDICATOR SYMBOL LETTER S}",
"\N{HEAVY DOLLAR SIGN}",
"\N{DIGIT FIVE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{HIGH VOLTAGE SIGN}\N{VARIATION SELECTOR-16}",
"\N{MONEY BAG}\N{VARIATION SELECTOR-16}",
"\N{BANKNOTE WITH DOLLAR SIGN}",
],
"t": [
"\N{REGIONAL INDICATOR SYMBOL LETTER T}",
"\N{LATIN CROSS}\N{VARIATION SELECTOR-16}",
"\N{HEAVY PLUS SIGN}",
"\N{LEVEL SLIDER}\N{VARIATION SELECTOR-16}",
"\N{PALM TREE}",
"\N{DIGIT SEVEN}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
],
"u": ["\N{REGIONAL INDICATOR SYMBOL LETTER U}", "\N{OPHIUCHUS}", "\N{DRAGON}"],
"v": [
"\N{REGIONAL INDICATOR SYMBOL LETTER V}",
"\N{ARIES}\N{VARIATION SELECTOR-16}",
"\N{BALLOT BOX WITH CHECK}\N{VARIATION SELECTOR-16}",
],
"w": [
"\N{REGIONAL INDICATOR SYMBOL LETTER W}",
"\N{WAVY DASH}\N{VARIATION SELECTOR-16}",
"\N{CHART WITH UPWARDS TREND}",
],
"x": [
"\N{REGIONAL INDICATOR SYMBOL LETTER X}",
"\N{NEGATIVE SQUARED CROSS MARK}",
"\N{HEAVY MULTIPLICATION X}\N{VARIATION SELECTOR-16}",
"\N{CROSS MARK}",
"\N{HAMMER AND PICK}\N{VARIATION SELECTOR-16}",
],
"y": [
"\N{REGIONAL INDICATOR SYMBOL LETTER Y}",
"\N{VICTORY HAND}\N{VARIATION SELECTOR-16}",
"\N{BANKNOTE WITH YEN SIGN}",
],
"z": [
"\N{REGIONAL INDICATOR SYMBOL LETTER Z}",
"\N{DIGIT TWO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
],
"0": [
"\N{DIGIT ZERO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{NEGATIVE SQUARED LATIN CAPITAL LETTER O}\N{VARIATION SELECTOR-16}",
"\N{DIGIT ZERO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{HEAVY LARGE CIRCLE}\N{VARIATION SELECTOR-16}",
"\N{RADIO BUTTON}",
"\N{BLACK CIRCLE FOR RECORD}\N{VARIATION SELECTOR-16}",
"\N{MEDIUM WHITE CIRCLE}\N{VARIATION SELECTOR-16}",
"\N{MEDIUM BLACK CIRCLE}\N{VARIATION SELECTOR-16}",
"\N{LARGE BLUE CIRCLE}",
"\N{LARGE RED CIRCLE}",
"\N{DIZZY SYMBOL}",
],
"1": [
"\N{DIGIT ONE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{REGIONAL INDICATOR SYMBOL LETTER I}",
],
"2": [
"\N{DIGIT TWO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{REGIONAL INDICATOR SYMBOL LETTER Z}",
],
"3": ["\N{DIGIT THREE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}"],
"4": ["\N{DIGIT FOUR}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}"],
"5": [
"\N{DIGIT FIVE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{REGIONAL INDICATOR SYMBOL LETTER S}",
"\N{HEAVY DOLLAR SIGN}",
"\N{HIGH VOLTAGE SIGN}\N{VARIATION SELECTOR-16}",
],
"6": ["\N{DIGIT SIX}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}"],
"7": ["\N{DIGIT SEVEN}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}"],
"8": [
"\N{DIGIT EIGHT}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}",
"\N{BILLIARDS}",
"\N{REGIONAL INDICATOR SYMBOL LETTER B}",
"\N{NEGATIVE SQUARED LATIN CAPITAL LETTER B}\N{VARIATION SELECTOR-16}",
],
"9": ["\N{DIGIT NINE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}"],
"?": ["\N{BLACK QUESTION MARK ORNAMENT}\N{VARIATION SELECTOR-16}"],
"!": [
"\N{HEAVY EXCLAMATION MARK SYMBOL}\N{VARIATION SELECTOR-16}",
"\N{WHITE EXCLAMATION MARK ORNAMENT}",
"\N{WARNING SIGN}\N{VARIATION SELECTOR-16}",
"\N{HEAVY HEART EXCLAMATION MARK ORNAMENT}\N{VARIATION SELECTOR-16}",
],
"#": ["\N{NUMBER SIGN}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP}"],
# emojis that contain more than one letter can also help us react
# letters that we are trying to replace go in front, emoji to use second
#
Expand All @@ -111,37 +221,37 @@
# the longest ones & most desirable ones should go at the top
# else you'll have "100" -> "🔟0" instead of "100" -> "💯".
"combination": [
["cool", "🆒"],
["back", "🔙"],
["soon", "🔜"],
["free", "🆓"],
["end", "🔚"],
["top", "🔝"],
["abc", "🔤"],
["atm", "🏧"],
["new", "🆕"],
["sos", "🆘"],
["100", "💯"],
["loo", "💯"],
["zzz", "💤"],
["...", "💬"],
["ng", "🆖"],
["id", "🆔"],
["vs", "🆚"],
["wc", "🚾"],
["ab", "🆎"],
["cl", "🆑"],
["ok", "🆗"],
["up", "🆙"],
["10", "🔟"],
["11", ""],
["ll", ""],
["ii", ""],
["tm", ""],
["on", "🔛"],
["oo", "🈁"],
["!?", ""],
["!!", ""],
["21", "📅"],
["cool", "\N{SQUARED COOL}"],
["back", "\N{BACK WITH LEFTWARDS ARROW ABOVE}"],
["soon", "\N{SOON WITH RIGHTWARDS ARROW ABOVE}"],
["free", "\N{SQUARED FREE}"],
["end", "\N{END WITH LEFTWARDS ARROW ABOVE}"],
["top", "\N{TOP WITH UPWARDS ARROW ABOVE}"],
["abc", "\N{INPUT SYMBOL FOR LATIN LETTERS}"],
["atm", "\N{AUTOMATED TELLER MACHINE}"],
["new", "\N{SQUARED NEW}"],
["sos", "\N{SQUARED SOS}"],
["100", "\N{HUNDRED POINTS SYMBOL}"],
["loo", "\N{HUNDRED POINTS SYMBOL}"],
["zzz", "\N{SLEEPING SYMBOL}"],
["...", "\N{SPEECH BALLOON}"],
["ng", "\N{SQUARED NG}"],
["id", "\N{SQUARED ID}"],
["vs", "\N{SQUARED VS}"],
["wc", "\N{WATER CLOSET}"],
["ab", "\N{NEGATIVE SQUARED AB}"],
["cl", "\N{SQUARED CL}"],
["ok", "\N{SQUARED OK}"],
["up", "\N{SQUARED UP WITH EXCLAMATION MARK}"],
["10", "\N{KEYCAP TEN}"],
["11", "\N{DOUBLE VERTICAL BAR}\N{VARIATION SELECTOR-16}"],
["ll", "\N{DOUBLE VERTICAL BAR}\N{VARIATION SELECTOR-16}"],
["ii", "\N{DOUBLE VERTICAL BAR}\N{VARIATION SELECTOR-16}"],
["tm", "\N{TRADE MARK SIGN}\N{VARIATION SELECTOR-16}"],
["on", "\N{ON WITH EXCLAMATION MARK WITH LEFT RIGHT ARROW ABOVE}"],
["oo", "\N{SQUARED KATAKANA KOKO}"],
["!?", "\N{EXCLAMATION QUESTION MARK}\N{VARIATION SELECTOR-16}"],
["!!", "\N{DOUBLE EXCLAMATION MARK}\N{VARIATION SELECTOR-16}"],
["21", "\N{CALENDAR}"],
],
}
Loading

0 comments on commit 61ad559

Please sign in to comment.