context: clarify

This commit is contained in:
Demian 2021-07-07 12:52:28 +03:00
parent 7e3a68249a
commit 55ffac1c33
3 changed files with 11 additions and 10 deletions

View File

@ -261,11 +261,11 @@ func (c *nativeContext) Data() string {
func (c *nativeContext) Args() []string {
if c.message != nil {
message := strings.Trim(c.message.Payload, " ")
if message == "" {
payload := strings.Trim(c.message.Payload, " ")
if payload == "" {
return nil
}
return strings.Split(message, " ")
return strings.Split(payload, " ")
}
if c.callback != nil {
return strings.Split(c.callback.Data, "|")

View File

@ -8,9 +8,11 @@ import (
var _ Context = (*nativeContext)(nil)
func TestContextStore(t *testing.T) {
var c Context
c = new(nativeContext)
c.Set("name", "Jon Snow")
assert.Equal(t, "Jon Snow", c.Get("name"))
func TestContext(t *testing.T) {
t.Run("Get,Set", func(t *testing.T) {
var c Context
c = new(nativeContext)
c.Set("name", "Jon Snow")
assert.Equal(t, "Jon Snow", c.Get("name"))
})
}

View File

@ -10,8 +10,7 @@ import (
// Recipient is any possible endpoint you can send
// messages to: either user, group or a channel.
type Recipient interface {
// Must return legit Telegram chat_id or username
Recipient() string
Recipient() string // must return legit Telegram chat_id or username
}
// Sendable is any object that can send itself.