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