Skip to content

fake cheers result in a nonzero bits_amount in extract_bits_from_message #6

@briaguya0

Description

@briaguya0

pretty sure this is due to the fallback here

# Fallback: Look for cheer emotes in the message content
if message.content:
words = message.content.lower().split()
for word in words:
# Common cheer patterns: cheer100, kappa50, pogchamp25, etc.
if any(word.startswith(cheer) for cheer in ['cheer', 'kappa', 'pogchamp']):
# Extract number from the end of the cheer
import re
match = re.search(r'(\d+)$', word)
if match:
try:
bits_amount += int(match.group(1))
except (ValueError, TypeError):
pass

here's a fiddle demonstrating the issue (it prints out 9001 even though the cheer is fake and uses cheerc9001 instead of a real cheer) https://python-fiddle.com/saved/3a02ef05-684a-41fd-bbba-78b2caddd14e

and here's the code from the fiddle in case that link breaks at some point

from types import SimpleNamespace

bits_amount = 0
message = SimpleNamespace(content="")
message.content = "cheerc9001 this is a fake cheer of over 9000"

words = message.content.lower().split()
for word in words:
# Common cheer patterns: cheer100, kappa50, pogchamp25, etc.
    if any(word.startswith(cheer) for cheer in ['cheer', 'kappa', 'pogchamp']):
        # Extract number from the end of the cheer
        import re
        match = re.search(r'(\d+)$', word)
        if match:
            try:
                bits_amount += int(match.group(1))
            except (ValueError, TypeError):
                pass

print(bits_amount)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions