feat: fixed the *Bot.Send method.

This commit is contained in:
Andrey Parhomenko 2023-12-13 09:05:29 +03:00
parent ae2da1201c
commit 803ae14c6c
2 changed files with 11 additions and 6 deletions

13
bot.go
View file

@ -54,15 +54,16 @@ func (bot *Bot) Debug(debug bool) *Bot {
func (bot *Bot) Send( func (bot *Bot) Send(
sid SessionId, v Sendable, sid SessionId, v Sendable,
) (*Message, error) { ) (*Message, error) {
ctx, ok := bot.contexts[sid] config := v.SendConfig(sid, bot)
if !ok { if config.Error != nil {
return nil, ContextNotExistErr return nil, config.Error
} }
c := &Context{ msg, err := bot.Api.Send(config.ToApi())
context: ctx, 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. // Send to the session specified its ID raw chattable from the tgbotapi.

View file

@ -202,6 +202,10 @@ func (c *Context) History() []Path {
// Changes screen of user to the Id one. // Changes screen of user to the Id one.
func (c *Context) Go(pth Path, args ...any) { func (c *Context) Go(pth Path, args ...any) {
if pth == "" {
c.pathHistory = []Path{}
return
}
var back bool var back bool
if pth == "-" { if pth == "-" {
ln := len(c.pathHistory) ln := len(c.pathHistory)