Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

refactor(playsounds): use regex instead of elif chaining #115

Merged
merged 7 commits into from
Feb 22, 2022
Merged

refactor(playsounds): use regex instead of elif chaining #115

merged 7 commits into from
Feb 22, 2022

Conversation

12beesinatrenchcoat
Copy link
Contributor

@12beesinatrenchcoat 12beesinatrenchcoat commented Feb 22, 2022

  • makes an array (playsounds) containing all the .wav files in the /playsounds/ directory
  • matches message with regex ^(\d+)$
  • checks if sound exists

resolves #96.

Description

Because if else chaining hurts my soul.

How Has This Been Tested

Ran two tests:

(100)

Should result in no sound being played.

(100) || ninja: wow

Should result in "ninja: wow" going through to Uberduck.ai, and nothing else.

Checklist

  • Changes follow the CONTRIBUTING.md guidelines.
  • Update necessary documentation accordingly.
  • Check issues and pull requests first. You don't want to duplicate effort.

Other information

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@mmattbtw mmattbtw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also (1) doesn't seem to work for me:
image

Using this string: spongebob: test || (1) || drake: test || (2) || kanye-west-rap: test || drake: test or this string: (1) || (2) || (3)

bot.py Outdated Show resolved Hide resolved
@12beesinatrenchcoat
Copy link
Contributor Author

oh yeah i did some wonky stuff with numbers didn't i

sound 1 = index 0. 
also replaced a print with log.info
Copy link
Member

@mmattbtw mmattbtw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested locally, all good 👍 thanks for your continued contributions!

@mmattbtw mmattbtw merged commit 8c8a70f into mmattDonk:main Feb 22, 2022
@12beesinatrenchcoat 12beesinatrenchcoat deleted the ifelse-begone branch February 22, 2022 03:40
@mmattbtw
Copy link
Member

@all-contributors add @12beesinatrenchcoat for doc, and code

@allcontributors
Copy link
Contributor

@mmattbtw

I've put up a pull request to add @12beesinatrenchcoat! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix If Elif spam in playsounds code.
2 participants