import consistency

pull/225/head
Aevann 2024-02-21 22:08:33 +02:00
parent 57c7bb4002
commit 0fd121c22f
8 changed files with 21 additions and 23 deletions

View File

@ -1,6 +1,5 @@
import time import time
from math import floor from math import floor
from random import randint
from urllib.parse import parse_qs, urlencode, urlparse from urllib.parse import parse_qs, urlencode, urlparse
from flask import g from flask import g

View File

@ -1,5 +1,5 @@
import time import time
from random import choice import random
from flask import g from flask import g
from files.classes.lottery import Lottery from files.classes.lottery import Lottery
@ -44,7 +44,7 @@ def end_lottery_session():
active_lottery.is_active = False active_lottery.is_active = False
return True, "Lottery ended with no participants!" return True, "Lottery ended with no participants!"
winner = choice(raffle) winner = random.choice(raffle)
active_lottery.winner_id = winner active_lottery.winner_id = winner
winning_user = next(filter(lambda x: x.id == winner, participating_users)) winning_user = next(filter(lambda x: x.id == winner, participating_users))
winning_user.pay_account('coins', active_lottery.prize) winning_user.pay_account('coins', active_lottery.prize)

View File

@ -1,4 +1,4 @@
from random import choice import random
from .const_stateful import MARSEY_MAPPINGS from .const_stateful import MARSEY_MAPPINGS
@ -15,6 +15,6 @@ def marsify(text, chud_phrase):
x = x.lower() x = x.lower()
if x in chud_words: continue if x in chud_words: continue
if len(x) >= 5 and x in MARSEY_MAPPINGS: if len(x) >= 5 and x in MARSEY_MAPPINGS:
marsey = choice(MARSEY_MAPPINGS[x]) marsey = random.choice(MARSEY_MAPPINGS[x])
new_text += f':{marsey}: ' new_text += f':{marsey}: '
return new_text return new_text

View File

@ -1,6 +1,5 @@
import random import random
import re import re
from random import choice, choices, randint
from .config.const import * from .config.const import *
@ -159,11 +158,11 @@ def command_regex_matcher(match, upper=False):
else: else:
if match.group(2).startswith('roll'): if match.group(2).startswith('roll'):
max_num = int(match.group(3)) max_num = int(match.group(3))
result = randint(1, max_num) result = random.randint(1, max_num)
color = tuple(choices(range(256), k=3)) color = tuple(random.choices(range(256), k=3))
result = f'<b style="color:rgb{color}">Your roll (1-{max_num}): {result}</b>' result = f'<b style="color:rgb{color}">Your roll (1-{max_num}): {result}</b>'
else: else:
result = str(choice(commands[match.group(2).lower()])) result = str(random.choice(commands[match.group(2).lower()]))
return match.group(1) + result return match.group(1) + result
reason_regex_post = re.compile('(/post/[0-9]+)', flags=re.A) reason_regex_post = re.compile('(/post/[0-9]+)', flags=re.A)

View File

@ -1,6 +1,6 @@
import json import json
from enum import Enum from enum import Enum
from random import randint import random
import time import time
from flask import g from flask import g
@ -166,7 +166,7 @@ def spin_roulette_wheel():
participants, bets, active_games = get_roulette_bets_and_betters() participants, bets, active_games = get_roulette_bets_and_betters()
if len(participants) > 0: if len(participants) > 0:
number = randint(0, 37) # 37 is 00 number = random.randint(0, 37) # 37 is 00
winners, payouts, rewards_by_game_id = determine_roulette_winners(number, bets) winners, payouts, rewards_by_game_id = determine_roulette_winners(number, bets)

View File

@ -1,5 +1,5 @@
from math import floor from math import floor
from random import randint import random
from files.helpers.config.const import * from files.helpers.config.const import *
from files.helpers.lottery import * from files.helpers.lottery import *
@ -15,23 +15,23 @@ def check_for_treasure(from_comment, in_text):
if not FEATURES['GAMBLING']: return if not FEATURES['GAMBLING']: return
seed = randint(1, 1000) seed = random.randint(1, 1000)
is_special = seed == 1000 is_special = seed == 1000
is_standard = seed >= 990 is_standard = seed >= 990
amount = 0 amount = 0
if is_special: if is_special:
amount = randint(special_min, special_max) amount = random.randint(special_min, special_max)
elif is_standard: elif is_standard:
amount = randint(standard_min, standard_max) amount = random.randint(standard_min, standard_max)
if randint(1, 100) > 90: if random.randint(1, 100) > 90:
amount = -amount amount = -amount
if amount != 0: if amount != 0:
if amount > 0: if amount > 0:
active_lottery = get_active_lottery() active_lottery = get_active_lottery()
lottery_tickets_seed = randint(1, 100) lottery_tickets_seed = random.randint(1, 100)
lottery_tickets_instead = lottery_tickets_seed <= lotterizer_rate lottery_tickets_instead = lottery_tickets_seed <= lotterizer_rate
if active_lottery and lottery_tickets_instead: if active_lottery and lottery_tickets_instead:

View File

@ -2,7 +2,7 @@ import time
from math import floor from math import floor
import os import os
import ffmpeg import ffmpeg
from random import randint import random
from sqlalchemy.orm import load_only from sqlalchemy.orm import load_only
@ -1894,7 +1894,7 @@ def delete_media_post(v):
@admin_level_required(PERMS['USER_RESET_PASSWORD']) @admin_level_required(PERMS['USER_RESET_PASSWORD'])
def admin_reset_password(user_id, v): def admin_reset_password(user_id, v):
user = get_account(user_id) user = get_account(user_id)
new_password = secrets.token_urlsafe(randint(27, 33)) new_password = secrets.token_urlsafe(random.randint(27, 33))
user.passhash = hash_password(new_password) user.passhash = hash_password(new_password)
g.db.add(user) g.db.add(user)

View File

@ -1,7 +1,7 @@
import time import time
import uuid import uuid
import random
from random import randint
from sqlalchemy.orm import aliased, deferred from sqlalchemy.orm import aliased, deferred
from sqlalchemy.sql import case, literal from sqlalchemy.sql import case, literal
from sqlalchemy.sql.expression import or_ from sqlalchemy.sql.expression import or_
@ -143,12 +143,12 @@ def execute_shadowban_viewers_and_voters(v, target):
ti = max(int((time.time() - target.created_utc)/60), 3) ti = max(int((time.time() - target.created_utc)/60), 3)
max_upvotes = min(ti, 13) max_upvotes = min(ti, 13)
rand = randint(0, max_upvotes) rand = random.randint(0, max_upvotes)
if target.upvotes >= rand: return if target.upvotes >= rand: return
amount = randint(0, 3) amount = random.randint(0, 3)
target.upvotes += amount target.upvotes += amount
if isinstance(target, Post): if isinstance(target, Post):
target.views += amount*randint(3, 5) target.views += amount*random.randint(3, 5)
g.db.add(target) g.db.add(target)