grammy-media-groups 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/mod.d.ts CHANGED
@@ -61,8 +61,8 @@ export type MediaGroupsFlavor = {
61
61
  *
62
62
  * @param messages Array of messages belonging to a media group
63
63
  * @param options Optional overrides: caption, parse_mode, caption_entities,
64
- * show_caption_above_media (first item only when caption is set),
65
- * has_spoiler (all photo/video items)
64
+ * (first item only when caption is set),
65
+ * show_caption_above_media, has_spoiler (all photo/video items)
66
66
  * @returns An array of `MediaGroupInputMedia` objects ready to be sent
67
67
  */
68
68
  toInputMedia: (messages: Message[], options?: ToInputMediaOptions) => MediaGroupInputMedia[];
package/out/storage.d.ts CHANGED
@@ -36,7 +36,8 @@ export interface ToInputMediaOptions {
36
36
  caption_entities?: MessageEntity[];
37
37
  /**
38
38
  * Show caption above the media.
39
- * Only applied when `caption` is provided (first item).
39
+ * Applied to all photo and video items for consistency.
40
+ * When not set, the value from the original messages is used.
40
41
  */
41
42
  show_caption_above_media?: boolean;
42
43
  /** Mark media as containing a spoiler (applies to all photo and video items). */
@@ -51,9 +52,9 @@ export interface ToInputMediaOptions {
51
52
  * Unsupported message types (e.g. animation) are silently skipped.
52
53
  *
53
54
  * @param messages Array of messages belonging to a media group
54
- * @param options Optional overrides: caption, parse_mode, caption_entities,
55
- * show_caption_above_media (all first item only when caption is set),
56
- * has_spoiler (all photo/video items)
55
+ * @param options Optional overrides: caption, parse_mode, caption_entities
56
+ * (all first item only when caption is set),
57
+ * show_caption_above_media, has_spoiler (all photo/video items)
57
58
  * @returns An array of `MediaGroupInputMedia` objects ready to be sent
58
59
  *
59
60
  * @example
package/out/storage.js CHANGED
@@ -46,9 +46,9 @@ export async function storeMessages(adapter, messages) {
46
46
  * Unsupported message types (e.g. animation) are silently skipped.
47
47
  *
48
48
  * @param messages Array of messages belonging to a media group
49
- * @param options Optional overrides: caption, parse_mode, caption_entities,
50
- * show_caption_above_media (all first item only when caption is set),
51
- * has_spoiler (all photo/video items)
49
+ * @param options Optional overrides: caption, parse_mode, caption_entities
50
+ * (all first item only when caption is set),
51
+ * show_caption_above_media, has_spoiler (all photo/video items)
52
52
  * @returns An array of `MediaGroupInputMedia` objects ready to be sent
53
53
  *
54
54
  * @example
@@ -73,6 +73,9 @@ export async function storeMessages(adapter, messages) {
73
73
  */
74
74
  export function toInputMedia(messages, options = {}) {
75
75
  const { has_spoiler } = options;
76
+ const show_caption_above_media = options.show_caption_above_media ??
77
+ messages.find((m) => m.show_caption_above_media)
78
+ ?.show_caption_above_media;
76
79
  return messages.map((msg, i) => {
77
80
  const hasCaption = options.caption !== undefined && i === 0;
78
81
  const base = {
@@ -81,11 +84,8 @@ export function toInputMedia(messages, options = {}) {
81
84
  caption_entities: hasCaption
82
85
  ? options.caption_entities
83
86
  : msg.caption_entities,
84
- show_caption_above_media: hasCaption
85
- ? options.show_caption_above_media
86
- : msg.show_caption_above_media,
87
87
  };
88
- const visual = { ...base, has_spoiler };
88
+ const visual = { ...base, show_caption_above_media, has_spoiler };
89
89
  switch (true) {
90
90
  case "photo" in msg:
91
91
  return InputMediaBuilder.photo(msg.photo.at(-1).file_id, visual);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grammy-media-groups",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Media Groups Storage Plugin for grammY",
5
5
  "homepage": "https://github.com/PonomareVlad/grammy-media-groups",
6
6
  "main": "./out/mod.js",