From 5fb46b722d5fbeea5df65b49e883640e51f41135 Mon Sep 17 00:00:00 2001 From: Damon To Date: Sun, 16 Jun 2024 14:16:25 +0800 Subject: [PATCH] chore: update lpac version --- internal/app/handler/modem.go | 4 ++++ internal/app/handler/profile.go | 2 +- internal/pkg/lpac/notification.go | 4 ++-- internal/pkg/lpac/profile.go | 16 ++++++++-------- internal/pkg/util/euicc.go | 4 ++-- main.go | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/internal/app/handler/modem.go b/internal/app/handler/modem.go index c9b6a4c..9e0c136 100644 --- a/internal/app/handler/modem.go +++ b/internal/app/handler/modem.go @@ -45,6 +45,10 @@ EID: %s } m.Lock() info, err := lpac.NewCmd(context.Background(), usbDevice).Info() + ns, _ := lpac.NewCmd(context.Background(), usbDevice).NotificationList() + for _, n := range ns { + fmt.Println(n.ICCID) + } m.Unlock() if err != nil { slog.Error("failed to get eUICC info", "error", err) diff --git a/internal/app/handler/profile.go b/internal/app/handler/profile.go index 2e31f60..e8cfb44 100644 --- a/internal/app/handler/profile.go +++ b/internal/app/handler/profile.go @@ -64,7 +64,7 @@ func (h *ProfileHandler) Handle(c telebot.Context) error { }) } -func (h *ProfileHandler) toTextMessage(c telebot.Context, profiles []lpac.Profile) (string, *telebot.ReplyMarkup) { +func (h *ProfileHandler) toTextMessage(c telebot.Context, profiles []*lpac.Profile) (string, *telebot.ReplyMarkup) { selector := &telebot.ReplyMarkup{} template := ` %s *%s* diff --git a/internal/pkg/lpac/notification.go b/internal/pkg/lpac/notification.go index 1647a36..f0a5934 100644 --- a/internal/pkg/lpac/notification.go +++ b/internal/pkg/lpac/notification.go @@ -19,8 +19,8 @@ const ( NotificationProfileManagementOperationDelete = "delete" ) -func (c *Cmd) NotificationList() ([]Notification, error) { - var notifications []Notification +func (c *Cmd) NotificationList() ([]*Notification, error) { + var notifications []*Notification if err := c.Run([]string{"notification", "list"}, ¬ifications, nil); err != nil { return notifications, err } diff --git a/internal/pkg/lpac/profile.go b/internal/pkg/lpac/profile.go index a537a03..bc49780 100644 --- a/internal/pkg/lpac/profile.go +++ b/internal/pkg/lpac/profile.go @@ -32,18 +32,18 @@ var ( ErrProfileNotFound = errors.New("profile not found") ) -func (c *Cmd) ProfileList() ([]Profile, error) { - var profiles []Profile +func (c *Cmd) ProfileList() ([]*Profile, error) { + var profiles []*Profile if err := c.Run([]string{"profile", "list"}, &profiles, nil); err != nil { return profiles, err } return profiles, nil } -func (c *Cmd) ProfileInfo(ICCID string) (Profile, error) { - var profiles []Profile +func (c *Cmd) ProfileInfo(ICCID string) (*Profile, error) { + var profiles []*Profile if err := c.Run([]string{"profile", "list"}, &profiles, nil); err != nil { - return Profile{}, err + return nil, err } for _, profile := range profiles { @@ -51,7 +51,7 @@ func (c *Cmd) ProfileInfo(ICCID string) (Profile, error) { return profile, nil } } - return Profile{}, ErrProfileNotFound + return nil, ErrProfileNotFound } func (c *Cmd) ProfileDownload(activationCode *ActivationCode, progress Progress) error { @@ -138,8 +138,8 @@ func (c *Cmd) ProfileSetNickname(ICCID string, nickname string) error { return c.Run([]string{"profile", "nickname", ICCID, nickname}, nil, nil) } -func (c *Cmd) ProfileDiscovery() ([]DiscoveryResponse, error) { - var response []DiscoveryResponse +func (c *Cmd) ProfileDiscovery() ([]*DiscoveryResponse, error) { + var response []*DiscoveryResponse if err := c.Run([]string{"profile", "discovery"}, &response, nil); err != nil { return response, err } diff --git a/internal/pkg/util/euicc.go b/internal/pkg/util/euicc.go index 837fb1e..db88e91 100644 --- a/internal/pkg/util/euicc.go +++ b/internal/pkg/util/euicc.go @@ -35,8 +35,8 @@ type CertificateIssuer struct { Name string `json:"name"` } -var certificateIssuers []CertificateIssuer -var EUMs []EUM +var certificateIssuers []*CertificateIssuer +var EUMs []*EUM func init() { if err := json.Unmarshal(eum, &EUMs); err != nil { diff --git a/main.go b/main.go index ee2d3e5..8916cf9 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ func init() { flag.StringVar(&config.C.BotToken, "bot-token", "", "telegram bot token") flag.Int64Var(&config.C.AdminId, "admin-id", 0, "telegram admin id") - flag.StringVar(&config.C.Version, "version", "v2.0.1", "the version of lpac to download") + flag.StringVar(&config.C.Version, "version", "v2.0.2", "the version of lpac to download") flag.StringVar(&config.C.Dir, "dir", dir, "the directory to store lpac") flag.BoolVar(&config.C.DontDownload, "dont-download", false, "don't download lpac binary") flag.BoolVar(&config.C.Verbose, "verbose", false, "enable verbose mode")