From 803ae14c6c9314df190a6ec6a160611e9d74c246 Mon Sep 17 00:00:00 2001 From: surdeus Date: Wed, 13 Dec 2023 09:05:29 +0300 Subject: [PATCH] feat: fixed the *Bot.Send method. --- bot.go | 13 +++++++------ context.go | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bot.go b/bot.go index 06bc8db..e53519d 100644 --- a/bot.go +++ b/bot.go @@ -54,15 +54,16 @@ func (bot *Bot) Debug(debug bool) *Bot { func (bot *Bot) Send( sid SessionId, v Sendable, ) (*Message, error) { - ctx, ok := bot.contexts[sid] - if !ok { - return nil, ContextNotExistErr + config := v.SendConfig(sid, bot) + if config.Error != nil { + return nil, config.Error } - c := &Context{ - context: ctx, + msg, err := bot.Api.Send(config.ToApi()) + if err != nil { + return nil, err } - return c.Bot.Send(c.Session.Id, v) + return &msg, nil } // Send to the session specified its ID raw chattable from the tgbotapi. diff --git a/context.go b/context.go index 7cb2089..de11a82 100644 --- a/context.go +++ b/context.go @@ -202,6 +202,10 @@ func (c *Context) History() []Path { // Changes screen of user to the Id one. func (c *Context) Go(pth Path, args ...any) { + if pth == "" { + c.pathHistory = []Path{} + return + } var back bool if pth == "-" { ln := len(c.pathHistory)