remotes/1693045480750635534/spooky-22
Aevann1 2021-12-14 23:08:18 +02:00
parent f3cf087e8e
commit de3b2fc3fb
4 changed files with 173 additions and 7 deletions

View File

@ -83,6 +83,8 @@ class User(Base):
oldreddit = Column(Boolean, default=True)
teddit = Column(Boolean)
nitter = Column(Boolean)
grinch = Column(Boolean)
grincheffect = Column(Boolean)
mute = Column(Boolean)
unmutable = Column(Boolean)
eye = Column(Boolean)
@ -281,6 +283,7 @@ class User(Base):
if not self.is_suspended: return None
return g.db.query(User).filter_by(id=self.is_banned).first()
@lazy
def has_badge(self, badge_id):
return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).first()
@ -413,14 +416,15 @@ class User(Base):
@lazy
def banner_url(self):
if self.bannerurl: return self.bannerurl
else: return f"https://{site}/assets/images/{site_name}/preview.webp?v=190"
else: return f"https://{site}/assets/images/{site_name}/preview.webp?v=200"
@property
@lazy
def profile_url(self):
if self.agendaposter: return f"https://{site}/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?v=190"
if self.grincheffect: return f"https://{site}/assets/images/grinch.webp?v=200"
if self.agendaposter: return f"https://{site}/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?v=200"
if self.profileurl: return self.profileurl
if "rama" in site: return f"https://{site}/assets/images/defaultpictures/{random.randint(1, 150)}.webp?v=190"
if "rama" in site: return f"https://{site}/assets/images/defaultpictures/{random.randint(1, 150)}.webp?v=200"
return f"https://{site}/assets/images/default-profile-pic.webp"
@property

View File

@ -674,6 +674,53 @@ AWARDS = {
}
AWARDS2 = {
"snow": {
"kind": "snow",
"title": "Snow",
"description": "???",
"icon": "fas fa-snowflake",
"color": "text-blue-200",
"price": 300
},
"gingerbread": {
"kind": "gingerbread",
"title": "Gingerbread",
"description": "???",
"icon": "fas fa-gingerbread-man",
"color": "",
"price": 300
},
"lights": {
"kind": "lights",
"title": "Lights",
"description": "???",
"icon": "fad fa-lights-holiday",
"color": "",
"price": 300
},
"candycane": {
"kind": "candycane",
"title": "Candy Cane",
"description": "???",
"icon": "fad fa-candy-cane",
"color": "",
"price": 400
},
"fireplace": {
"kind": "fireplace",
"title": "Fireplace",
"description": "???",
"icon": "fad fa-fireplace",
"color": "",
"price": 600
},
"grinch": {
"kind": "grinch",
"title": "Grinch",
"description": "???",
"icon": "fas fa-angry",
"color": "text-green-500",
},
"lootbox": {
"kind": "lootbox",
"title": "Lootstocking",

View File

@ -48,6 +48,58 @@ AWARDS3 = {
@auth_required
def shop(v):
AWARDS = {
"snow": {
"kind": "snow",
"title": "Snow",
"description": "???",
"icon": "fas fa-snowflake",
"color": "text-blue-200",
"owned": 0,
"price": 300
},
"gingerbread": {
"kind": "gingerbread",
"title": "Gingerbread",
"description": "???",
"icon": "fas fa-gingerbread-man",
"color": "",
"owned": 0,
"price": 300
},
"lights": {
"kind": "lights",
"title": "Lights",
"description": "???",
"icon": "fad fa-lights-holiday",
"color": "",
"owned": 0,
"price": 300
},
"candycane": {
"kind": "candycane",
"title": "Candy Cane",
"description": "???",
"icon": "fad fa-candy-cane",
"color": "",
"owned": 0,
"price": 400
},
"fireplace": {
"kind": "fireplace",
"title": "Fireplace",
"description": "???",
"icon": "fad fa-fireplace",
"color": "",
"owned": 0,
"price": 600
},
"grinch": {
"kind": "grinch",
"title": "Grinch",
"description": "???",
"icon": "fas fa-angry",
"color": "text-green-500",
},
"lootbox": {
"kind": "lootbox",
"title": "Lootstocking",
@ -255,6 +307,53 @@ def shop(v):
@validate_formkey
def buy(v, award):
AWARDS = {
"snow": {
"kind": "snow",
"title": "Snow",
"description": "???",
"icon": "fas fa-snowflake",
"color": "text-blue-200",
"price": 300
},
"gingerbread": {
"kind": "gingerbread",
"title": "Gingerbread",
"description": "???",
"icon": "fas fa-gingerbread-man",
"color": "",
"price": 300
},
"lights": {
"kind": "lights",
"title": "Lights",
"description": "???",
"icon": "fad fa-lights-holiday",
"color": "",
"price": 300
},
"candycane": {
"kind": "candycane",
"title": "Candy Cane",
"description": "???",
"icon": "fad fa-candy-cane",
"color": "",
"price": 400
},
"fireplace": {
"kind": "fireplace",
"title": "Fireplace",
"description": "???",
"icon": "fad fa-fireplace",
"color": "",
"price": 600
},
"grinch": {
"kind": "grinch",
"title": "Grinch",
"description": "???",
"icon": "fas fa-angry",
"color": "text-green-500",
},
"lootbox": {
"kind": "lootbox",
"title": "Lootstocking",
@ -645,6 +744,12 @@ def award_post(pid, v):
if not author.has_badge(90):
new_badge = Badge(badge_id=90, user_id=author.id)
g.db.add(new_badge)
elif kind == "grinch":
author.grinch = True
send_notification(CARP_ID, f"@{v.username} used {kind} award!")
if not author.has_badge(91):
new_badge = Badge(badge_id=91, user_id=author.id)
g.db.add(new_badge)
if post.author.received_award_count: post.author.received_award_count += 1
else: post.author.received_award_count = 1
@ -807,6 +912,12 @@ def award_comment(cid, v):
if not author.has_badge(90):
new_badge = Badge(badge_id=90, user_id=author.id)
g.db.add(new_badge)
elif kind == "grinch":
author.grinch = True
send_notification(CARP_ID, f"@{v.username} used {kind} award!")
if not author.has_badge(91):
new_badge = Badge(badge_id=91, user_id=author.id)
g.db.add(new_badge)
if c.author.received_award_count: c.author.received_award_count += 1
else: c.author.received_award_count = 1

View File

@ -52,7 +52,11 @@ def settings_profile_post(v):
updated = False
if request.values.get("background", v.background) != v.background:
if request.values.get("grincheffect", v.grincheffect) != v.grincheffect:
updated = True
v.grincheffect = request.values.get("grincheffect", None) == 'true'
elif request.values.get("background", v.background) != v.background:
updated = True
v.background = request.values.get("background", None)
@ -732,8 +736,8 @@ def settings_images_profile(v):
if not imageurl: abort(400)
if v.highres and '/images/' in v.highres : os.remove('images/' + v.highres.split('/images/')[1])
if v.profileurl and '/images/' in v.profileurl : os.remove('images/' + v.profileurl.split('/images/')[1])
if v.highres and '/images/' in v.highres : os.remove('/images/' + v.highres.split('/images/')[1])
if v.profileurl and '/images/' in v.profileurl : os.remove('/images/' + v.profileurl.split('/images/')[1])
v.highres = highres
v.profileurl = imageurl
g.db.add(v)
@ -761,7 +765,7 @@ def settings_images_banner(v):
bannerurl = process_image(name)
if bannerurl:
if v.bannerurl and '/images/' in v.bannerurl : os.remove('images/' + v.bannerurl.split('/images/')[1])
if v.bannerurl and '/images/' in v.bannerurl : os.remove('/images/' + v.bannerurl.split('/images/')[1])
v.bannerurl = bannerurl
g.db.add(v)
g.db.commit()