Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Level 5/level_5_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ def extract_bits_from_message(self, message):
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
import re
# Match anything that starts with a common cheer patern followed by a number
match = re.search(r'^(cheer|kappa|pogchamp)(?P<bits>\d+)$', word)
if match:
try:
bits_amount += int(match.group('bits'))
except (ValueError, TypeError):
pass

return bits_amount

Expand Down