mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Implement nickname support
Nicknames will be shown in both the embed and discord.
This commit is contained in:
parent
5da55cc66b
commit
2ace5f7040
@ -69,6 +69,8 @@ class DatabaseInterface(object):
|
|||||||
|
|
||||||
def get_message_author(self, message):
|
def get_message_author(self, message):
|
||||||
author = message.author
|
author = message.author
|
||||||
|
if author.nick is not None:
|
||||||
|
author.name = author.nick
|
||||||
obj = {
|
obj = {
|
||||||
"username": author.name,
|
"username": author.name,
|
||||||
"discriminator": author.discriminator,
|
"discriminator": author.discriminator,
|
||||||
@ -81,6 +83,8 @@ class DatabaseInterface(object):
|
|||||||
def get_message_mentions(self, mentions):
|
def get_message_mentions(self, mentions):
|
||||||
ments = []
|
ments = []
|
||||||
for author in mentions:
|
for author in mentions:
|
||||||
|
if author.nick:
|
||||||
|
author.name = author.nick
|
||||||
ments.append({
|
ments.append({
|
||||||
"username": author.name,
|
"username": author.name,
|
||||||
"discriminator": author.discriminator,
|
"discriminator": author.discriminator,
|
||||||
@ -264,7 +268,7 @@ class DatabaseInterface(object):
|
|||||||
dbmember.active = active
|
dbmember.active = active
|
||||||
dbmember.username = member.name
|
dbmember.username = member.name
|
||||||
dbmember.discriminator = member.discriminator
|
dbmember.discriminator = member.discriminator
|
||||||
dbmember.nick = member.nick
|
dbmember.nickname = member.nick
|
||||||
dbmember.avatar = member.avatar
|
dbmember.avatar = member.avatar
|
||||||
dbmember.roles = json.dumps(self.list_role_ids(member.roles))
|
dbmember.roles = json.dumps(self.list_role_ids(member.roles))
|
||||||
session.commit()
|
session.commit()
|
||||||
|
@ -109,7 +109,7 @@ def parse_emoji(textToParse, guild_id):
|
|||||||
return textToParse
|
return textToParse
|
||||||
|
|
||||||
|
|
||||||
def format_post_content(guild_id, channel_id, message):
|
def format_post_content(guild_id, channel_id, message, dbUser):
|
||||||
illegal_post = False
|
illegal_post = False
|
||||||
illegal_reasons = []
|
illegal_reasons = []
|
||||||
message = message.replace("<", "\<")
|
message = message.replace("<", "\<")
|
||||||
@ -140,7 +140,11 @@ def format_post_content(guild_id, channel_id, message):
|
|||||||
if (session['unauthenticated']):
|
if (session['unauthenticated']):
|
||||||
message = u"**[{}#{}]** {}".format(session['username'], session['user_id'], message)
|
message = u"**[{}#{}]** {}".format(session['username'], session['user_id'], message)
|
||||||
else:
|
else:
|
||||||
message = u"**<{}#{}>** {}".format(session['username'], session['discriminator'], message) # I would like to do a @ mention, but i am worried about notif spam
|
username = session['username']
|
||||||
|
if dbUser:
|
||||||
|
if dbUser.nickname:
|
||||||
|
username = dbUser.nickname
|
||||||
|
message = u"**<{}#{}>** {}".format(username, session['discriminator'], message) # I would like to do a @ mention, but i am worried about notify spam
|
||||||
return (message, illegal_post, illegal_reasons)
|
return (message, illegal_post, illegal_reasons)
|
||||||
|
|
||||||
def format_everyone_mention(channel, content):
|
def format_everyone_mention(channel, content):
|
||||||
@ -364,11 +368,15 @@ def post():
|
|||||||
guild_id = request.form.get("guild_id")
|
guild_id = request.form.get("guild_id")
|
||||||
channel_id = request.form.get('channel_id')
|
channel_id = request.form.get('channel_id')
|
||||||
content = request.form.get('content')
|
content = request.form.get('content')
|
||||||
content, illegal_post, illegal_reasons = format_post_content(guild_id, channel_id, content)
|
if "user_id" in session:
|
||||||
|
dbUser = GuildMembers.query.filter(GuildMembers.guild_id == guild_id).filter(GuildMembers.user_id == session['user_id']).first()
|
||||||
|
else:
|
||||||
|
dbUser = None
|
||||||
if user_unauthenticated():
|
if user_unauthenticated():
|
||||||
key = session['user_keys'][guild_id]
|
key = session['user_keys'][guild_id]
|
||||||
else:
|
else:
|
||||||
key = None
|
key = None
|
||||||
|
content, illegal_post, illegal_reasons = format_post_content(guild_id, channel_id, content, dbUser)
|
||||||
status = update_user_status(guild_id, session['username'], key)
|
status = update_user_status(guild_id, session['username'], key)
|
||||||
message = {}
|
message = {}
|
||||||
if illegal_post:
|
if illegal_post:
|
||||||
@ -392,6 +400,9 @@ def post():
|
|||||||
avatar = url_for('static', filename='img/titanembeds_round.png', _external=True)
|
avatar = url_for('static', filename='img/titanembeds_round.png', _external=True)
|
||||||
else:
|
else:
|
||||||
username = session["username"]
|
username = session["username"]
|
||||||
|
if dbUser:
|
||||||
|
if dbUser.nickname:
|
||||||
|
username = dbUser.nickname
|
||||||
if content.startswith("(Titan Dev) "):
|
if content.startswith("(Titan Dev) "):
|
||||||
content = content[12:]
|
content = content[12:]
|
||||||
username = "(Titan Dev) " + username
|
username = "(Titan Dev) " + username
|
||||||
|
Loading…
Reference in New Issue
Block a user