package fsmwizard import ( "gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/iface" "gitea.neur0tx.site/Neur0toxine/vegapokerbot/pkg/fsm" "github.com/mymmrac/telego" tu "github.com/mymmrac/telego/telegoutil" ) const WaitingForMemberWebhookStateID fsm.StateID = "waiting_for_member_webhook" type WaitingForMemberWebhookState struct { State } func NewWaitingForMemberWebhookState(app iface.App) fsm.IState[Wizard] { return &WaitingForMemberWebhookState{newBase(app)} } func (s *WaitingForMemberWebhookState) Handle(pl *Wizard, mc fsm.MachineControls[*Wizard]) { cm := pl.Data.MyChatMember if !cm.OldChatMember.MemberIsMember() && cm.OldChatMember.MemberUser().ID == s.App.TGProfile().ID && cm.NewChatMember.MemberIsMember() && cm.NewChatMember.MemberUser().ID == s.App.TGProfile().ID { s.Move(mc, AddChatMemberStateID, pl) return } if cm.OldChatMember.MemberIsMember() && cm.OldChatMember.MemberUser().ID == s.App.TGProfile().ID && !cm.NewChatMember.MemberIsMember() && cm.NewChatMember.MemberUser().ID == s.App.TGProfile().ID { s.Move(mc, RemoveChatMemberStateID, pl) return } s.LogError(s.App.TG().LeaveChat(&telego.LeaveChatParams{ ChatID: tu.ID(pl.Data.MyChatMember.Chat.ID), })) } func (s *WaitingForMemberWebhookState) ID() fsm.StateID { return WaitingForMemberWebhookStateID }