diff --git a/cmd/test/main.go b/cmd/test/main.go index 4ca595b..21c98ae 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -184,6 +184,7 @@ WithInitFunc(func(c *tg.Context) { "inc-dec", tg.RenderFunc(func(c *tg.Context) tg.UI { var ( kbd *tg.InlineCompo + //cntMsg *tg.MessageCompo inline, std, onlyInc, onlyDec *tg.Inline ) @@ -226,6 +227,7 @@ WithInitFunc(func(c *tg.Context) { inline = std } + kbd = tg.NewMessage( fmt.Sprintf(format, d.Counter), ).Inline(inline) @@ -316,6 +318,9 @@ WithUsage(tg.Func(func(c *tg.Context){ ), ) })), + tg.NewCommand("invoice", "invoice check"). + WithAction(tg.Func(func(c *tg.Context){ + })), )) func main() { log.Println(beh.Screens) diff --git a/tg/inline.go b/tg/inline.go index 2f4fa5b..66ff0e7 100644 --- a/tg/inline.go +++ b/tg/inline.go @@ -46,7 +46,8 @@ func (compo *InlineCompo) Update(c *Context) { compo.Text, compo.Inline.ToApi(), ) - c.Bot.Api.Send(edit) + msg, _ := c.Bot.Api.Send(edit) + compo.Message = &msg } // Implementing the Filterer interface. diff --git a/tg/invoice.go b/tg/invoice.go new file mode 100644 index 0000000..87d8037 --- /dev/null +++ b/tg/invoice.go @@ -0,0 +1,17 @@ +package tg + +import ( + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" +) + +type InvoiceCompo struct { + *MessageCompo + tgbotapi.InvoiceConfig +} + +func (compo *InvoiceCompo) SendConfig( + sid SessionId, bot *Bot, +) (*SendConfig) { + return nil +} + diff --git a/tg/message.go b/tg/message.go index 5826151..5d94eaf 100644 --- a/tg/message.go +++ b/tg/message.go @@ -25,6 +25,16 @@ func Escape2(str string) string { return string(escapeRe.ReplaceAll([]byte(str), []byte("\\$1"))) } +func (compo *MessageCompo) Update(c *Context) { + edit := tgbotapi.NewEditMessageText( + c.Session.Id.ToApi(), + compo.Message.MessageID, + compo.Text, + ) + msg, _ := c.Bot.Api.Send(edit) + compo.Message = &msg +} + // Is only implemented to make it sendable and so we can put it // return of rendering functions. func (compo *MessageCompo) SetMessage(msg *Message) {