From 81eee54695ddf3e08d66bb5379b0fade7b8c981d Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 12 Jan 2018 22:28:13 -0800 Subject: [PATCH] Properly handle the @ part of a command. --- src/telepathy/bot.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/telepathy/bot.cr b/src/telepathy/bot.cr index 9aaf6c0..684078b 100644 --- a/src/telepathy/bot.cr +++ b/src/telepathy/bot.cr @@ -74,8 +74,9 @@ module Telepathy text = message.text.as String if entity.offset == 0 && entity.type == "bot_command" divider_index = (text.index /\s|@/) || text.size + first_space_index = (text.index /\s/) || text.size command = text[1...divider_index] - remaining = text[divider_index..text.size] + remaining = text[first_space_index..text.size] params = remaining.empty? ? ([] of String) : (remaining[1...remaining.size].split ' ') @command_hooks[command]?.try { |command| command.call(update, params) } end