mirror of
https://github.com/tucnak/telebot
synced 2024-11-11 01:10:39 +00:00
context: clarify
This commit is contained in:
parent
7e3a68249a
commit
55ffac1c33
@ -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, "|")
|
||||
|
@ -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"))
|
||||
})
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user