mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-23 21:47:04 +01:00
Renamed webhook icon to guest icon for preperation of avatars in the client
This commit is contained in:
parent
cb10c35ec9
commit
ad833434dd
@ -8,7 +8,7 @@ class Guilds(Base):
|
||||
unauth_users = db.Column(db.Boolean()) # If allowed unauth users
|
||||
visitor_view = db.Column(db.Boolean()) # If users are automatically "signed in" and can view chat
|
||||
webhook_messages = db.Column(db.Boolean()) # Use webhooks to send messages instead of the bot
|
||||
webhook_icon = db.Column(db.String(255), default=None) # Webhook icon url, None if unset
|
||||
guest_icon = db.Column(db.String(255), default=None) # Guest icon url, None if unset
|
||||
chat_links = db.Column(db.Boolean()) # If users can post links
|
||||
bracket_links = db.Column(db.Boolean()) # If appending brackets to links to prevent embed
|
||||
mentions_limit = db.Column(db.Integer) # If there is a limit on the number of mentions in a msg
|
||||
@ -26,7 +26,7 @@ class Guilds(Base):
|
||||
self.unauth_users = True # defaults to true
|
||||
self.visitor_view = False
|
||||
self.webhook_messages = False
|
||||
self.webhook_icon = None
|
||||
self.guest_icon = None
|
||||
self.chat_links = True
|
||||
self.bracket_links = True
|
||||
self.mentions_limit = -1 # -1 = unlimited mentions
|
||||
|
@ -0,0 +1,30 @@
|
||||
"""Renamed webhook icon to guest icon
|
||||
|
||||
Revision ID: 109a6025e9ec
|
||||
Revises: 39815dfbcccb
|
||||
Create Date: 2017-09-24 00:52:44.038589
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '109a6025e9ec'
|
||||
down_revision = '39815dfbcccb'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('guilds', 'webhook_icon', new_column_name='guest_icon')
|
||||
op.alter_column('cosmetics', 'webhook_icon', new_column_name='guest_icon')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('guilds', 'guest_icon', new_column_name='webhook_icon')
|
||||
op.alter_column('cosmetics', 'guest_icon', new_column_name='webhook_icon')
|
||||
# ### end Alembic commands ###
|
@ -37,7 +37,7 @@ def cosmetics_post():
|
||||
abort(400)
|
||||
css = request.form.get("css", None)
|
||||
css_limit = int(request.form.get("css_limit", 0))
|
||||
webhook_icon = request.form.get("webhook_icon", None)
|
||||
guest_icon = request.form.get("guest_icon", None)
|
||||
entry = db.session.query(Cosmetics).filter(Cosmetics.user_id == user_id).first()
|
||||
if entry:
|
||||
abort(409)
|
||||
@ -47,9 +47,9 @@ def cosmetics_post():
|
||||
user.css = css
|
||||
if css_limit is not None:
|
||||
user.css_limit = css_limit
|
||||
if webhook_icon is not None:
|
||||
webhook_icon = webhook_icon.lower() == "true"
|
||||
user.webhook_icon = webhook_icon
|
||||
if guest_icon is not None:
|
||||
guest_icon = guest_icon.lower() == "true"
|
||||
user.guest_icon = guest_icon
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
return ('', 204)
|
||||
@ -75,7 +75,7 @@ def cosmetics_patch():
|
||||
abort(400)
|
||||
css = request.form.get("css", None)
|
||||
css_limit = request.form.get("css_limit", None)
|
||||
webhook_icon = request.form.get("webhook_icon", None)
|
||||
guest_icon = request.form.get("guest_icon", None)
|
||||
entry = db.session.query(Cosmetics).filter(Cosmetics.user_id == user_id).first()
|
||||
if not entry:
|
||||
abort(409)
|
||||
@ -84,9 +84,9 @@ def cosmetics_patch():
|
||||
entry.css = css
|
||||
if css_limit is not None:
|
||||
entry.css_limit = css_limit
|
||||
if webhook_icon:
|
||||
webhook_icon = webhook_icon.lower() == "true"
|
||||
entry.webhook_icon = webhook_icon
|
||||
if guest_icon:
|
||||
guest_icon = guest_icon.lower() == "true"
|
||||
entry.guest_icon = guest_icon
|
||||
db.session.commit()
|
||||
return ('', 204)
|
||||
def prepare_guild_members_list(members, bans):
|
||||
@ -156,7 +156,7 @@ def administrate_guild(guild_id):
|
||||
"mentions_limit": db_guild.mentions_limit,
|
||||
"icon": db_guild.icon,
|
||||
"discordio": db_guild.discordio if db_guild.discordio != None else "",
|
||||
"webhook_icon": db_guild.webhook_icon if db_guild.webhook_icon != None else "",
|
||||
"guest_icon": db_guild.guest_icon if db_guild.guest_icon != None else "",
|
||||
}
|
||||
return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions, cosmetics=cosmetics)
|
||||
|
||||
@ -174,10 +174,10 @@ def update_administrate_guild(guild_id):
|
||||
if discordio != None and discordio.strip() == "":
|
||||
discordio = None
|
||||
db_guild.discordio = discordio
|
||||
webhook_icon = request.form.get("webhook_icon", db_guild.webhook_icon)
|
||||
if webhook_icon != None and webhook_icon.strip() == "":
|
||||
webhook_icon = None
|
||||
db_guild.webhook_icon = webhook_icon
|
||||
guest_icon = request.form.get("guest_icon", db_guild.guest_icon)
|
||||
if guest_icon != None and guest_icon.strip() == "":
|
||||
guest_icon = None
|
||||
db_guild.guest_icon = guest_icon
|
||||
db.session.commit()
|
||||
return jsonify(
|
||||
id=db_guild.id,
|
||||
@ -189,7 +189,7 @@ def update_administrate_guild(guild_id):
|
||||
bracket_links=db_guild.bracket_links,
|
||||
mentions_limit=db_guild.mentions_limit,
|
||||
discordio=db_guild.discordio,
|
||||
webhook_icon=db_guild.webhook_icon,
|
||||
guest_icon=db_guild.guest_icon,
|
||||
)
|
||||
|
||||
@admin.route("/guilds")
|
||||
|
@ -251,7 +251,7 @@ def post():
|
||||
avatar = url_for('static', filename='img/titanembeds_square.png', _external=True)
|
||||
dbguild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first()
|
||||
if dbguild:
|
||||
icon = dbguild.webhook_icon
|
||||
icon = dbguild.guest_icon
|
||||
if icon:
|
||||
avatar = icon
|
||||
else:
|
||||
|
@ -210,7 +210,7 @@ def administrate_guild(guild_id):
|
||||
"mentions_limit": db_guild.mentions_limit,
|
||||
"icon": db_guild.icon,
|
||||
"discordio": db_guild.discordio if db_guild.discordio != None else "",
|
||||
"webhook_icon": db_guild.webhook_icon if db_guild.webhook_icon != None else "",
|
||||
"guest_icon": db_guild.guest_icon if db_guild.guest_icon != None else "",
|
||||
}
|
||||
return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions, cosmetics=cosmetics)
|
||||
|
||||
@ -236,10 +236,10 @@ def update_administrate_guild(guild_id):
|
||||
discordio = None
|
||||
db_guild.discordio = discordio
|
||||
|
||||
webhook_icon = request.form.get("webhook_icon", db_guild.webhook_icon)
|
||||
if webhook_icon != None and webhook_icon.strip() == "":
|
||||
webhook_icon = None
|
||||
db_guild.webhook_icon = webhook_icon
|
||||
guest_icon = request.form.get("guest_icon", db_guild.guest_icon)
|
||||
if guest_icon != None and guest_icon.strip() == "":
|
||||
guest_icon = None
|
||||
db_guild.guest_icon = guest_icon
|
||||
|
||||
db.session.commit()
|
||||
return jsonify(
|
||||
@ -252,7 +252,7 @@ def update_administrate_guild(guild_id):
|
||||
bracket_links=db_guild.bracket_links,
|
||||
mentions_limit=db_guild.mentions_limit,
|
||||
discordio=db_guild.discordio,
|
||||
webhook_icon=webhook_icon,
|
||||
guest_icon=guest_icon,
|
||||
)
|
||||
|
||||
@user.route("/add-bot/<guild_id>")
|
||||
@ -444,9 +444,9 @@ def donate_patch():
|
||||
entry = db.session.query(Cosmetics).filter(Cosmetics.user_id == session["user_id"]).first()
|
||||
if item == "custom_css_slots":
|
||||
subtract_amt = 100
|
||||
if item == "webhook_icon":
|
||||
if item == "guest_icon":
|
||||
subtract_amt = 300
|
||||
if entry is not None and entry.webhook_icon:
|
||||
if entry is not None and entry.guest_icon:
|
||||
abort(400)
|
||||
amt_change = -1 * subtract_amt * amount
|
||||
subtract = set_titan_token(session["user_id"], amt_change, "BUY " + item + " x" + str(amount))
|
||||
@ -459,10 +459,10 @@ def donate_patch():
|
||||
entry.css = True
|
||||
entry.css_limit = 0
|
||||
entry.css_limit += amount
|
||||
if item == "webhook_icon":
|
||||
if item == "guest_icon":
|
||||
if not entry:
|
||||
entry = Cosmetics(session["user_id"])
|
||||
entry.webhook_icon = True
|
||||
entry.guest_icon = True
|
||||
db.session.add(entry)
|
||||
db.session.commit()
|
||||
return ('', 204)
|
@ -6,7 +6,7 @@ class Cosmetics(db.Model):
|
||||
user_id = db.Column(db.String(255), nullable=False) # Discord user id of user of cosmetics
|
||||
css = db.Column(db.Boolean(), nullable=False) # If they can create/edit custom CSS
|
||||
css_limit = db.Column(db.Integer, nullable=False, server_default="0") # Custom CSS Limit
|
||||
webhook_icon = db.Column(db.Boolean(), nullable=False, server_default=db.false()) # If they can set the webhook icon for all guilds
|
||||
guest_icon = db.Column(db.Boolean(), nullable=False, server_default=db.false()) # If they can set the guest icon for all guilds
|
||||
|
||||
def __init__(self, user_id, **kwargs):
|
||||
self.user_id = user_id
|
||||
@ -21,7 +21,7 @@ class Cosmetics(db.Model):
|
||||
else:
|
||||
self.css_limit = 0
|
||||
|
||||
if "webhook_icon" in kwargs:
|
||||
self.webhook_icon = kwargs["webhook_icon"]
|
||||
if "guest_icon" in kwargs:
|
||||
self.guest_icon = kwargs["guest_icon"]
|
||||
else:
|
||||
self.webhook_icon = False
|
||||
self.guest_icon = False
|
@ -8,7 +8,7 @@ class Guilds(db.Model):
|
||||
unauth_users = db.Column(db.Boolean(), nullable=False, default=1) # If allowed unauth users
|
||||
visitor_view = db.Column(db.Boolean(), nullable=False, default=0) # If users are automatically "signed in" and can view chat
|
||||
webhook_messages = db.Column(db.Boolean(), nullable=False, default=0) # Use webhooks to send messages instead of the bot
|
||||
webhook_icon = db.Column(db.String(255), default=None) # Webhook icon url, None if unset
|
||||
guest_icon = db.Column(db.String(255), default=None) # Guest icon url, None if unset
|
||||
chat_links = db.Column(db.Boolean(), nullable=False, default=1) # If users can post links
|
||||
bracket_links = db.Column(db.Boolean(), nullable=False, default=1) # If appending brackets to links to prevent embed
|
||||
mentions_limit = db.Column(db.Integer, nullable=False, default=11) # If there is a limit on the number of mentions in a msg
|
||||
@ -26,7 +26,7 @@ class Guilds(db.Model):
|
||||
self.unauth_users = True # defaults to true
|
||||
self.visitor_view = False
|
||||
self.webhook_messages = False
|
||||
self.webhook_icon = None
|
||||
self.guest_icon = None
|
||||
self.chat_links = True
|
||||
self.bracket_links = True
|
||||
self.mentions_limit = -1 # -1 = unlimited mentions
|
||||
|
@ -1,13 +1,13 @@
|
||||
/* global $, Materialize, location */
|
||||
|
||||
function postForm(user_id, css, css_limit, webhook_icon) {
|
||||
function postForm(user_id, css, css_limit, guest_icon) {
|
||||
if (css_limit == "") {
|
||||
css_limit = 0;
|
||||
}
|
||||
var funct = $.ajax({
|
||||
dataType: "json",
|
||||
method: "POST",
|
||||
data: {"user_id": user_id, "css": css, "css_limit": css_limit, "webhook_icon": webhook_icon}
|
||||
data: {"user_id": user_id, "css": css, "css_limit": css_limit, "guest_icon": guest_icon}
|
||||
});
|
||||
return funct.promise();
|
||||
}
|
||||
@ -40,8 +40,8 @@ $(function() {
|
||||
}
|
||||
var css_checked = $("#new_css_switch").is(':checked');
|
||||
var css_limit = $("#new_css_limit").val();
|
||||
var webhook_icon_checked = $("#new_webhook_icon_switch").is(':checked');
|
||||
var formPost = postForm(user_id, css_checked, css_limit, webhook_icon_checked);
|
||||
var guest_icon_checked = $("#new_guest_icon_switch").is(':checked');
|
||||
var formPost = postForm(user_id, css_checked, css_limit, guest_icon_checked);
|
||||
formPost.done(function (data) {
|
||||
location.reload();
|
||||
});
|
||||
@ -101,9 +101,9 @@ function update_css_limit(user_id, value) {
|
||||
});
|
||||
}
|
||||
|
||||
function update_webhook_icon_switch(user_id, element) {
|
||||
function update_guest_icon_switch(user_id, element) {
|
||||
var webhook_checked = $(element).is(':checked');
|
||||
var formPatch = patchForm(user_id, {"webhook_icon": webhook_checked});
|
||||
var formPatch = patchForm(user_id, {"guest_icon": webhook_checked});
|
||||
formPatch.done(function (data) {
|
||||
Materialize.toast('Webhook Icon updated!', 10000);
|
||||
});
|
||||
|
@ -65,13 +65,13 @@ $("#discordio").keyup(function(event){
|
||||
}
|
||||
});
|
||||
|
||||
$("#webhook_icon").keyup(function(event){
|
||||
$("#guest_icon").keyup(function(event){
|
||||
if(event.keyCode == 13){
|
||||
var pathname = window.location.pathname;
|
||||
var value = $("#webhook_icon").val()
|
||||
var payload = {"webhook_icon": value}
|
||||
var value = $("#guest_icon").val()
|
||||
var payload = {"guest_icon": value}
|
||||
$.post(pathname, payload, function(data) {
|
||||
Materialize.toast('Updated Webhook Icon setting!', 2000)
|
||||
Materialize.toast('Updated Guest Icon setting!', 2000)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -47,10 +47,10 @@
|
||||
});
|
||||
});
|
||||
|
||||
$("#buy-webhook-guest-user-avatar-btn").click(function () {
|
||||
var formPatch = patchForm("webhook_icon", 1);
|
||||
$("#buy-guest-user-avatar-btn").click(function () {
|
||||
var formPatch = patchForm("guest_icon", 1);
|
||||
formPatch.done(function (data) {
|
||||
alert("Successfully bought webhook guest user avatar perk!");
|
||||
alert("Successfully bought guest user avatar perk!");
|
||||
location.reload();
|
||||
});
|
||||
formPatch.fail(function (data) {
|
||||
@ -59,7 +59,7 @@
|
||||
} else if (data.status == 402) {
|
||||
Materialize.toast('Insufficient token funds!', 10000);
|
||||
} else {
|
||||
Materialize.toast('Purchasing webhook guest user avatar perk failed!', 10000);
|
||||
Materialize.toast('Purchasing guest user avatar perk failed!', 10000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -14,7 +14,7 @@
|
||||
<th>User ID</th>
|
||||
<th>CSS</th>
|
||||
<th>CSS Limit</th>
|
||||
<th>Webhook Icon</th>
|
||||
<th>Guest Icon</th>
|
||||
<th>Submit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -44,7 +44,7 @@
|
||||
<div class="switch">
|
||||
<label>
|
||||
Off
|
||||
<input type="checkbox" id="new_webhook_icon_switch">
|
||||
<input type="checkbox" id="new_guest_icon_switch">
|
||||
<span class="lever"></span>
|
||||
On
|
||||
</label>
|
||||
@ -68,7 +68,7 @@
|
||||
<th>User ID</th>
|
||||
<th>CSS</th>
|
||||
<th>CSS Limit</th>
|
||||
<th>Webhook Icon</th>
|
||||
<th>Guest Icon</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -95,7 +95,7 @@
|
||||
<div class="switch">
|
||||
<label>
|
||||
Off
|
||||
<input type="checkbox" {% if cosmetic.webhook_icon %}checked{% endif %} onchange="update_webhook_icon_switch('{{ cosmetic.user_id }}', this)">
|
||||
<input type="checkbox" {% if cosmetic.guest_icon %}checked{% endif %} onchange="update_guest_icon_switch('{{ cosmetic.user_id }}', this)">
|
||||
<span class="lever"></span>
|
||||
On
|
||||
</label>
|
||||
|
@ -115,13 +115,13 @@
|
||||
|
||||
<br>
|
||||
|
||||
<p class="flow-text">Webhook Guest User Avatar URL</p>
|
||||
<p>If enabled Webhook Messages, you may set it so that the guest users may have a custom avatar instead of the Titan logo. Source must be the permanent URL location to the image file (try imgur and get direct link to image).</p>
|
||||
<p class="flow-text">Guest User Avatar URL</p>
|
||||
<p>Guest users may have a custom avatar instead of the Titan logo. Source must be the permanent URL location to the image file (try imgur and get direct link to image).</p>
|
||||
<p>(Leave blank if none - enter to submit)</p>
|
||||
{% if not cosmetics.webhook_icon %}
|
||||
<p class="red lighten-4"><strong>Your user account does not have access to change webhook avatar url. Please visit the Titan Tokens shop to activate this cosmetic item.</strong></p>
|
||||
{% if not cosmetics.guest_icon %}
|
||||
<p class="red lighten-4"><strong>Your user account does not have access to change guest avatar url. Please visit the Titan Tokens shop to activate this cosmetic item.</strong></p>
|
||||
{% endif %}
|
||||
<input id="webhook_icon" value="{{ guild['webhook_icon'] }}" {% if not cosmetics.webhook_icon %}disabled{% endif %}>
|
||||
<input id="guest_icon" value="{{ guild['guest_icon'] }}" {% if not cosmetics.guest_icon %}disabled{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -47,10 +47,10 @@
|
||||
</div>
|
||||
<div class="col s12">
|
||||
<div class="card-panel indigo lighten-5 z-depth-3 hoverable black-text">
|
||||
<h4>Webhook Guest User Avatar <strong>[300 tokens]</strong></h4>
|
||||
<p class="flow-text">Tired of the bland Titan logo for your guests avatars in your servers? Enables your account to be able to set webhook icons for guests for all servers you can manage.</p>
|
||||
<p>(Note: Webhook Messages has to be enabled & Titan needs server permissions to create webhooks)</p>
|
||||
<a class="waves-effect waves-light btn" id="buy-webhook-guest-user-avatar-btn" {% if cosmetics.webhook_icon %}disabled{% endif %}>{% if cosmetics.webhook_icon %}Already Purchased{% else %}Buy{% endif %}</a>
|
||||
<h4>Guest User Avatar <strong>[300 tokens]</strong></h4>
|
||||
<p class="flow-text">Tired of the bland Titan logo for your guests avatars in your servers? Enables your account to be able to set icons for guests on all servers you can manage.</p>
|
||||
<p>(Note: Webhook Messages has to be enabled to be displayed in Discord; Titan needs server permissions to create webhooks)</p>
|
||||
<a class="waves-effect waves-light btn" id="buy-guest-user-avatar-btn" {% if cosmetics.guest_icon %}disabled{% endif %}>{% if cosmetics.guest_icon %}Already Purchased{% else %}Buy{% endif %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user