remotes/1693045480750635534/spooky-22
Aevann1 2021-11-18 19:11:39 +02:00
parent f8fa983d9f
commit 088fbb981f
2 changed files with 47 additions and 19 deletions

View File

@ -202,25 +202,27 @@ def transfer_coins(v, username):
if v.coins < amount: return {"error": f"You don't have enough {app.config['COINS_NAME']}"}, 400
if amount < 100: return {"error": f"You have to gift at least 100 {app.config['COINS_NAME']}."}, 400
tax = math.ceil(amount*0.03)
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first()
tax_receiver.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(TAX_RECEIVER_ID, log_message)
g.db.add(tax_receiver)
if not v.patron and not receiver.patron:
tax = math.ceil(amount*0.03)
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first()
tax_receiver.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(TAX_RECEIVER_ID, log_message)
g.db.add(tax_receiver)
if request.host == 'rdrama.net':
carp = g.db.query(User).filter_by(id=CARP_ID).first()
carp.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(CARP_ID, log_message)
g.db.add(carp)
dad = g.db.query(User).filter_by(id=DAD_ID).first()
dad.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(DAD_ID, log_message)
g.db.add(dad)
if request.host == 'rdrama.net':
carp = g.db.query(User).filter_by(id=CARP_ID).first()
carp.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(CARP_ID, log_message)
g.db.add(carp)
dad = g.db.query(User).filter_by(id=DAD_ID).first()
dad.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(DAD_ID, log_message)
g.db.add(dad)
else: tax = 0
receiver.coins += amount-tax
v.coins -= amount

View File

@ -15,7 +15,33 @@
}
</style>
<script src="/assets/js/userpage.js?v=59"></script>
<script src="/assets/js/userpage.js?v=60"></script>
{% if v and not v.patron %}
<script>
const TRANSFER_TAX = 0.03;
function updateTax(mobile=false) {
let suf = mobile ? "-mobile" : "";
let amount = parseInt(document.getElementById("coins-transfer-amount" + suf).value);
if(isNaN(amount) || amount < 0) {
amount = 0;
}
document.getElementById("coins-transfer-taxed" + suf).innerText = amount - Math.ceil(amount*TRANSFER_TAX);
}
function toggleElement(group, id) {
for(let el of document.getElementsByClassName(group)) {
if(el.id != id) {
el.classList.add('d-none');
}
}
document.getElementById(id).classList.toggle('d-none');
}
</script>
{% endif %}
<title>{{u.username}}'s profile - {{'SITE_NAME' | app_config}}</title>
{% if u.is_private %}
<meta name="robots" content="noindex">