9 // ImageShow shows a stored image to the root's user. A configured bot sends it
10 // to its owner, and the tool result gives terminal clients its name and path.
11 type ImageShow struct {
16 // Show checks the stored name and bytes before any output. A refused Telegram
17 // photo goes as a document. An uncertain send is not repeated.
18 func (s *ImageShow) Show(ctx context.Context, name, caption string) (string, error) {
19 data, err := s.store.Read(name)
21 return "", fmt.Errorf("read image to show: %w", err)
24 path, err := filepath.Abs(filepath.Join(s.store.dir, name))
26 return "", fmt.Errorf("find image path: %w", err)
30 err = s.bot.api.SendImage(ctx, s.bot.owner, name, data, caption)
32 return "", fmt.Errorf("show Telegram image: %w", err)
36 return imageText([]string{name}, caption) + "\n" + path, nil