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(
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.

View file

@ -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)