Changed text race scoring and added a say command

This commit is contained in:
2026-04-29 19:36:19 +03:00
parent 93b4a42109
commit 786cb3c0f8
2 changed files with 42 additions and 7 deletions
+9
View File
@@ -251,6 +251,15 @@ async def gamble(interaction: nextcord.Interaction, bet: float):
if gamble_string[2] == "3": if gamble_string[2] == "3":
await interaction.edit_original_message(content=conv_gamble_string(gamble_string) + f"\n:moneybag: ***JACKPOT!*** :moneybag:\nYou have regained **3x** your original bet.\nYou now have {db["users"][str(interaction.user.id)]["balance"]} internet points.") await interaction.edit_original_message(content=conv_gamble_string(gamble_string) + f"\n:moneybag: ***JACKPOT!*** :moneybag:\nYou have regained **3x** your original bet.\nYou now have {db["users"][str(interaction.user.id)]["balance"]} internet points.")
@bot.slash_command()
async def say(interaction: nextcord.Interaction, text: str = "", attachment: nextcord.Attachment = None):
if interaction.user.id == 1043523548339241001:
data = await attachment.read()
await interaction.channel.send(text, file = nextcord.File(io.BytesIO(data), filename=attachment.filename))
await interaction.send("OK", ephemeral=True)
else:
await interaction.send("Wrong guy", ephemeral=True)
@bot.event @bot.event
async def on_message(message: nextcord.Message): async def on_message(message: nextcord.Message):
if message.author != bot.user: if message.author != bot.user:
+31 -5
View File
@@ -20,9 +20,32 @@ special = [
"multimeter is very very awesome", "multimeter is very very awesome",
"i hide my true sexuality", "i hide my true sexuality",
"i tried eating my phone", "i tried eating my phone",
"i urinated in fridge once" "i urinated in fridge once",
"ok ok ok ok ok"
] ]
def hex_to_rgb(hex_color: int) -> tuple[int, int, int]:
r = (hex_color >> 16) & 0xFF
g = (hex_color >> 8) & 0xFF
b = hex_color & 0xFF
return r, g, b
def relative_luminance(hex_color: int) -> float:
r, g, b = hex_to_rgb(hex_color)
def linearize(c: int) -> float:
c /= 255.0
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
return 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b)
def contrast(color1: int, color2: int) -> float:
l1 = relative_luminance(color1)
l2 = relative_luminance(color2)
lighter = max(l1, l2)
darker = min(l1, l2)
ratio = (lighter + 0.05) / (darker + 0.05) # 1.0 to 21.0
normalized = (ratio - 1) / 20.0 # 0.0 to 1.0 linear
return math.log1p(normalized * (math.e - 1))
def generate_image(): def generate_image():
if random.randint(1, 100) == 1: if random.randint(1, 100) == 1:
text = random.choice(special) text = random.choice(special)
@@ -35,17 +58,19 @@ def generate_image():
x1, y1, x2, y2 = font.getbbox(text) x1, y1, x2, y2 = font.getbbox(text)
width = x2 - x1 + (y2 - y1) * 2 width = x2 - x1 + (y2 - y1) * 2
height = (y2 - y1) * 3 height = (y2 - y1) * 3
img = Image.new("RGB", (width, height), random.randint(0x000000, 0xFFFFFF)) col1 = random.randint(0x000000, 0xFFFFFF)
col2 = random.randint(0x000000, 0xFFFFFF)
img = Image.new("RGB", (width, height), col1)
draw = ImageDraw.Draw(img) draw = ImageDraw.Draw(img)
rand3 = random.random() rand3 = random.random()
for i in range(int(rand3 * 20)): for i in range(int(rand3 * 20)):
draw.line([(random.randint(0, int(width)), random.randint(0, int(height))), (random.randint(0, int(width)), random.randint(0, int(height)))], fill=random.randint(0x000000, 0xFFFFFF), width=3) draw.line([(random.randint(0, int(width)), random.randint(0, int(height))), (random.randint(0, int(width)), random.randint(0, int(height)))], fill=random.randint(0x000000, 0xFFFFFF), width=3)
draw.text((-x1 + (y2 - y1), -y1 + (y2 - y1)), text, fill=random.randint(0x000000, 0xFFFFFF), font_size=20, font=font) draw.text((-x1 + (y2 - y1), -y1 + (y2 - y1)), text, fill=col2, font_size=20, font=font)
array = numpy.array(img) array = numpy.array(img)
height, width = array.shape[:2] height, width = array.shape[:2]
rand1 = random.random() rand1 = random.random()
rand2 = random.random() rand2 = random.random() * 2 - 1
for x in range(width): for x in range(width):
shift = int((math.sin(x / 50) * (y2 - y1) / 3) * rand1 + x * rand2 / 3) shift = int((math.sin(x / 50) * (y2 - y1) / 3) * rand1 + x * rand2 / 3)
array[:, x] = numpy.roll(array[:, x], shift, axis=0) array[:, x] = numpy.roll(array[:, x], shift, axis=0)
@@ -57,7 +82,8 @@ def generate_image():
img = img.filter(ImageFilter.GaussianBlur(radius=1)) img = img.filter(ImageFilter.GaussianBlur(radius=1))
img = img.filter(ImageFilter.EDGE_ENHANCE) img = img.filter(ImageFilter.EDGE_ENHANCE)
internet_value = rand1 * rand2 * rand3 * len(text) internet_value = len(text) * (abs(rand2) * 3 + rand1 + rand3 - contrast(col1, col2)) / 8
print(contrast(col1, col2))
print(internet_value) print(internet_value)
buffer = io.BytesIO() buffer = io.BytesIO()