mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-23 21:47:04 +01:00
Create EmojiParser.py
Update EmojiParser.py Update EmojiParser.py Now parsing custom emoji Now parsing custom emoji
This commit is contained in:
parent
9661a7cbce
commit
187ae6809f
17
webapp/titanembeds/EmojiParser.py
Normal file
17
webapp/titanembeds/EmojiParser.py
Normal file
@ -0,0 +1,17 @@
|
||||
from titanembeds.utils import discord_api
|
||||
import re
|
||||
|
||||
def parseEmoji(textToParse, guild_id):
|
||||
_endpoint = "/guilds/{guild_id}".format(guild_id=guild_id)
|
||||
_method = "GET"
|
||||
response = discord_api.request(_method, _endpoint)
|
||||
emojis = []
|
||||
emojis = re.findall(":(.*?):", textToParse)
|
||||
newText = textToParse
|
||||
for emoji in response['emojis']:
|
||||
name = emoji['name']
|
||||
emojiId = emoji['id']
|
||||
for emoji2 in emojis:
|
||||
if name.lower is emoji2.replace(":", "").lower():
|
||||
newText = newText.replace(":{}:".format(name), "<img src='https://cdn.discordapp.com/emojis/{}.png'></img>".format(id))
|
||||
return newText
|
@ -1,5 +1,6 @@
|
||||
from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans, AuthenticatedUsers, KeyValueProperties, GuildMembers, Messages, get_channel_messages, list_all_guild_members
|
||||
from titanembeds.decorators import valid_session_required, discord_users_only
|
||||
from titamembeds.EmojiParser import parseEmoji
|
||||
from titanembeds.utils import check_guild_existance, guild_query_unauth_users_bool, get_client_ipaddr, discord_api, rate_limiter, channel_ratelimit_key, guild_ratelimit_key
|
||||
from titanembeds.oauth import user_has_permission, generate_avatar_url, check_user_can_administrate_guild
|
||||
from flask import Blueprint, abort, jsonify, session, request
|
||||
@ -102,6 +103,7 @@ def check_user_in_guild(guild_id):
|
||||
def format_post_content(guild_id, message):
|
||||
illegal_post = False
|
||||
illegal_reasons = []
|
||||
message = parseEmoji(message, guild_id)
|
||||
message = message.replace("<", "\<")
|
||||
message = message.replace(">", "\>")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user