remove !wordle since nobody uses it (only 2 ppl used it last 30 days in rdrama and WPD)

pull/143/head
Aevann 2023-04-29 23:27:45 +02:00
parent 4bd57d42ee
commit de47c992fa
11 changed files with 27 additions and 121 deletions

View File

@ -325,7 +325,3 @@ function handle_action(type, cid, thing) {
}
xhr.send(form)
}
function wordle(t) {
handle_action('wordle', t.dataset.cid, t.previousElementSibling.value)
}

View File

@ -134,7 +134,6 @@ class Comment(Base):
body_html = Column(String)
body_ts = Column(TSVECTOR(), server_default=FetchedValue())
ban_reason = Column(String)
wordle_result = Column(String)
treasure_amount = Column(String)
slots_result = Column(String)
blackjack_result = Column(String)
@ -390,8 +389,6 @@ class Comment(Base):
if self.author.shadowbanned: return True
if (self.wordle_result) and (not self.body or len(self.body_html) <= 100) and 9 > self.level > 1: return True
if v and v.filter_words and self.body and any(x in self.body for x in v.filter_words): return True
return False
@ -408,27 +405,6 @@ class Comment(Base):
def active_flags(self, v):
return len(self.filtered_flags(v))
@lazy
def wordle_html(self, v):
if not self.wordle_result: return ''
split_wordle_result = self.wordle_result.split('_')
wordle_guesses = split_wordle_result[0]
wordle_status = split_wordle_result[1]
wordle_answer = split_wordle_result[2]
body = f"<span id='wordle-{self.id}' class='ml-2'><small>{wordle_guesses}</small>"
if wordle_status == 'active' and v and v.id == self.author_id:
body += f'''<input autocomplete="off" type="text" class="form-control" maxsize="4" style="width:200px;display:initial" placeholder="5-letter guess"><button class="action-{self.id} btn btn-success small text-uppercase px-2 mb-2" data-cid="{self.id}" data-nonce="{g.nonce}" data-onclick="wordle(this)">Guess</button>'''
elif wordle_status == 'won':
body += "<strong class='ml-2'>Correct!</strong>"
elif wordle_status == 'lost':
body += f"<strong class='ml-2'>Lost. The answer was: {wordle_answer}</strong>"
body += '</span>'
return body
@property
@lazy
def blackjack_html(self):

View File

@ -411,7 +411,6 @@ def execute_antispam_duplicate_comment_check(v:User, body_html:str):
if v.id in ANTISPAM_BYPASS_IDS or v.admin_level: return
if v.age >= NOTIFICATION_SPAM_AGE_THRESHOLD: return
if len(body_html) < 16: return
if body_html == '!wordle': return # wordle
compare_time = int(time.time()) - 60 * 60 * 24
count = g.db.query(Comment.id).filter(Comment.body_html == body_html,
Comment.created_utc >= compare_time).count()
@ -519,13 +518,6 @@ def execute_lawlz_actions(v:User, p:Submission):
g.db.add(ma_3)
def execute_wordle(c:Comment, body:str):
if not FEATURES['WORDLE']: return
if not "!wordle" in body: return
answer = random.choice(WORDLE_LIST)
c.wordle_result = f'_active_{answer}'
def process_poll_options(v:User, target:Union[Submission, Comment]):
patterns = [(poll_regex, 0), (choice_regex, 1)]

File diff suppressed because one or more lines are too long

View File

@ -15,32 +15,31 @@ def check_for_treasure(from_comment, in_text):
if not FEATURES['GAMBLING']: return
if '!wordle' not in in_text:
seed = randint(1, 1000)
is_special = seed == 1000
is_standard = seed >= 990
amount = 0
seed = randint(1, 1000)
is_special = seed == 1000
is_standard = seed >= 990
amount = 0
if is_special:
amount = randint(special_min, special_max)
elif is_standard:
amount = randint(standard_min, standard_max)
if randint(1, 100) > 90:
if amount > user.coins: amount = user.coins
amount = -amount
if is_special:
amount = randint(special_min, special_max)
elif is_standard:
amount = randint(standard_min, standard_max)
if randint(1, 100) > 90:
if amount > user.coins: amount = user.coins
amount = -amount
if amount != 0:
if amount > 0:
active_lottery = get_active_lottery()
lottery_tickets_seed = randint(1, 100)
lottery_tickets_instead = lottery_tickets_seed <= lotterizer_rate
if amount != 0:
if amount > 0:
active_lottery = get_active_lottery()
lottery_tickets_seed = randint(1, 100)
lottery_tickets_instead = lottery_tickets_seed <= lotterizer_rate
if active_lottery and lottery_tickets_instead:
ticket_count = floor(amount / LOTTERY_TICKET_COST)
grant_lottery_tickets_to_user(user, ticket_count)
from_comment.treasure_amount = f'l{ticket_count}'
return
if active_lottery and lottery_tickets_instead:
ticket_count = floor(amount / LOTTERY_TICKET_COST)
grant_lottery_tickets_to_user(user, ticket_count)
from_comment.treasure_amount = f'l{ticket_count}'
return
user.pay_account('coins', amount)
from_comment.treasure_amount = str(amount)
user.pay_account('coins', amount)
from_comment.treasure_amount = str(amount)

View File

@ -22,8 +22,6 @@ from files.routes.routehelpers import execute_shadowban_viewers_and_voters
from files.routes.wrappers import *
from files.__main__ import app, cache, limiter
WORDLE_COLOR_MAPPINGS = {-1: "🟥", 0: "🟨", 1: "🟩"}
@app.get("/comment/<int:cid>")
@app.get("/post/<int:pid>/<anything>/<int:cid>")
@app.get("/h/<sub>/comment/<int:cid>")
@ -239,7 +237,7 @@ def comment(v:User):
body_html = sanitize(body_for_sanitize, limit_pings=5, count_emojis=not v.marsify)
if post_target.id not in ADMIGGER_THREADS and '!wordle' not in body.lower() and not (v.agendaposter and v.agendaposter_phrase in body.lower()):
if post_target.id not in ADMIGGER_THREADS and not (v.agendaposter and v.agendaposter_phrase in body.lower()):
existing = g.db.query(Comment.id).filter(
Comment.author_id == v.id,
Comment.deleted_utc == 0,
@ -372,13 +370,11 @@ def comment(v:User):
c.voted = 1
check_for_treasure(c, body)
execute_wordle(c, body)
check_slots_command(c, v, v)
# Increment post count iff not self-reply and not a spammy comment game
# Essentially a measure to make comment counts reflect "real" content
if (posting_to_submission and not rts
and not c.wordle_result and not c.slots_result):
if (posting_to_submission and not rts and not c.slots_result):
post_target.comment_count += 1
g.db.add(post_target)
@ -547,40 +543,6 @@ def diff_words(answer, guess):
return diffs
@app.post("/wordle/<int:cid>")
@limiter.limit('1/second', scope=rpath)
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
@limiter.limit(DEFAULT_RATELIMIT)
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def handle_wordle_action(cid, v):
comment = get_comment(cid)
if v.id != comment.author_id:
abort(403)
guesses, status, answer = comment.wordle_result.split("_")
count = len(guesses.split(" -> "))
try: guess = request.values.get("thing").strip().lower()
except: abort(400)
if len(guess) != 5: abort(400, "Not a valid guess!")
if status == "active":
guesses += "".join(cg + WORDLE_COLOR_MAPPINGS[diff] for cg, diff in zip(guess, diff_words(answer, guess)))
if (guess == answer): status = "won"
elif (count == 6): status = "lost"
else: guesses += ' -> '
comment.wordle_result = f'{guesses}_{status}_{answer}'
g.db.add(comment)
return {"response" : comment.wordle_html(v)}
@app.post("/toggle_comment_nsfw/<int:cid>")
@feature_required('NSFW_MARKING')
@limiter.limit('1/second', scope=rpath)

View File

@ -26,7 +26,7 @@ def create_group(v):
if not name: abort(400)
name = name.strip().lower()
if name.startswith('slots') or name.startswith('wordle') or name.startswith('remindme'):
if name.startswith('slots') or name.startswith('remindme'):
return redirect(f"/ping_groups?error=You can't make a group with that name!")
if not valid_sub_regex.fullmatch(name):

View File

@ -233,10 +233,6 @@
{% if c.blackjack_result %}
{{c.blackjack_html | safe}}
{% endif %}
{% if c.wordle_result %}
{{c.wordle_html(v) | safe}}
{% endif %}
</div>
{% if c.active_flags(v) %}
<div id="flaggers-{{c.id}}" class="flaggers d-none">

View File

@ -233,17 +233,6 @@ Text 2
<td>!biofoids</td>
<td>!biofoids</td>
</tr>
{% if FEATURES['WORDLE'] %}
<tr>
<td>Play Wordle<br>
<span style="font-style: italic; font-weight: normal;">
* Works only in comments.
</span>
</td>
<td>!wordle</td>
<td>!wordle</td>
</tr>
{% endif %}
</tbody>
</table></div>

View File

@ -0,0 +1 @@
alter table comments drop column wordle_result;

View File

@ -392,7 +392,6 @@ CREATE TABLE public.comments (
slots_result character varying(36),
blackjack_result character varying(860),
treasure_amount character varying(10),
wordle_result character varying(115),
body_ts tsvector GENERATED ALWAYS AS (to_tsvector('english'::regconfig, (body)::text)) STORED,
casino_game_id integer,
chuddedfor character varying(50),
@ -2896,4 +2895,3 @@ ALTER TABLE ONLY public.comments
--
-- PostgreSQL database dump complete
--