From 080ead560ac545b49d11b5c614f94edf083c8b84 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Thu, 30 Nov 2017 03:08:29 +0500 Subject: [PATCH] :bug: Fixed 'end of array' error in CommandArgument helper --- helpers_message.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/helpers_message.go b/helpers_message.go index 5550ca0..2c34920 100644 --- a/helpers_message.go +++ b/helpers_message.go @@ -1,9 +1,6 @@ package telegram -import ( - "strings" - "time" -) +import "time" func (msg *Message) IsCommand() bool { if len(msg.Entities) <= 0 { @@ -31,10 +28,13 @@ func (msg *Message) CommandArgument() string { return "" } - return strings.TrimLeft( - string([]rune(msg.Text)[(msg.Entities[0].Length):]), - " ", - ) + argument := string([]rune(msg.Text)[msg.Entities[0].Length:]) + + if argument != "" { + return argument[1:] + } + + return "" } func (msg *Message) HasArgument() bool {