context: clarify

pull/425/head
Demian 3 years ago
parent 7e3a68249a
commit 55ffac1c33

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

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

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

Loading…
Cancel
Save