2023-06-23 18:08:10 +00:00
import string
2022-11-15 09:19:08 +00:00
from copy import deepcopy
from flask import g , request
from sqlalchemy import func
from files . classes . award import AwardRelationship
from files . classes . userblock import UserBlock
from files . helpers . actions import *
2022-09-19 17:10:52 +00:00
from files . helpers . alerts import *
2022-12-11 23:44:34 +00:00
from files . helpers . config . const import *
2023-09-22 17:01:30 +00:00
from files . helpers . slurs_and_profanities import censor_slurs_profanities
2023-09-28 23:58:09 +00:00
from files . helpers . config . awards import *
2022-11-15 09:19:08 +00:00
from files . helpers . get import *
2022-09-19 17:10:52 +00:00
from files . helpers . regex import *
2023-10-07 15:35:16 +00:00
from files . helpers . sanitize import *
2022-11-01 23:46:56 +00:00
from files . helpers . useractions import *
2022-11-15 09:19:08 +00:00
from files . routes . wrappers import *
2024-11-10 17:33:40 +00:00
from files . routes . routehelpers import *
2022-11-15 09:19:08 +00:00
from files . __main__ import app , cache , limiter
2022-09-19 17:10:52 +00:00
from . front import frontlist
2023-03-10 20:27:36 +00:00
@app.get ( " /shop " )
2023-07-13 13:50:46 +00:00
@limiter.limit ( DEFAULT_RATELIMIT , deduct_when = lambda response : response . status_code < 400 )
@limiter.limit ( DEFAULT_RATELIMIT , deduct_when = lambda response : response . status_code < 400 , key_func = get_ID )
2023-03-10 20:27:36 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def shop_awards ( v ) :
2023-03-10 20:27:36 +00:00
return redirect ( ' /shop/awards ' )
2023-02-19 09:34:10 +00:00
@app.get ( " /shop/awards " )
2023-07-13 13:50:46 +00:00
@limiter.limit ( DEFAULT_RATELIMIT , deduct_when = lambda response : response . status_code < 400 )
@limiter.limit ( DEFAULT_RATELIMIT , deduct_when = lambda response : response . status_code < 400 , key_func = get_ID )
2022-11-14 15:11:05 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def shop ( v ) :
2024-05-22 19:26:09 +00:00
AWARDS = deepcopy ( AWARDS_ENABLED ( v ) )
2022-09-19 17:10:52 +00:00
for val in AWARDS . values ( ) : val [ " owned " ] = 0
2023-08-05 19:26:42 +00:00
for useraward in g . db . query ( AwardRelationship ) . filter ( AwardRelationship . user_id == v . id , AwardRelationship . post_id == None , AwardRelationship . comment_id == None ) :
2022-09-19 17:10:52 +00:00
if useraward . kind in AWARDS : AWARDS [ useraward . kind ] [ " owned " ] + = 1
for val in AWARDS . values ( ) :
val [ " baseprice " ] = int ( val [ " price " ] )
2023-09-22 06:53:13 +00:00
val [ " price " ] = int ( val [ " price " ] * v . award_discount )
2024-10-23 12:31:47 +00:00
if v . house . endswith ( ' Founder ' ) and val [ " kind " ] in { " earlylife " , " rainbow " , " sharpen " , " owoify " , " bite " } :
val [ " price " ] = int ( val [ " price " ] * 0.75 )
2022-09-19 17:10:52 +00:00
2024-03-09 07:39:23 +00:00
sales = g . db . query ( func . sum ( User . currency_spent_on_awards ) ) . scalar ( )
2022-09-19 17:10:52 +00:00
return render_template ( " shop.html " , awards = list ( AWARDS . values ( ) ) , v = v , sales = sales )
2024-04-16 14:58:39 +00:00
def buy_awards ( v , kind , AWARDS , quantity ) :
2023-10-10 16:53:46 +00:00
og_price = AWARDS [ kind ] [ " price " ]
2023-09-22 06:53:13 +00:00
price = int ( og_price * v . award_discount )
2024-10-23 12:31:47 +00:00
if v . house . endswith ( ' Founder ' ) and kind in { " earlylife " , " rainbow " , " sharpen " , " owoify " , " bite " } :
price = int ( price * 0.75 )
2022-09-19 17:10:52 +00:00
2023-10-10 16:53:46 +00:00
if kind == " grass " :
2023-04-24 15:08:40 +00:00
currency = ' coins '
2023-10-10 16:53:46 +00:00
elif kind == " benefactor " :
2023-04-24 15:08:40 +00:00
currency = ' marseybux '
2022-09-19 17:10:52 +00:00
else :
2024-01-12 08:12:35 +00:00
currency = ' coins/marseybux '
2023-04-24 15:08:40 +00:00
2024-04-16 14:58:39 +00:00
if quantity == 1 :
s = " "
es = " "
else :
s = " s "
es = " es "
charged = v . charge_account ( currency , price * quantity , f " Cost of { quantity } { AWARDS [ kind ] [ ' title ' ] } award { s } " )
2024-03-09 07:39:23 +00:00
if not charged :
2024-08-11 20:11:04 +00:00
stop ( 400 , f " Not enough { currency } ! " )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
v . currency_spent_on_awards + = price * quantity
2024-03-09 07:39:23 +00:00
if v . currency_spent_on_awards > = 1000000 :
2023-05-02 17:28:47 +00:00
badge_grant ( badge_id = 73 , user = v )
2024-03-10 06:32:43 +00:00
if v . currency_spent_on_awards > = 500000 :
2023-05-02 17:28:47 +00:00
badge_grant ( badge_id = 72 , user = v )
2024-03-10 06:32:43 +00:00
if v . currency_spent_on_awards > = 250000 :
2023-05-02 17:28:47 +00:00
badge_grant ( badge_id = 71 , user = v )
2024-03-10 06:32:43 +00:00
if v . currency_spent_on_awards > = 100000 :
2023-05-02 17:28:47 +00:00
badge_grant ( badge_id = 70 , user = v )
2024-03-10 06:32:43 +00:00
if v . currency_spent_on_awards > = 10000 :
2023-05-02 17:28:47 +00:00
badge_grant ( badge_id = 69 , user = v )
g . db . add ( v )
2022-09-19 17:10:52 +00:00
2023-10-10 16:53:46 +00:00
if kind == " lootbox " :
2022-09-19 17:10:52 +00:00
lootbox_items = [ ]
2024-04-16 14:58:39 +00:00
for _ in range ( LOOTBOX_ITEM_COUNT * quantity ) : # five items per lootbox
2024-05-22 19:26:09 +00:00
LOOTBOX_CONTENTS = [ x [ " kind " ] for x in AWARDS_ENABLED ( v ) . values ( ) if x [ " included_in_lootbox " ] ]
2022-12-19 01:20:14 +00:00
lb_award = random . choice ( LOOTBOX_CONTENTS )
2022-10-07 21:00:37 +00:00
lootbox_items . append ( AWARDS [ lb_award ] [ ' title ' ] )
2024-07-21 21:38:05 +00:00
lb_award = AwardRelationship ( user_id = v . id , kind = lb_award , price_paid = 0 )
2023-03-16 06:27:58 +00:00
g . db . add ( lb_award )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
v . lootboxes_bought + = quantity
lootbox_msg = f " You open your lootbox { es } and receive: " + ' , ' . join ( lootbox_items )
2022-09-19 17:10:52 +00:00
send_repeatable_notification ( v . id , lootbox_msg )
2023-01-01 11:36:20 +00:00
2022-09-19 17:10:52 +00:00
if v . lootboxes_bought == 10 :
badge_grant ( badge_id = 76 , user = v )
elif v . lootboxes_bought == 50 :
badge_grant ( badge_id = 77 , user = v )
elif v . lootboxes_bought == 150 :
badge_grant ( badge_id = 78 , user = v )
2022-12-19 16:32:13 +00:00
return { " message " : lootbox_msg }
2022-09-19 17:10:52 +00:00
else :
2024-04-16 14:58:39 +00:00
award_objects = [ ]
for x in range ( quantity ) :
award_object = AwardRelationship ( user_id = v . id , kind = kind , price_paid = price )
g . db . add ( award_object )
award_objects . append ( award_object )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
if CARP_ID and v . id != CARP_ID and og_price > = 5000 :
award_title = AWARDS [ kind ] [ ' title ' ]
send_repeatable_notification ( CARP_ID , f " @ { v . username } has bought { quantity } ` { award_title } ` award { s } ! " )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
return award_objects
2023-10-10 16:53:46 +00:00
@app.post ( " /buy/<kind> " )
2024-04-20 15:00:35 +00:00
@limiter.limit ( ' 1/second ' , scope = rpath ) #Needed to fix race condition
@limiter.limit ( ' 1/second ' , scope = rpath , key_func = get_ID ) #Needed to fix race condition
2024-07-10 07:36:21 +00:00
@limiter.limit ( " 100/minute;400/hour;1000/day " , deduct_when = lambda response : response . status_code < 400 )
@limiter.limit ( " 100/minute;400/hour;1000/day " , deduct_when = lambda response : response . status_code < 400 , key_func = get_ID )
2023-10-10 16:53:46 +00:00
@auth_required
def buy ( v , kind ) :
2024-05-22 19:26:09 +00:00
AWARDS = deepcopy ( AWARDS_ENABLED ( v ) )
2023-10-10 16:53:46 +00:00
2024-08-11 20:11:04 +00:00
if kind not in AWARDS : stop ( 400 )
2023-10-10 16:53:46 +00:00
award_title = AWARDS [ kind ] [ ' title ' ]
2024-04-16 14:58:39 +00:00
award = buy_awards ( v , kind , AWARDS , 1 )
2023-10-12 13:41:23 +00:00
if isinstance ( award , dict ) :
return award
2022-09-19 17:10:52 +00:00
2022-10-07 21:00:37 +00:00
return { " message " : f " { award_title } award bought! " }
2022-09-19 17:10:52 +00:00
2023-10-29 12:09:50 +00:00
def alter_body ( obj ) :
2024-07-03 14:18:31 +00:00
obj . body_html = sanitize ( obj . body , limit_pings = 5 , obj = obj , author = obj . author )
2023-10-29 12:09:50 +00:00
if isinstance ( obj , Post ) :
2024-03-02 21:01:29 +00:00
obj . title_html = filter_emojis_only ( obj . title , golden = False , obj = obj , author = obj . author )
2023-10-15 13:38:42 +00:00
2022-12-29 10:39:10 +00:00
@app.post ( " /award/<thing_type>/<int:id> " )
2024-04-20 15:00:35 +00:00
@limiter.limit ( ' 1/second ' , scope = rpath ) #Needed to fix race condition
@limiter.limit ( ' 1/second ' , scope = rpath , key_func = get_ID ) #Needed to fix race condition
2023-07-13 13:50:46 +00:00
@limiter.limit ( DEFAULT_RATELIMIT , deduct_when = lambda response : response . status_code < 400 )
@limiter.limit ( DEFAULT_RATELIMIT , deduct_when = lambda response : response . status_code < 400 , key_func = get_ID )
2023-09-14 16:49:46 +00:00
@auth_required
2022-09-19 17:10:52 +00:00
def award_thing ( v , thing_type , id ) :
2022-12-19 16:32:13 +00:00
kind = request . values . get ( " kind " , " " ) . strip ( )
2023-01-01 11:36:20 +00:00
if thing_type == ' post ' :
2023-10-29 12:09:50 +00:00
obj = get_post ( id )
2023-10-13 22:23:18 +00:00
elif thing_type == ' comment ' :
2023-10-29 12:09:50 +00:00
obj = get_comment ( id )
2024-08-11 20:11:04 +00:00
if not obj . parent_post and not obj . wall_user_id : stop ( 404 ) # don't let users award messages
2023-10-13 22:23:18 +00:00
else :
2024-08-11 20:11:04 +00:00
stop ( 400 )
2022-09-19 17:10:52 +00:00
2023-10-29 12:09:50 +00:00
author = obj . author
2023-01-01 11:36:20 +00:00
2024-05-22 19:26:09 +00:00
AWARDS = deepcopy ( AWARDS_ENABLED ( v ) )
2022-09-19 17:10:52 +00:00
2024-03-30 20:19:25 +00:00
if kind not in AWARDS :
2024-08-11 20:11:04 +00:00
stop ( 404 , " This award doesn ' t exist. " )
2024-04-05 09:40:26 +00:00
if kind == " grass " and v . id == author . id :
2024-08-11 20:11:04 +00:00
stop ( 403 , " You can ' t grass yourself. " )
2022-09-19 17:10:52 +00:00
2023-10-08 22:42:05 +00:00
award_title = AWARDS [ kind ] [ ' title ' ]
2024-04-16 14:58:39 +00:00
quantity = int ( request . values . get ( " quantity " , " 1 " ) . strip ( ) or 1 )
if quantity < 1 or quantity > 30 :
quantity = 1
if quantity == 1 :
s = " "
it = " it "
was = " was "
has = " has "
else :
s = " s "
it = " they "
was = " were "
has = " have "
2024-03-30 20:19:25 +00:00
if v . shadowbanned :
2024-04-16 14:58:39 +00:00
return { " message " : f " { quantity } { award_title } award { s } given to { thing_type } successfully! " }
2024-03-30 20:19:25 +00:00
2024-05-22 19:26:09 +00:00
if obj . is_longpost and kind in { " ectoplasm " , " candycorn " , " candycane " , " stab " , " glowie " , " tilt " , " queen " , " chud " , " marsify " , " owoify " , " sharpen " , " rainbow " } :
2024-11-07 11:29:06 +00:00
stop ( 403 , f ' Long posts and comments are immune to the { award_title } award! ' )
2024-10-19 04:12:50 +00:00
2024-11-07 11:30:39 +00:00
if obj . distinguished and ( AWARDS [ kind ] [ ' cosmetic ' ] or AWARDS [ kind ] [ ' negative ' ] ) :
stop ( 403 , ' Distinguished posts and comments are immune to cosmetic and negative awards! ' )
2024-02-18 22:35:54 +00:00
2024-04-16 14:58:39 +00:00
note = request . values . get ( " note " , " " ) . strip ( )
if len ( note ) > 200 :
2024-08-11 20:11:04 +00:00
stop ( 400 , " Award note is too long (max 200 characters) " )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
safe_username = f " @ { obj . author_name } is "
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
if AWARDS [ kind ] [ ' negative ' ] and author . immune_to_negative_awards ( v ) :
if author . new_user and not author . alts :
2024-08-11 20:11:04 +00:00
stop ( 403 , " New users are immune to negative awards! " )
stop ( 403 , f " { safe_username } immune to negative awards! " )
2024-01-02 18:54:08 +00:00
2024-04-16 14:58:39 +00:00
if isinstance ( obj , Post ) and obj . id == 210983 :
2024-08-11 20:11:04 +00:00
stop ( 403 , " You can ' t award this post! " )
2024-01-02 18:54:08 +00:00
2024-04-16 14:58:39 +00:00
if kind == " benefactor " :
if author . id == v . id :
2024-08-11 20:11:04 +00:00
stop ( 403 , " You can ' t use this award on yourself! " )
2024-04-16 14:58:39 +00:00
if author . id in get_alt_graph_ids ( v . id ) :
2024-08-11 20:11:04 +00:00
stop ( 403 , " You can ' t use this award on your alts! " )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
if obj . ghost and not AWARDS [ kind ] [ ' ghost ' ] :
2024-08-11 20:11:04 +00:00
stop ( 403 , " This kind of award can ' t be used on ghost posts! " )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
if kind == ' marsify ' and author . marsify == 1 :
2024-08-11 20:11:04 +00:00
stop ( 409 , f " { safe_username } already permanently marsified! " )
2023-10-11 13:50:15 +00:00
2024-04-16 14:58:39 +00:00
if kind == ' spider ' and author . spider == 1 :
2024-08-11 20:11:04 +00:00
stop ( 409 , f " { safe_username } already best friends with a spider! " )
2023-10-20 15:56:26 +00:00
2024-04-17 20:18:36 +00:00
awards = g . db . query ( AwardRelationship ) . filter (
AwardRelationship . kind == kind ,
AwardRelationship . user_id == v . id ,
AwardRelationship . post_id == None ,
AwardRelationship . comment_id == None
) . order_by ( AwardRelationship . id ) . limit ( quantity ) . all ( )
num_owned = len ( awards )
2022-09-19 17:10:52 +00:00
2024-04-17 20:18:36 +00:00
if quantity > num_owned :
bought = buy_awards ( v , kind , AWARDS , quantity - num_owned )
if isinstance ( bought , dict ) :
return bought
awards . extend ( bought )
2022-11-09 23:06:36 +00:00
2024-10-01 16:36:07 +00:00
if v . id == author . id and kind == " zombiebite " :
stop ( 403 , " You can ' t bite yourself! " )
2024-11-12 10:24:12 +00:00
for award in awards :
if isinstance ( obj , Post ) : award . post_id = obj . id
else : award . comment_id = obj . id
award . awarded_utc = int ( time . time ( ) )
award . note = note
g . db . add ( award )
2024-11-13 16:52:33 +00:00
if note :
msg_note = ' \n \n > ' + ' \n \n > ' . join ( note . splitlines ( ) )
2024-04-16 14:58:39 +00:00
if v . id != author . id :
2024-10-17 00:30:33 +00:00
if author . deflector and v . deflector and AWARDS [ kind ] [ ' deflectable ' ] and v . admin_level < PERMS [ ' IMMUNE_TO_DEFLECTIONS ' ] :
2024-04-16 14:58:39 +00:00
msg = f " @ { v . username } has tried to give { obj . textlink } { quantity } { award_title } award { s } but { it } { was } deflected on them, they also had a deflector up, so { it } bounced back and forth until { it } vaporized! "
2024-11-13 16:52:33 +00:00
if note :
msg + = msg_note
2024-04-16 14:58:39 +00:00
send_repeatable_notification ( author . id , msg )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
msg = f " { safe_username } under the effect of a deflector award; your { award_title } award { s } { has } been deflected back to you but your deflector protected you, the award { s } bounced back and forth until { it } vaporized! "
send_repeatable_notification ( v . id , msg )
2022-09-19 17:10:52 +00:00
2024-04-16 14:58:39 +00:00
return { " message " : f " { quantity } { award_title } award { s } given to { thing_type } successfully! " }
2022-09-19 17:10:52 +00:00
2024-10-17 00:34:46 +00:00
if author . deflector and AWARDS [ kind ] [ ' deflectable ' ] and v . admin_level < PERMS [ ' IMMUNE_TO_DEFLECTIONS ' ] :
2024-04-16 14:58:39 +00:00
author = v
safe_username = f " Your award { s } { has } been deflected but failed since you ' re "
2023-10-04 10:18:08 +00:00
2024-04-16 14:58:39 +00:00
if kind == ' shit ' :
2024-07-21 21:38:05 +00:00
not_from_lootbox_quantity = len ( [ award for award in awards if award . price_paid ] )
awarded_coins = int ( AWARDS [ kind ] [ ' price ' ] * COSMETIC_AWARD_COIN_AWARD_PCT ) * not_from_lootbox_quantity
2024-04-16 14:58:39 +00:00
v . charge_account ( ' coins ' , awarded_coins , f " { quantity } deflected Shit award { s } on { obj . textlink } " , should_check_balance = False )
2024-04-20 14:44:15 +00:00
obj . author . pay_account ( ' coins ' , awarded_coins , f " { quantity } deflected Shit award { s } on { obj . textlink } " )
2024-04-16 14:58:39 +00:00
elif kind != ' spider ' :
2024-07-21 21:38:05 +00:00
not_from_lootbox_quantity = len ( [ award for award in awards if award . price_paid ] )
if AWARDS [ kind ] [ ' cosmetic ' ] :
awarded_coins = int ( AWARDS [ kind ] [ ' price ' ] * COSMETIC_AWARD_COIN_AWARD_PCT ) * not_from_lootbox_quantity
2024-04-16 14:58:39 +00:00
else :
awarded_coins = 0
2023-04-25 07:26:55 +00:00
2024-04-16 14:58:39 +00:00
if awarded_coins :
2023-10-10 15:11:32 +00:00
if kind == ' shit ' :
2024-04-16 14:58:39 +00:00
author . charge_account ( ' coins ' , awarded_coins , f " { quantity } Shit award { s } on { obj . textlink } " , should_check_balance = False )
v . pay_account ( ' coins ' , awarded_coins , f " { quantity } Shit award { s } on { obj . textlink } " )
2023-10-10 15:11:32 +00:00
else :
2024-04-16 14:58:39 +00:00
author . pay_account ( ' coins ' , awarded_coins , f " { quantity } { award_title } award { s } on { obj . textlink } " )
2024-04-12 11:08:03 +00:00
2024-04-16 14:58:39 +00:00
can_alter_body = not obj . author . deflector or v == obj . author
2024-04-16 21:33:29 +00:00
if kind in { " ban " , " grass " } :
2024-05-23 00:29:24 +00:00
if author . is_suspended and author . ban_reason . startswith ( ' Grass award used by @ ' ) :
2024-08-11 20:11:04 +00:00
stop ( 400 , f " You can ' t give a { kind } award to an already-grassed user! " )
2024-05-23 00:29:24 +00:00
2024-04-16 21:33:29 +00:00
ban_reason_link = f " / { thing_type } / { obj . id } "
if isinstance ( obj , Comment ) :
ban_reason_link + = ' #context '
2024-11-10 17:33:21 +00:00
ban_reason = f ' { award_title } award { s } used by <a href= " /id/ { v . id } " >@ { v . username } </a> on <a href= " { ban_reason_link } " > { ban_reason_link } </a> '
2024-04-16 21:33:29 +00:00
author . ban_reason = ban_reason
2024-04-17 20:45:29 +00:00
if kind == " pause " :
if author . has_badge ( 68 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( badge_id = 68 , user = author )
elif kind == " unpausable " :
if author . has_badge ( 67 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( badge_id = 67 , user = author )
elif kind == " eye " :
if author . has_badge ( 83 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( badge_id = 83 , user = author )
elif kind == " offsitementions " :
if author . has_badge ( 140 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
author . offsite_mentions = True
badge_grant ( user = author , badge_id = 140 )
elif kind == " alt " :
if author . has_badge ( 84 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( badge_id = 84 , user = author )
elif kind == " unblockable " :
if author . has_badge ( 87 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( badge_id = 87 , user = author )
blocks = g . db . query ( UserBlock ) . filter (
or_ (
UserBlock . user_id == author . id ,
UserBlock . target_id == author . id ,
)
)
for block in blocks :
g . db . delete ( block )
elif kind == " beano " :
if author . has_badge ( 128 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( user = author , badge_id = 128 )
elif kind == " checkmark " :
if author . has_badge ( 150 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
author . verified = " Verified "
badge_grant ( user = author , badge_id = 150 )
2024-07-22 19:21:41 +00:00
elif kind == " pride " :
2024-04-17 20:45:29 +00:00
if author . has_badge ( 303 ) :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
badge_grant ( user = author , badge_id = 303 )
elif kind == " grinch " :
if author . grinch :
2024-10-02 18:46:17 +00:00
stop ( 409 , f " @ { obj . author_name } already has this profile upgrade! " )
2024-04-17 20:45:29 +00:00
author . grinch = True
if v . id == author . id :
session [ ' event_music ' ] = False
elif kind == " emoji " :
2024-04-16 14:58:39 +00:00
emoji_behavior = request . values . get ( " emoji_behavior " ) . strip ( )
for award in awards :
award . note = award . note . strip ( " : " ) . lower ( )
if emoji_behavior == " horizontal " :
award . kind = " emoji-hz "
emoji = g . db . query ( Emoji ) . filter_by ( name = award . note ) . one_or_none ( )
if not emoji :
2024-08-11 20:11:04 +00:00
stop ( 404 , f ' an Emoji with the name " { award . note } " was not found! ' )
2024-04-16 21:10:14 +00:00
elif kind == " ban " :
2024-10-21 20:31:51 +00:00
if author . is_permabanned :
stop ( 400 , f " { safe_username } already permabanned! " )
author . ban ( reason = ban_reason , days = quantity , modlog = False )
2024-11-10 17:33:40 +00:00
text = f " Your account has been banned for ** { quantity } day { s } ** for { obj . textlink } . It sucked and you should feel bad. "
send_repeatable_notification ( author . id , text )
if SITE_NAME == ' WPD ' :
for x in get_alt_graph ( author . id ) :
x . ban ( reason = ban_reason , days = quantity , modlog = False , original_user = author )
one_month_ago = time . time ( ) - 2592000
if x . last_active > one_month_ago :
send_repeatable_notification ( x . id , text )
2024-04-16 21:10:14 +00:00
elif kind == " unban " :
2024-11-10 18:30:18 +00:00
if not author . is_suspended or not author . unban_utc or not author . ban_reason . startswith ( ' Ban award ' ) :
2024-08-11 20:11:04 +00:00
stop ( 400 , " You can only use unban awards to undo the effect of ban awards! " )
2024-04-16 21:10:14 +00:00
if author . unban_utc - time . time ( ) > 86400 * quantity :
author . unban_utc - = 86400 * quantity
send_repeatable_notification ( author . id , f " Your ban duration has been reduced by { quantity } day { s } ! " )
else :
author . unban_utc = None
author . is_banned = None
author . ban_reason = None
send_repeatable_notification ( author . id , " You have been unbanned! " )
2024-11-10 18:28:55 +00:00
if SITE_NAME == ' WPD ' :
for x in get_alt_graph ( author . id ) :
2024-11-10 18:30:18 +00:00
if not x . is_suspended or not x . unban_utc or not x . ban_reason . startswith ( ' Ban award ' ) :
2024-11-10 18:28:55 +00:00
continue
if x . unban_utc - time . time ( ) > 86400 * quantity :
x . unban_utc - = 86400 * quantity
one_month_ago = time . time ( ) - 2592000
if x . last_active > one_month_ago :
send_repeatable_notification ( x . id , f " Your ban duration has been reduced by { quantity } day { s } ! " )
else :
x . unban_utc = None
x . is_banned = None
x . ban_reason = None
one_month_ago = time . time ( ) - 2592000
if x . last_active > one_month_ago :
send_repeatable_notification ( x . id , " You have been unbanned! " )
2024-04-16 21:10:14 +00:00
elif kind == " grass " :
new_unban_utc = int ( time . time ( ) ) + 30 * 86400 * quantity
if author . is_banned and ( not author . unban_utc or author . unban_utc > new_unban_utc ) :
2024-08-11 20:11:04 +00:00
stop ( 403 , f " { safe_username } already banned for more than 30 days! " )
2024-10-21 20:32:28 +00:00
author . ban ( reason = ban_reason , days = 30 , modlog = False )
2024-04-16 21:10:14 +00:00
send_repeatable_notification ( author . id , f " @ { v . username } gave you { quantity } grass award { s } on { obj . textlink } and as a result you have been banned! You must [send the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned! " )
2024-04-17 20:45:29 +00:00
elif kind == " hieroglyphs " :
if author . hieroglyphs : author . hieroglyphs + = 86400 * quantity
else : author . hieroglyphs = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 98 )
elif kind == " progressivestack " :
if not FEATURES [ ' PINS ' ] :
2024-08-11 20:11:04 +00:00
stop ( 403 )
2024-04-16 14:58:39 +00:00
2024-04-17 20:45:29 +00:00
if author . progressivestack != 1 :
if author . progressivestack : author . progressivestack + = 21600 * quantity
else : author . progressivestack = int ( time . time ( ) ) + 21600 * quantity
badge_grant ( user = author , badge_id = 94 )
elif kind == " benefactor " :
if not author . patron :
author . patron = 1
if author . patron_utc : author . patron_utc + = 2629746 * quantity
else : author . patron_utc = int ( time . time ( ) ) + 2629746 * quantity
author . pay_account ( ' marseybux ' , 1250 * quantity , f " Benefactor award on { obj . textlink } " )
badge_grant ( user = v , badge_id = 103 )
elif kind == " rehab " :
if author . rehab : author . rehab + = 86400 * quantity
else : author . rehab = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 109 )
elif kind == " deflector " :
2024-08-23 11:35:13 +00:00
if author . id in IMMUNE_TO_NEGATIVE_AWARDS :
stop ( 400 , f " { safe_username } immune to negative awards! " )
2024-04-17 20:45:29 +00:00
if author . deflector : author . deflector + = 36000 * quantity
else : author . deflector = int ( time . time ( ) ) + 36000 * quantity
elif kind == ' marsify ' :
if not author . marsify or author . marsify != 1 :
if author . marsify : author . marsify + = 86400 * quantity
else : author . marsify = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 170 )
if can_alter_body :
alter_body ( obj )
2024-05-22 19:48:03 +00:00
elif kind == " bite " :
2024-07-08 09:09:40 +00:00
if author . bite : author . bite + = 86400 * quantity
2024-04-17 20:45:29 +00:00
else :
if author . house . startswith ( " Vampire " ) :
2024-08-11 20:11:04 +00:00
stop ( 400 , f " { safe_username } already a permanent vampire! " )
2024-04-17 20:45:29 +00:00
2024-07-08 09:09:40 +00:00
author . bite = int ( time . time ( ) ) + 86400 * quantity
2024-04-17 20:45:29 +00:00
author . old_house = author . house
author . house = " Vampire "
badge_grant ( user = author , badge_id = 168 )
2024-05-22 19:26:09 +00:00
elif kind == " earlylife " :
2024-08-10 16:47:35 +00:00
if author . earlylife : author . earlylife + = 21600 * quantity
else : author . earlylife = int ( time . time ( ) ) + 21600 * quantity
2024-04-17 20:45:29 +00:00
badge_grant ( user = author , badge_id = 169 )
2024-05-22 19:26:09 +00:00
elif kind == " owoify " :
2024-04-17 20:45:29 +00:00
if author . owoify : author . owoify + = 21600 * quantity
else : author . owoify = int ( time . time ( ) ) + 21600 * quantity
badge_grant ( user = author , badge_id = 167 )
if can_alter_body :
alter_body ( obj )
2024-05-22 19:26:09 +00:00
elif kind == " sharpen " :
2024-04-17 20:45:29 +00:00
if author . sharpen : author . sharpen + = 86400 * quantity
else : author . sharpen = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 289 )
if can_alter_body :
obj . sharpened = True
alter_body ( obj )
2024-05-22 19:26:09 +00:00
elif kind == " rainbow " :
2024-04-17 20:45:29 +00:00
if author . rainbow : author . rainbow + = 86400 * quantity
else : author . rainbow = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 171 )
if can_alter_body :
obj . rainbowed = True
elif kind == " gold " :
if obj . award_count ( ' glowie ' , v ) :
2024-08-11 20:11:04 +00:00
stop ( 409 , f " This { thing_type } is under the effect of a conflicting award: Glowie award! " )
2024-04-17 20:45:29 +00:00
elif kind == " glowie " :
if obj . award_count ( ' gold ' , v ) :
2024-08-11 20:11:04 +00:00
stop ( 409 , f " This { thing_type } is under the effect of a conflicting award: Gold award! " )
2024-04-17 20:45:29 +00:00
elif kind == " spider " :
if author . spider : author . spider + = 86400 * quantity
else : author . spider = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 179 , notify = False )
2024-10-21 17:13:53 +00:00
elif kind in { " pin " , " gigapin " } :
2024-08-11 20:11:04 +00:00
if not FEATURES [ ' PINS ' ] : stop ( 403 )
2024-11-12 10:17:49 +00:00
if obj . is_banned :
stop ( 403 , f " You can ' t give a { kind } award to a removed { thing_type } ! " )
2024-04-17 20:45:29 +00:00
if obj . pinned and not obj . pinned_utc :
2024-08-11 20:11:04 +00:00
stop ( 400 , f " This { thing_type } is already pinned permanently! " )
2024-04-17 20:45:29 +00:00
2024-08-17 22:33:31 +00:00
if SITE_NAME == ' WPD ' and isinstance ( obj , Comment ) and not obj . parent_post :
2024-08-17 17:48:29 +00:00
stop ( 400 , " You can ' t pin wall comments! " )
2024-04-17 20:45:29 +00:00
if isinstance ( obj , Comment ) : add = 3600 * 6 * quantity
else : add = 3600 * quantity
2024-10-21 17:13:53 +00:00
if kind == " gigapin " :
add * = 12
2024-04-17 20:45:29 +00:00
if obj . pinned_utc :
obj . pinned_utc + = add
else :
obj . pinned_utc = int ( time . time ( ) ) + add
if isinstance ( obj , Comment ) :
obj . pin_parents ( )
obj . pinned = f ' { v . username } { PIN_AWARD_TEXT } '
if isinstance ( obj , Post ) :
cache . delete_memoized ( frontlist )
elif kind == " unpin " :
2024-11-12 10:17:04 +00:00
if not obj . pinned_utc :
stop ( 400 , f " This { thing_type } is not pinned! " )
2024-04-17 20:45:29 +00:00
if not obj . author . deflector or v == obj . author :
if isinstance ( obj , Comment ) :
t = obj . pinned_utc - 3600 * 6 * quantity
else :
t = obj . pinned_utc - 3600 * quantity
2024-04-16 14:58:39 +00:00
2024-04-17 20:45:29 +00:00
if time . time ( ) > t :
obj . pinned = None
obj . pinned_utc = None
if isinstance ( obj , Post ) :
cache . delete_memoized ( frontlist )
else :
obj . unpin_parents ( )
else : obj . pinned_utc = t
elif kind == " queen " :
2024-11-15 14:36:55 +00:00
if author . username . startswith ( ' deleted~ ' ) :
stop ( 403 , " Recipient account is deleted! " )
2024-04-17 20:45:29 +00:00
if not author . queen :
characters = list ( filter ( str . isalpha , author . username ) )
if characters :
first_character = characters [ 0 ] . upper ( )
else :
first_character = random . choice ( string . ascii_letters ) . upper ( )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
available_names = GIRL_NAMES [ first_character ]
random . shuffle ( available_names )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
broken = False
for new_name in available_names :
existing = get_user ( new_name , graceful = True )
if not existing :
broken = True
break
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if not broken :
new_name = new_name + f ' - { author . id } '
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if not author . prelock_username :
author . prelock_username = author . username
author . username = new_name
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if author . queen and time . time ( ) < author . queen : author . queen + = 86400 * quantity
else : author . queen = int ( time . time ( ) ) + 86400 * quantity
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
author . namechanged = author . queen
2023-10-26 20:08:29 +00:00
2024-04-17 20:45:29 +00:00
badge_grant ( user = author , badge_id = 285 )
2023-12-01 19:31:45 +00:00
2024-04-17 20:45:29 +00:00
if can_alter_body :
obj . queened = True
alter_body ( obj )
elif kind == " chud " :
if isinstance ( obj , Post ) and obj . hole == ' chudrama ' \
or isinstance ( obj , Comment ) and obj . post and obj . post . hole == ' chudrama ' :
2024-08-11 20:11:04 +00:00
stop ( 403 , " You can ' t give the chud award in /h/chudrama " )
2023-12-01 19:31:45 +00:00
2024-04-17 20:45:29 +00:00
if author . chud == 1 :
2024-08-11 20:11:04 +00:00
stop ( 409 , f " { safe_username } already permanently chudded! " )
2023-10-04 13:05:43 +00:00
2024-04-17 20:45:29 +00:00
if author . chud and time . time ( ) < author . chud : author . chud + = 86400 * quantity
else : author . chud = int ( time . time ( ) ) + 86400 * quantity
2022-12-20 01:13:34 +00:00
2024-08-11 20:11:04 +00:00
if not note : stop ( 400 , " Missing phrase! " )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if note not in CHUD_PHRASES :
2024-08-11 20:11:04 +00:00
stop ( 400 , " Invalid phrase! " )
2024-04-12 11:08:03 +00:00
2024-07-21 18:53:47 +00:00
author . chud_phrase = note
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
badge_grant ( user = author , badge_id = 58 )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if can_alter_body :
obj . chudded = True
complies_with_chud ( obj )
elif kind == " flairlock " :
2024-11-15 14:36:55 +00:00
if author . username . startswith ( ' deleted~ ' ) :
stop ( 403 , " Recipient account is deleted! " )
2024-04-17 20:45:29 +00:00
new_flair = note
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if len ( new_flair ) > 100 :
2024-08-11 20:11:04 +00:00
stop ( 400 , " New flair is too long (max 100 characters) " )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if not new_flair and author . flairchanged :
author . flairchanged + = 86400 * quantity
else :
author . flair = new_flair
new_flair = filter_emojis_only ( new_flair , link = True )
new_flair = censor_slurs_profanities ( new_flair , None )
2024-08-11 20:11:04 +00:00
if len ( new_flair ) > 1000 : stop ( 403 )
2024-04-17 20:45:29 +00:00
author . flair_html = new_flair
author . flairchanged = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 96 )
elif kind == " namelock " :
2024-11-14 18:17:17 +00:00
if author . username . startswith ( ' deleted~ ' ) :
stop ( 403 , " Recipient account is deleted! " )
2024-09-02 18:46:40 +00:00
new_name = note . strip ( ) . lstrip ( ' @ ' ) . strip ( )
2024-04-17 20:45:29 +00:00
if author . namechanged and ( not new_name or new_name == author . username ) :
author . namechanged + = 86400 * quantity
else :
if not valid_username_regex . fullmatch ( new_name ) :
2024-08-11 20:11:04 +00:00
stop ( 400 , " You need to enter a valid username to change the recipient to. " )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if not execute_blackjack ( v , None , new_name , f ' namelock award attempt on @ { author . username } ' ) :
existing = get_user ( new_name , graceful = True )
if existing and existing . id != author . id :
2024-08-11 20:11:04 +00:00
stop ( 400 , f " @ { new_name } is already taken! " )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
if not author . prelock_username :
author . prelock_username = author . username
author . username = new_name
author . namechanged = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 281 )
elif kind == " pizzashill " :
if author . bird :
author . bird = 0
badge = author . has_badge ( 95 )
if badge : g . db . delete ( badge )
else :
if author . longpost : author . longpost + = 86400 * quantity
else : author . longpost = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 97 )
elif kind == " bird " :
if author . longpost :
author . longpost = 0
badge = author . has_badge ( 97 )
if badge : g . db . delete ( badge )
else :
if author . bird : author . bird + = 86400 * quantity
else : author . bird = int ( time . time ( ) ) + 86400 * quantity
badge_grant ( user = author , badge_id = 95 )
elif kind == " jumpscare " :
author . jumpscare + = 1 * quantity
elif kind == " vax " :
2024-10-01 15:14:20 +00:00
if v . zombie < 0 :
stop ( 403 , " Zombies can ' t vaccinate others! " )
2024-04-17 20:45:29 +00:00
for award in awards :
g . db . flush ( )
if author . zombie < 0 :
author . zombie = 0
send_repeatable_notification ( author . id , " You are no longer **INFECTED**! Praise Fauci! " )
2024-04-12 11:08:03 +00:00
2024-04-17 20:45:29 +00:00
badge = author . has_badge ( 181 )
2024-04-12 11:08:03 +00:00
if badge : g . db . delete ( badge )
2024-04-17 20:45:29 +00:00
elif author . zombie > = 0 :
author . zombie + = 2
author . zombie = min ( author . zombie , 10 )
badge_grant ( user = author , badge_id = 182 )
2024-05-22 19:26:09 +00:00
elif kind == " zombiebite " :
2024-10-01 15:14:20 +00:00
if v . zombie > = 0 :
stop ( 403 , " Only zombies can bite others! " )
2024-04-17 20:45:29 +00:00
for award in awards :
g . db . flush ( )
2024-04-12 11:08:03 +00:00
if author . zombie < 0 :
author = v
if author . zombie == 0 :
author . zombie = - 1
badge_grant ( user = author , badge_id = 181 )
2024-10-06 14:39:17 +00:00
award_object = AwardRelationship ( user_id = author . id , kind = ' zombiebite ' )
2024-04-12 11:08:03 +00:00
g . db . add ( award_object )
send_repeatable_notification ( author . id ,
" As the zombie virus washes over your mind, you feel the urge "
" to… BITE YUMMY BRAINS :marseyzombie:<br> "
" You receive a free **Zombie Bite** award: pass it on! " )
elif author . zombie > 0 :
author . zombie - = 1
if author . zombie == 0 :
send_repeatable_notification ( author . id , " You are no longer **VAXXMAXXED**! Time for another booster! " )
badge = author . has_badge ( 182 )
if badge : g . db . delete ( badge )
2024-04-16 16:16:52 +00:00
2024-04-16 14:58:39 +00:00
author = obj . author
if v . id != author . id :
2024-10-17 00:30:33 +00:00
if author . deflector and AWARDS [ kind ] [ ' deflectable ' ] and v . admin_level < PERMS [ ' IMMUNE_TO_DEFLECTIONS ' ] :
2024-04-16 14:58:39 +00:00
msg = f " @ { v . username } has tried to give { obj . textlink } { quantity } { award_title } award { s } but { it } { was } deflected and applied to them :marseytroll: "
2024-11-13 16:52:33 +00:00
if note :
msg + = msg_note
2024-04-16 14:58:39 +00:00
n = send_repeatable_notification ( author . id , msg )
if n : n . created_utc - = 2
msg = f " @ { obj . author_name } is under the effect of a deflector award; your { award_title } award { s } { has } been deflected back to you :marseytroll: "
n = send_repeatable_notification ( v . id , msg )
if n : n . created_utc - = 2
elif kind not in { ' spider ' , ' jumpscare ' } :
msg = f " @ { v . username } has given { obj . textlink } { quantity } { award_title } award { s } "
if kind == ' shit ' :
msg + = f " and has stolen from you { awarded_coins } coins as a result "
elif awarded_coins :
msg + = f " and you have received { awarded_coins } coins as a result "
msg + = " ! "
if kind == ' emoji ' :
msg + = f " \n \n > : { award . note } : "
elif note :
if kind == " chud " :
2024-11-14 20:21:04 +00:00
msg + = f " \n \n **You now have to say this phrase in all posts and comments you make for { quantity } day { s } :** "
2024-11-13 16:52:33 +00:00
msg + = msg_note
2024-08-11 21:31:38 +00:00
if SITE_NAME == ' rDrama ' and kind == " chud " :
msg + = f " \n \n Please keep your chud behavior to /h/chudrama in the future! "
2024-04-16 14:58:39 +00:00
n = send_repeatable_notification ( author . id , msg )
if n : n . created_utc - = 2
if author . received_award_count : author . received_award_count + = quantity
else : author . received_award_count = quantity
g . db . add ( author )
g . db . add ( obj )
return { " message " : f " { quantity } { award_title } award { s } given to { thing_type } successfully! " }
Add the "Misogynist" award to harass incels (#154)
Whazzup? This PR is the final solution to the incel problem. There's an old indian proverb that says: "never judge a man until you've walked two moons in his mocassins". In this case, it should be: "never judge a woman until you've walked 24 hrs in her high-heels".
The misogynist award is a comment-transforming award that "feminizes" comments. It does the following:
- makes text pink
- makes text lowercase
- removes "complicated" punctuation
- makes paragraphs into run-on sentences
- adds stereotypical girly remarks to the beginning or end of a paragraph.
For example:
INPUT
> What the fuck did you just fucking say about me, you little bitch? I'll have you know I graduated top of my class in the Navy Seals, and I've been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I'm the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You're fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that's just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little "clever" comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn't, you didn't, and now you're paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You're fucking dead, kiddo.
OUTPUT
> im literally screaming, what the fuck did you just fucking say about me, you little bitch? ill have you know i graduated top of my class in the navy seals, and ive been involved in numerous secret raids on al-quaeda, and i have over 300 confirmed kills, i am trained in gorilla warfare and im the top sniper in the entire us armed forces, you are nothing to me but just another target, i will wipe you the fuck out with precision the likes of which has never been seen before on this earth, mark my fucking words, you think you can get away with saying that shit to me over the internet? think again, fucker, as we speak i am contacting my secret network of spies across the usa and your ip is being traced right now so you better prepare for the storm, maggot, the storm that wipes out the pathetic little thing you call your life, youre fucking dead, kid, i can be anywhere, anytime, and i can kill you in over seven hundred ways, and thats just with my bare hands, not only am i extensively trained in unarmed combat, but i have access to the entire arsenal of the united states marine corps and i will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit, if only you could have known what unholy retribution your little clever comment was about to bring down upon you, maybe you would have held your fucking tongue, but you couldnt, you didnt, and now youre paying the price, you goddamn idiot, i will shit fury all over you and you will drown in it, youre fucking dead, kiddo
It also sets the user's pfp to a random white woman. Well, psuedorandom - it's based off of the user's id, so each user will only ever have one pfp assigned to them, which I think is nifty.
Finally, it changes the name of the user toa girly name.
There is one small problem with the PR, which is simply that I manually added a badge for testing purposes. If you like this PR, I will submit the badge throught the proper chanels and fix it.
![image](/attachments/641c7276-ffe4-4e69-b3e9-aec9f4f94191)
Co-authored-by: Chuck Sneed <sneed@formerlychucks.net>
Reviewed-on: https://fsdfsd.net/rDrama/rDrama/pulls/154
Co-authored-by: HeyMoon <heymoon@noreply.fsdfsd.net>
Co-committed-by: HeyMoon <heymoon@noreply.fsdfsd.net>
2023-06-21 12:36:07 +00:00
2023-11-18 17:20:03 +00:00
@app.post ( " /trick_or_treat " )
2024-10-21 15:26:27 +00:00
@limiter.limit ( " 1/hour " , deduct_when = lambda response : response . status_code < 400 )
@limiter.limit ( " 1/hour " , deduct_when = lambda response : response . status_code < 400 , key_func = get_ID )
2023-09-28 23:58:09 +00:00
@auth_required
def trick_or_treat ( v ) :
2023-10-12 18:46:22 +00:00
if v . client :
2024-08-11 20:11:04 +00:00
stop ( 403 , " Not allowed from the API " )
2023-10-12 18:46:22 +00:00
if not IS_HOMOWEEN ( ) :
2024-08-11 20:11:04 +00:00
stop ( 403 )
2023-09-28 23:58:09 +00:00
result = random . choice ( [ 0 , 1 ] )
if result == 0 :
message = " Trick! "
else :
2024-05-22 19:26:09 +00:00
choices = [ x [ " kind " ] for x in AWARDS_ENABLED ( v ) . values ( ) if x [ " included_in_lootbox " ] ]
2023-10-12 18:46:22 +00:00
award = random . choice ( choices )
2023-09-28 23:58:09 +00:00
award_object = AwardRelationship ( user_id = v . id , kind = award )
g . db . add ( award_object )
2024-05-22 19:26:09 +00:00
award_title = AWARDS_ENABLED ( v ) [ award ] [ ' title ' ]
2023-09-28 23:58:09 +00:00
message = f " Treat! You got a { award_title } award! "
return { " message " : f " { message } " , " result " : f " { result } " }
@app.post ( " /jumpscare " )
@auth_required
def execute_jumpscare ( v ) :
2023-10-12 18:46:22 +00:00
if v . client :
2024-08-11 20:11:04 +00:00
stop ( 403 , " Not allowed from the API " )
2023-10-12 18:46:22 +00:00
if not IS_HOMOWEEN ( ) :
2024-08-11 20:11:04 +00:00
stop ( 403 )
2023-10-12 18:46:22 +00:00
2023-09-28 23:58:09 +00:00
if v . jumpscare > 0 :
v . jumpscare - = 1
g . db . add ( v )
return { }