Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
allhands = "Someone actually gets paid to make a %s, a %s, and a %s" % (
person_tipping_hand,
man_tipping_hand,
woman_tipping_hand,
)
assert demoji.findall(allhands) == {
person_tipping_hand: "person tipping hand",
man_tipping_hand: "man tipping hand",
woman_tipping_hand: "woman tipping hand",
}
assert (
demoji.replace(allhands)
== "Someone actually gets paid to make a , a , and a "
)
assert (
demoji.replace(allhands, "X")
== "Someone actually gets paid to make a X, a X, and a X"
)
assert isinstance(demoji.last_downloaded_timestamp(), datetime.datetime)
# Something for everyone...
batch = [
"๐",
"๐",
"๐คฉ",
"๐ค",
"๐คข",
"๐",
"๐ซ",
"๐",
"๐",
"๐งก",
def removeWords(self):
self.sentence = demoji.replace(self.sentence)
finalText = ''
invisibleChar = [u"\u2800", u"\u2063", u'\xe3', u'\xa4']
words = [i for j in self.sentence.split() for i in (j, ' ')][:-1]
for word in words:
word = word.lower()
# remove twt username, hashtag, and links
if word[0] == '@' or word[0] == '#' or word[0:4] == 'http':
word = word.replace(word, '')
if word[0:5] == '&':
word = word.replace(word, '&')
for ew in self.excludedWords: # remove unnecassary words
word = word.replace(ew, '')
for char in word:
if char in invisibleChar: # remove invisible char
def remove_emoji(self):
# emoji_pattern = re.compile(
# u'(\U0001F1F2\U0001F1F4)|' # Macau flag
# u'([\U0001F1E6-\U0001F1FF]{2})|' # flags
# u'([\U0001F600-\U0001F64F])' # emoticons
# "+", flags=re.UNICODE)
# self.filename = emoji_pattern.sub('', self.filename)
try:
self.filename = demoji.replace(self.filename, '#')
except IOError:
demoji.download_codes()
jumbo = (not re.sub(r'(\s)', '', re.sub(jumbo_pat, '', content))) and (len(re.findall(jumbo_pat, content)) < 28)
emoji_class = 'emoji emoji--large' if jumbo else 'emoji'
# Custom emojis (<:name:id>)
content = re.sub(r'<(:.*?:)(\d*)>', fr'<img alt="\1" src="'
fr'https://cdn.discordapp.com/emojis/\2.png" title="\1" class="{emoji_class}">', content)
# Custom animated emojis ()
content = re.sub(r'<a(:.*?:)(\d*)>', fr'<img alt="\1" src="'
fr'https://cdn.discordapp.com/emojis/\2.gif" title="\1" class="{emoji_class}">', content)
# Process emojis (:text:)
content = re.sub(EMOJI_REGEX, _process_emojis, content)
# Process unicode emojis
content = demoji.replace(content, lambda m: _process_unicode_emojis(m, emoji_class))
# Process block quotes (> text or >>> te\ntx)
content = re.sub(r'^> (.+)$|^(?:>){3} ([\S\s]+)$', r'<blockquote>\1\2</blockquote>', content)
# Process bold (**text**)
content = re.sub(r'\*\*((?:\\[\s\S]|[^\\])+?)\*\*(?!\*)', r'<b>\1</b>', content)
# Process underline (__text__)
content = re.sub(r'__((?:\\[\s\S]|[^\\])+?)__(?!_)', r'<u>\1</u>', content)
# Process italic (*text* or _text_)
content = re.sub(r'\b_((?:__|\\[\s\S]|[^\\_])+?)_\b|\*(?=\S)((?:\*\*|\\[\s\S]|\s+(?:\\[\s\S]|[^\s*\\]|\*\*)|'
r'[^\s*\\])+?)\*(?!\*)', r'<i>\1\2</i>', content)
# Process strike through (~~text~~)
content = re.sub(r'~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s\\~]|\s+(?!~~))+?)~~', r'<s>\1</s>', content)
# Process emojis (:text:)
content = re.sub(EMOJI_REGEX, process_emojis, content)
def process_unicode_emojis(m):
e = m.group()
e = re.sub(r'[\U0000FE00-\U0000FE0F]$', '', e)
title_e = re.sub(r'[\U0001F3FB-\U0001F3FF]$', '', e)
if not title_e:
title_e = e
title = UNICODE_LIST.get(title_e) or demoji._CODE_TO_DESC[title_e]
codepoint = "-".join(['%04x' % ord(_c) for _c in e]).lstrip('0')
return fr'<img alt="{e}" title=":{title}:" class="emoji">'
# Process unicode emojis
content = demoji.replace(content, process_unicode_emojis)
# Process bold (**text**)
content = re.sub(r'\*\*((?:\\[\s\S]|[^\\])+?)\*\*(?!\*)', r'<b>\1</b>', content)
# Process underline (__text__)
content = re.sub(r'__((?:\\[\s\S]|[^\\])+?)__(?!_)', r'<u>\1</u>', content)
# Process italic (*text* or _text_)
content = re.sub(r'\b_((?:__|\\[\s\S]|[^\\_])+?)_\b|\*(?=\S)((?:\*\*|\\[\s\S]|\s+(?:\\[\s\S]|[^\s*\\]|\*\*)|'
r'[^\s*\\])+?)\*(?!\*)', r'<i>\1\2</i>', content)
# Process strike through (~~text~~)
content = re.sub(r'~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s\\~]|\s+(?!~~))+?)~~', r'<s>\1</s>', content)
# Decode and process links
def decode_url(m):
content = re.sub(EMOJI_REGEX, process_emojis, content)
def process_unicode_emojis(m):
e = m.group()
e = re.sub(r'[\U0000FE00-\U0000FE0F]$', '', e)
title_e = re.sub(r'[\U0001F3FB-\U0001F3FF]$', '', e)
if not title_e:
title_e = e
title = UNICODE_LIST.get(title_e) or demoji._CODE_TO_DESC[title_e]
emoji_class = 'emoji emoji--large' if jumbo else 'emoji'
codepoint = "-".join(['%04x' % ord(_c) for _c in e]).lstrip('0')
return fr'<img alt="{e}" title=":{title}:" class="{emoji_class}">'
# Process unicode emojis
content = demoji.replace(content, process_unicode_emojis)
# Process block quotes (> text or >>> te\ntx)
content = re.sub(r'^> (.+)$|^(?:>){3} ([\S\s]+)$', r'<blockquote>\1\2</blockquote>', content)
# Process bold (**text**)
content = re.sub(r'\*\*((?:\\[\s\S]|[^\\])+?)\*\*(?!\*)', r'<b>\1</b>', content)
# Process underline (__text__)
content = re.sub(r'__((?:\\[\s\S]|[^\\])+?)__(?!_)', r'<u>\1</u>', content)
# Process italic (*text* or _text_)
content = re.sub(r'\b_((?:__|\\[\s\S]|[^\\_])+?)_\b|\*(?=\S)((?:\*\*|\\[\s\S]|\s+(?:\\[\s\S]|[^\s*\\]|\*\*)|'
r'[^\s*\\])+?)\*(?!\*)', r'<i>\1\2</i>', content)
# Process strike through (~~text~~)
content = re.sub(r'~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s\\~]|\s+(?!~~))+?)~~', r'<s>\1</s>', content)