ekonda / kutana

The library for developing systems for messengers and social networks
MIT License
72 stars 17 forks source link

Incorrect Command Matching When Passing String Instead of List #93

Closed daeeros closed 1 week ago

daeeros commented 1 month ago

Description There is a bug in the on_commands method when a single string is passed instead of a list of commands. The method will incorrectly trigger on each character of the string rather than treating the entire string as a single command.

Steps to Reproduce

  1. Define a handler using the on_commands decorator and pass a string as the commands argument (e.g., "start" instead of ["start"]).
  2. Send a message that contains any of the characters in the string.

Expected Behavior The handler should only trigger when the message matches the full string provided as the command.

Actual Behavior The handler triggers on any message that contains any character from the provided string.

Example Code

@plugin.on_commands("start")
async def _(msg, ctx):
    await ctx.reply("Start command received")

In this case, the handler will trigger on any message containing the letters "s", "t", "a", "r", or "t" rather than just the word "start".

Suggested Fix The method should validate the commands parameter to ensure that it is a list. If a string is passed, it should convert it to a single-element list.