Properly handle the @ part of a command.

This commit is contained in:
Danila Fedorin 2018-01-12 22:28:13 -08:00
parent e4381e7daf
commit 81eee54695

View File

@ -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