Fixed string reading issues.
This commit is contained in:
parent
37cd1d37fd
commit
0471ea91c7
3 changed files with 21 additions and 2 deletions
|
@ -170,6 +170,9 @@ func (af ActionFunc) Act(c *Context) {
|
|||
|
||||
// Changes screen of user to the Id one.
|
||||
func (c *Context) Go(pth Path, args ...any) error {
|
||||
if pth == "-" {
|
||||
pth = c.PrevPath()
|
||||
}
|
||||
// Getting the screen and changing to
|
||||
// then executing its widget.
|
||||
if !pth.IsAbs() {
|
||||
|
@ -244,7 +247,7 @@ func (c *Context) RunWidget(widget Widget, args ...any) *UpdateChan {
|
|||
}
|
||||
chns := make([]*UpdateChan, len(compos))
|
||||
for i, compo := range compos {
|
||||
chns[i] = c.RunCompo(compo)
|
||||
chns[i] = c.RunCompo(compo, args...)
|
||||
}
|
||||
|
||||
ret := NewUpdateChan()
|
||||
|
@ -283,8 +286,13 @@ func (c *Context) RunWidget(widget Widget, args ...any) *UpdateChan {
|
|||
// Simple way to read strings for widgets.
|
||||
func (c *Context) ReadString(pref string, args ...any) string {
|
||||
var text string
|
||||
c.Sendf(pref, args...)
|
||||
if pref != "" {
|
||||
c.Sendf(pref, args...)
|
||||
}
|
||||
for u := range c.Input() {
|
||||
if u == nil {
|
||||
break
|
||||
}
|
||||
if u.Message == nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ func (kbd *Keyboard) Row(btns ...*Button) *Keyboard {
|
|||
return kbd
|
||||
}
|
||||
|
||||
// Adds buttons as one column list.
|
||||
func (kbd *Keyboard) List(btns ...*Button) *Keyboard {
|
||||
for _, btn := range btns {
|
||||
kbd.Rows = append(kbd.Rows, ButtonRow{btn})
|
||||
}
|
||||
return kbd
|
||||
}
|
||||
|
||||
// Set the default action when no button provides
|
||||
// key to the data we got.
|
||||
func (kbd *Keyboard) WithAction(a Action) *Keyboard {
|
||||
|
|
|
@ -2,6 +2,7 @@ package tg
|
|||
|
||||
import (
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
//"strings"
|
||||
)
|
||||
type Message = tgbotapi.Message
|
||||
|
||||
|
@ -75,6 +76,8 @@ func (config *MessageCompo) SendConfig(
|
|||
text = config.Text
|
||||
}
|
||||
|
||||
//text = strings.ReplaceAll(text, "-", "\\-")
|
||||
|
||||
msg := tgbotapi.NewMessage(c.Session.Id.ToApi(), text)
|
||||
ret.Message = &msg
|
||||
ret.Message.ParseMode = config.ParseMode
|
||||
|
|
Loading…
Reference in a new issue