Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter out regex names from .toArgs #25

Merged
merged 3 commits into from
Jun 18, 2024
Merged

fix: filter out regex names from .toArgs #25

merged 3 commits into from
Jun 18, 2024

Conversation

carafelix
Copy link
Member

@carafelix carafelix commented Jun 18, 2024

this will fix #24 only for regex's.
Command names containing UpperCase letters will still thrown when calling SetMyCommand on them.

They should at least be discouraged. I don't know if it's better to enforce right from the bat the use of lowercaseonly commands or just a mention in the docs. Because they will still register and be handled correctly, but could not be pass to SetMyCommand

@carafelix carafelix changed the base branch from main to next June 18, 2024 14:36
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (next@efa55cc). Learn more about missing BASE report.

Current head 981fbaf differs from pull request most recent head 1ad9e15

Please upload reports for the commit 1ad9e15 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             next      #25   +/-   ##
=======================================
  Coverage        ?   84.02%           
=======================================
  Files           ?        8           
  Lines           ?      582           
  Branches        ?       91           
=======================================
  Hits            ?      489           
  Misses          ?       92           
  Partials        ?        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +160 to +162
commands: commands
.filter((command) => typeof command.name === "string")
.map((command) => command.toObject(language)),
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think it's better if we move this kind of thing to the actual setCommands method, so users can still use toArgs and toSingleScopeArgs however they want. WDYT?

Copy link
Member Author

@carafelix carafelix Jun 18, 2024

Choose a reason for hiding this comment

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

Yeah, that make sense, but it will make the output silently uncomplainant to the telegram specification. And since both function are returning setMyCommandParams interfaces, which are meant for passing them to the telegram api, might be misleading.

If someone wants to inspect their commands or do something with them like they could with .toArgs they could use the .toElementals method, which does not filter regex's and archives a very similar result.
I can add the scope and description to that interface so they become more detailed

Copy link
Member Author

Choose a reason for hiding this comment

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

output looks like:

[
  {
    name: "bread",
    language: "default",
    prefix: "/",
    scopes: [ { type: "default" } ],
    description: "_"
  },
  {
    name: "pan",
    language: "es",
    prefix: "/",
    scopes: [ { type: "default" } ],
    description: "_"
  },
// etc

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm... yeah, that makes sense. Thanks!

@carafelix carafelix merged commit 8e7edbb into next Jun 18, 2024
@carafelix carafelix deleted the symbols branch June 19, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: calling .setCommands(bot) on commands containing UpperCase letters or symbols will throw
2 participants