mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Send mentions from embed
This commit is contained in:
parent
674c98b100
commit
ceb19cd1af
@ -8,6 +8,7 @@ import random
|
||||
import requests
|
||||
import json
|
||||
import datetime
|
||||
import re
|
||||
from config import config
|
||||
|
||||
api = Blueprint("api", __name__)
|
||||
@ -99,7 +100,13 @@ def check_user_in_guild(guild_id):
|
||||
|
||||
def format_post_content(message):
|
||||
message = message.replace("<", "\<")
|
||||
message = message.replace(">", "\>") #escape mentions for now
|
||||
message = message.replace(">", "\>")
|
||||
|
||||
pattern = re.compile(r'\[@[0-9]+\]')
|
||||
for match in re.findall(pattern, message):
|
||||
mention = "<@" + match[2: len(match) - 1] + ">"
|
||||
message = message.replace(match, mention, 1)
|
||||
|
||||
if (session['unauthenticated']):
|
||||
message = "**[{}#{}]** {}".format(session['username'], session['user_id'], message)
|
||||
else:
|
||||
|
@ -155,14 +155,25 @@ function fill_channels(channels) {
|
||||
$("#channel-"+selected_channel).parent().addClass("active");
|
||||
}
|
||||
|
||||
function mention_member(member_id) {
|
||||
if (!$('#messagebox').prop('disabled')) {
|
||||
$('#messagebox').val( $('#messagebox').val() + "[@" + member_id + "] " );
|
||||
$('.button-collapse').sideNav('hide');
|
||||
$("#messagebox").focus();
|
||||
}
|
||||
}
|
||||
|
||||
function fill_discord_members(discordmembers) {
|
||||
var template = $('#mustache_authedusers').html();
|
||||
Mustache.parse(template);
|
||||
$("#discord-members").empty();
|
||||
for (var i = 0; i < discordmembers.length; i++) {
|
||||
var member = discordmembers[i];
|
||||
var rendered = Mustache.render(template, {"id": member.id, "username": member.username, "avatar": member.avatar_url});
|
||||
var rendered = Mustache.render(template, {"id": member.id.toString() + "d", "username": member.username, "avatar": member.avatar_url});
|
||||
$("#discord-members").append(rendered);
|
||||
$( "#discorduser-" + member.id.toString() + "d").click(function() {
|
||||
mention_member(member.id.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,8 +183,11 @@ function fill_authenticated_users(users) {
|
||||
$("#embed-discord-members").empty();
|
||||
for (var i = 0; i < users.length; i++) {
|
||||
var member = users[i];
|
||||
var rendered = Mustache.render(template, {"id": member.id, "username": member.username, "avatar": member.avatar_url});
|
||||
var rendered = Mustache.render(template, {"id": member.id.toString() + "a", "username": member.username, "avatar": member.avatar_url});
|
||||
$("#embed-discord-members").append(rendered);
|
||||
$( "#discorduser-" + member.id.toString() + "a").click(function() {
|
||||
mention_member(member.id.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user