1
0

🚑 Fixed panic by loop in command argument helpers

This commit is contained in:
Maxim Lebedev 2017-11-21 19:40:36 +05:00
parent 2dc679a0a1
commit 3eb4ddaed9
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F

View File

@ -1,6 +1,9 @@
package telegram
import "time"
import (
"strings"
"time"
)
func (msg *Message) IsCommand() bool {
if len(msg.Entities) <= 0 {
@ -28,11 +31,10 @@ func (msg *Message) CommandArgument() string {
return ""
}
if !msg.HasArgument() {
return ""
}
return string([]rune(msg.Text)[(msg.Entities[0].Length + 1):])
return strings.TrimLeft(
string([]rune(msg.Text)[(msg.Entities[0].Length):]),
" ",
)
}
func (msg *Message) HasArgument() bool {