def parseMsg(self, event:tracker.Tracker): trackedEmojis = [] for s in iter(event.message.splitlines()): # Search if its a Discord style emoji first matchObj = self.emojiRegex.search(s) print(matchObj) if matchObj is not None: tEmoji = discord.PartialEmoji(animated=False, name=matchObj.group(2), id=int(matchObj.group(3))) trackedEmojis.append(tEmoji) continue # Next try to lookup the by unicode #matchObj = self.unicodeEmojiRegex.search(s) matchObj = emoji.get_emoji_regexp().search(s) print(matchObj) if matchObj is not None: tEmoji = discord.PartialEmoji(animated=False, name=matchObj.group(0), id=None) trackedEmojis.append(tEmoji) continue event.cogData = trackedEmojis print(trackedEmojis)
def parseMsg(self, event: tracker.Tracker): trackedEmojis = [] for s in iter(event.message.splitlines()): # Remove all whitespace at the start of the line sStrip = s.lstrip() # Search if its a Discord style emoji first matchObj = self.emojiRegex.search(sStrip) if matchObj is not None: tEmoji = discord.PartialEmoji(animated=False, name=matchObj.group(2), id=int(matchObj.group(3))) # Prevent duplicates from making it into the list if tEmoji not in trackedEmojis: trackedEmojis.append(tEmoji) continue # Next try to lookup the by unicode # Check to make sure the first character ISNT a normal character since the emoji library's regex # will find anything. This check allows us to make sure a unicode emoji is at the start of the line # We also need to check for ':' since a unicode emoji may be the name if ((len(sStrip) > 0) and (sStrip[0] == ':' or not (sStrip[0].isascii()))): matchObj = emoji.get_emoji_regexp().search(sStrip) if matchObj is not None: tEmoji = discord.PartialEmoji(animated=False, name=matchObj.group(0), id=None) # Prevent duplicates from making it into the list if tEmoji not in trackedEmojis: trackedEmojis.append(tEmoji) continue event.cogData = trackedEmojis