Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BotSendMessageAction = &logic.Node[BotSendMessageArgs, Empty]{ ID: uuid.MustParse("7b42a5e7-0c59-4034-94f9-8310c531e521"), Type: logic.NodeTypeAction, Func: func(ctx context.Context, input *BotSendMessageArgs) (*Empty, error) { bot, ok := ctx.Value(BotContextValue).(*telego.Bot) if !ok { return nil, fmt.Errorf("no context value %q", BotContextValue) } _, err := bot.SendMessage(tu.Message(tu.ID(input.ChatID), input.Text)) if err != nil { return nil, err } return &Empty{}, nil }, }
View Source
var BotUpdateEvent = &logic.Node[Empty, BotUpdate]{ ID: uuid.MustParse("ab2283b9-2553-474f-9d8c-14267eb026af"), Type: logic.NodeTypeEvent, Func: func(ctx context.Context, _ *Empty) (*BotUpdate, error) { update, ok := ctx.Value(BotUpdateContextValue).(telego.Update) if !ok { return nil, fmt.Errorf("no context value %q", BotUpdateContextValue) } upd := &BotUpdate{ UpdateID: int64(update.UpdateID), } if update.Message != nil { message := update.Message upd.Message = &BotMessage{ ID: int64(message.MessageID), Chat: BotChat{ ID: message.Chat.ID, }, Text: message.Text, } } return upd, nil }, }
View Source
var Nodes = map[logic.NodeID]json.Marshaler{ BotUpdateEvent.ID: BotUpdateEvent, BotSendMessageAction.ID: BotSendMessageAction, }
Functions ¶
This section is empty.
Types ¶
type BotMessage ¶
type BotSendMessageArgs ¶
type BotUpdate ¶
type BotUpdate struct { UpdateID int64 `json:"updateID"` Message *BotMessage `json:"message,omitempty"` }
type ContextValue ¶
type ContextValue string
const BotContextValue ContextValue = "bot"
const BotUpdateContextValue ContextValue = "bot-update"
Click to show internal directories.
Click to hide internal directories.