@grom.js/effect-tg 0.11.0 → 0.13.0

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # effect-tg
2
2
 
3
3
  [![Effectful](https://img.shields.io/badge/Yes.-%23fff?style=flat&logo=effect&logoColor=%23000&logoSize=auto&label=Effect%3F&labelColor=%23fff&color=%23000)](https://effect.website/)
4
- [![Bot API](https://img.shields.io/badge/v9.4-%23fff?style=flat&logo=telegram&logoColor=%2325A3E1&logoSize=auto&label=Bot%20API&labelColor=%23fff&color=%2325A3E1)](https://core.telegram.org/bots/api)
4
+ [![Bot API](https://img.shields.io/badge/v9.5-%23fff?style=flat&logo=telegram&logoColor=%2325A3E1&logoSize=auto&label=Bot%20API&labelColor=%23fff&color=%2325A3E1)](https://core.telegram.org/bots/api)
5
5
  [![npm](https://img.shields.io/npm/v/%40grom.js%2Feffect-tg?style=flat&logo=npm&logoColor=%23BB443E&logoSize=auto&label=Latest&labelColor=%23fff&color=%23BB443E)](https://www.npmjs.com/package/@grom.js/effect-tg)
6
6
  [![codecov](https://img.shields.io/codecov/c/github/grom-dev/effect-tg?style=flat&logo=codecov&logoColor=%23f07&label=Coverage&labelColor=%23fff&color=%23f07)](https://codecov.io/gh/grom-dev/effect-tg)
7
7
 
@@ -72,7 +72,7 @@ const program = Effect.gen(function* () {
72
72
 
73
73
  `BotApi` has a layered architecture:
74
74
 
75
- ```
75
+ ```text
76
76
  ┌• BotApi — typed interface that delegates calls to BotApiTransport.
77
77
  └─┬• BotApiTransport — serializes parameters, sends HTTP requests, parses responses.
78
78
  ├──• BotApiUrl — constructs endpoint URLs to methods and files.
@@ -441,6 +441,38 @@ Benefits of using JSX:
441
441
 
442
442
  `Text.tgx` function accepts a JSX element and returns an instance of `Text.Tgx`, which can then be used as a content of a message.
443
443
 
444
+ <details>
445
+ <summary>How to enable?</summary>
446
+
447
+ 1. Install `@grom.js/tgx` package:
448
+
449
+ ```sh
450
+ npm install @grom.js/tgx
451
+ ```
452
+
453
+ 2. Update your `tsconfig.json`:
454
+
455
+ ```json
456
+ {
457
+ "compilerOptions": {
458
+ "jsx": "react-jsx",
459
+ "jsxImportSource": "@grom.js/tgx"
460
+ }
461
+ }
462
+ ```
463
+
464
+ </details>
465
+
466
+ <details>
467
+ <summary>How it works?</summary>
468
+
469
+ JSX is just syntactic sugar transformed by the compiler.
470
+ Result of transformation depends on the JSX runtime.
471
+ `effect-tg` relies on JSX runtime from [`@grom.js/tgx`](https://github.com/grom-dev/tgx), which transforms JSX elements to `TgxElement` instances.
472
+ When `Send.sendMessage` encounters an instance of `Text.Tgx`, it converts inner `TgxElement`s to the parameters for a `send*` method.
473
+
474
+ </details>
475
+
444
476
  **Example:** Composing reusable messages with JSX.
445
477
 
446
478
  ```tsx
@@ -500,32 +532,3 @@ const publish = Send.message(Content.text(summary)).pipe(
500
532
  Send.to(Dialog.channel(3011378744)),
501
533
  )
502
534
  ```
503
-
504
- <details>
505
- <summary>How it works?</summary>
506
-
507
- JSX is just syntactic sugar transformed by the compiler.
508
- Result of transformation depends on the JSX runtime.
509
- `effect-tg` relies on JSX runtime from [`@grom.js/tgx`](https://github.com/grom-dev/tgx), which transforms JSX elements to `TgxElement` instances.
510
- When `Send.sendMessage` encounters an instance of `Text.Tgx`, it converts inner `TgxElement`s to the parameters for a `send*` method.
511
-
512
- </details>
513
-
514
- To enable JSX support:
515
-
516
- 1. Install `@grom.js/tgx` package:
517
-
518
- ```sh
519
- npm install @grom.js/tgx
520
- ```
521
-
522
- 2. Update your `tsconfig.json`:
523
-
524
- ```json
525
- {
526
- "compilerOptions": {
527
- "jsx": "react-jsx",
528
- "jsxImportSource": "@grom.js/tgx"
529
- }
530
- }
531
- ```
package/dist/Text.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TgxElement } from '@grom.js/tgx/types';
1
+ import type { TgxElement } from '@grom.js/tgx';
2
2
  import type { Types } from './BotApi.ts';
3
3
  /**
4
4
  * Formatted text.
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../src/Text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC;;GAEG;AACH,MAAM,MAAM,IAAI,GACZ,KAAK,GACL,IAAI,GACJ,QAAQ,GACR,GAAG,CAAA;;;;AAEP,qBAAa,KAAM,SAAQ,WAA0B;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;CACtC,CAAC;CAAG;;;;AAEL,qBAAa,IAAK,SAAQ,UAAyB;IACjD,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;CAAG;;;;AAEL,qBAAa,QAAS,SAAQ,cAA6B;IACzD,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAC;CAAG;;;;AAEL,qBAAa,GAAI,SAAQ,SAAwB;IAC/C,GAAG,EAAE,UAAU,CAAA;CAChB,CAAC;CAAG;AAIL,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,EACZ,WAAW,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KACpC,KAAsC,CAAA;AAEzC,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,IAA0B,CAAA;AAE9D,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,KAAG,QAAsC,CAAA;AAElF,eAAO,MAAM,GAAG,GAAI,KAAK,UAAU,KAAG,GAAuB,CAAA"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../src/Text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC;;GAEG;AACH,MAAM,MAAM,IAAI,GACZ,KAAK,GACL,IAAI,GACJ,QAAQ,GACR,GAAG,CAAA;;;;AAEP,qBAAa,KAAM,SAAQ,WAA0B;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;CACtC,CAAC;CAAG;;;;AAEL,qBAAa,IAAK,SAAQ,UAAyB;IACjD,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;CAAG;;;;AAEL,qBAAa,QAAS,SAAQ,cAA6B;IACzD,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAC;CAAG;;;;AAEL,qBAAa,GAAI,SAAQ,SAAwB;IAC/C,GAAG,EAAE,UAAU,CAAA;CAChB,CAAC;CAAG;AAIL,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,EACZ,WAAW,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KACpC,KAAsC,CAAA;AAEzC,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,IAA0B,CAAA;AAE9D,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,KAAG,QAAsC,CAAA;AAElF,eAAO,MAAM,GAAG,GAAI,KAAK,UAAU,KAAG,GAAuB,CAAA"}
@@ -81,7 +81,7 @@ export interface BotApi {
81
81
  sendChecklist: BotApiMethod<'sendChecklist'>;
82
82
  /** Use this method to send an animated emoji that will display a random value. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
83
83
  sendDice: BotApiMethod<'sendDice'>;
84
- /** Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns _True_ on success. */
84
+ /** Use this method to stream a partial message to a user while the message is being generated. Returns _True_ on success. */
85
85
  sendMessageDraft: BotApiMethod<'sendMessageDraft'>;
86
86
  /**
87
87
  * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns _True_ on success.
@@ -115,6 +115,8 @@ export interface BotApi {
115
115
  promoteChatMember: BotApiMethod<'promoteChatMember'>;
116
116
  /** Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns _True_ on success. */
117
117
  setChatAdministratorCustomTitle: BotApiMethod<'setChatAdministratorCustomTitle'>;
118
+ /** Use this method to set a tag for a regular member in a group or a supergroup. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_tags_ administrator right. Returns _True_ on success. */
119
+ setChatMemberTag: BotApiMethod<'setChatMemberTag'>;
118
120
  /** Use this method to ban a channel chat in a supergroup or a channel. Until the chat is [unbanned](https://core.telegram.org/bots/api#unbanchatsenderchat), the owner of the banned chat won't be able to send messages on behalf of **any of their channels**. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
119
121
  banChatSenderChat: BotApiMethod<'banChatSenderChat'>;
120
122
  /** Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
@@ -660,6 +662,8 @@ export declare namespace Types {
660
662
  sender_boost_count?: number;
661
663
  /** The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account. */
662
664
  sender_business_bot?: Types.User;
665
+ /** Tag or custom title of the sender of the message; for supergroups only */
666
+ sender_tag?: string;
663
667
  /** Date the message was sent in Unix time. It is always a positive number, representing a valid date. */
664
668
  date: number;
665
669
  /** Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier. */
@@ -692,7 +696,7 @@ export declare namespace Types {
692
696
  is_from_offline?: true;
693
697
  /** _True_, if the message is a paid post. Note that such posts must not be deleted for 24 hours to receive the payment and can't be edited. */
694
698
  is_paid_post?: true;
695
- /** The unique identifier of a media message group this message belongs to */
699
+ /** The unique identifier inside this chat of a media message group this message belongs to */
696
700
  media_group_id?: string;
697
701
  /** Signature of the post author for messages in channels, or the custom title of an anonymous group administrator */
698
702
  author_signature?: string;
@@ -854,7 +858,7 @@ export declare namespace Types {
854
858
  video_chat_participants_invited?: Types.VideoChatParticipantsInvited;
855
859
  /** Service message: data sent by a Web App */
856
860
  web_app_data?: Types.WebAppData;
857
- /** Inline keyboard attached to the message. `login_url` buttons are represented as ordinary `url` buttons. */
861
+ /** [Inline keyboard](https://core.telegram.org/bots/features#inline-keyboards) attached to the message. `login_url` buttons are represented as ordinary `url` buttons. */
858
862
  reply_markup?: Types.InlineKeyboardMarkup;
859
863
  }
860
864
  /** This object represents a unique message identifier. */
@@ -880,8 +884,8 @@ export declare namespace Types {
880
884
  type MaybeInaccessibleMessage = Types.Message | Types.InaccessibleMessage;
881
885
  /** This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. */
882
886
  interface MessageEntity {
883
- /** Type of the entity. Currently, can be “mention” (`@username`), “hashtag” (`#hashtag` or `#hashtag@chatusername`), “cashtag” (`$USD` or `$USD@chatusername`), “bot\_command” (`/start@jobs_bot`), “url” (`https://telegram.org`), “email” (`do-not-reply@telegram.org`), “phone\_number” (`+1-212-555-0123`), “bold” (**bold text**), “italic” (_italic text_), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable\_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text\_link” (for clickable text URLs), “text\_mention” (for users [without usernames](https://telegram.org/blog/edit#new-mentions)), “custom\_emoji” (for inline custom emoji stickers) */
884
- type: 'mention' | 'hashtag' | 'cashtag' | 'bot_command' | 'url' | 'email' | 'phone_number' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'blockquote' | 'expandable_blockquote' | 'code' | 'pre' | 'text_link' | 'text_mention' | 'custom_emoji';
887
+ /** Type of the entity. Currently, can be “mention” (`@username`), “hashtag” (`#hashtag` or `#hashtag@chatusername`), “cashtag” (`$USD` or `$USD@chatusername`), “bot\_command” (`/start@jobs_bot`), “url” (`https://telegram.org`), “email” (`do-not-reply@telegram.org`), “phone\_number” (`+1-212-555-0123`), “bold” (**bold text**), “italic” (_italic text_), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable\_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text\_link” (for clickable text URLs), “text\_mention” (for users [without usernames](https://telegram.org/blog/edit#new-mentions)), “custom\_emoji” (for inline custom emoji stickers), or “date\_time” (for formatted date and time) */
888
+ type: 'mention' | 'hashtag' | 'cashtag' | 'bot_command' | 'url' | 'email' | 'phone_number' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'blockquote' | 'expandable_blockquote' | 'code' | 'pre' | 'text_link' | 'text_mention' | 'custom_emoji' | 'date_time';
885
889
  /** Offset in [UTF-16 code units](https://core.telegram.org/api/entities#entity-length) to the start of the entity */
886
890
  offset: number;
887
891
  /** Length of the entity in [UTF-16 code units](https://core.telegram.org/api/entities#entity-length) */
@@ -894,6 +898,10 @@ export declare namespace Types {
894
898
  language?: string;
895
899
  /** For “custom\_emoji” only, unique identifier of the custom emoji. Use [getCustomEmojiStickers](https://core.telegram.org/bots/api#getcustomemojistickers) to get full information about the sticker */
896
900
  custom_emoji_id?: string;
901
+ /** For “date\_time” only, the Unix time associated with the entity */
902
+ unix_time?: number;
903
+ /** For “date\_time” only, the string that defines the formatting of the date and time. See [date-time entity formatting](https://core.telegram.org/bots/api#date-time-entity-formatting) for more details. */
904
+ date_time_format?: string;
897
905
  }
898
906
  /** This object contains information about the quoted part of a message that is replied to by the given message. */
899
907
  interface TextQuote {
@@ -2093,6 +2101,8 @@ export declare namespace Types {
2093
2101
  can_manage_topics?: boolean;
2094
2102
  /** _True_, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only */
2095
2103
  can_manage_direct_messages?: boolean;
2104
+ /** _True_, if the administrator can edit the tags of regular members; for groups and supergroups only. If omitted defaults to the value of can\_pin\_messages. */
2105
+ can_manage_tags?: boolean;
2096
2106
  }
2097
2107
  /** This object represents changes in the status of a chat member. */
2098
2108
  interface ChatMemberUpdated {
@@ -2175,6 +2185,8 @@ export declare namespace Types {
2175
2185
  can_manage_topics?: boolean;
2176
2186
  /** _True_, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only */
2177
2187
  can_manage_direct_messages?: boolean;
2188
+ /** _True_, if the administrator can edit the tags of regular members; for groups and supergroups only. If omitted defaults to the value of can\_pin\_messages. */
2189
+ can_manage_tags?: boolean;
2178
2190
  /** Custom title for this user */
2179
2191
  custom_title?: string;
2180
2192
  }
@@ -2182,6 +2194,8 @@ export declare namespace Types {
2182
2194
  interface ChatMemberMember {
2183
2195
  /** The member's status in the chat, always “member” */
2184
2196
  status: 'member';
2197
+ /** Tag of the member */
2198
+ tag?: string;
2185
2199
  /** Information about the user */
2186
2200
  user: Types.User;
2187
2201
  /** Date when the user's subscription will expire; Unix time */
@@ -2191,6 +2205,8 @@ export declare namespace Types {
2191
2205
  interface ChatMemberRestricted {
2192
2206
  /** The member's status in the chat, always “restricted” */
2193
2207
  status: 'restricted';
2208
+ /** Tag of the member */
2209
+ tag?: string;
2194
2210
  /** Information about the user */
2195
2211
  user: Types.User;
2196
2212
  /** _True_, if the user is a member of the chat at the moment of the request */
@@ -2215,6 +2231,8 @@ export declare namespace Types {
2215
2231
  can_send_other_messages: boolean;
2216
2232
  /** _True_, if the user is allowed to add web page previews to their messages */
2217
2233
  can_add_web_page_previews: boolean;
2234
+ /** _True_, if the user is allowed to edit their own tag */
2235
+ can_edit_tag: boolean;
2218
2236
  /** _True_, if the user is allowed to change the chat title, photo and other settings */
2219
2237
  can_change_info: boolean;
2220
2238
  /** _True_, if the user is allowed to invite new users to the chat */
@@ -2279,6 +2297,8 @@ export declare namespace Types {
2279
2297
  can_send_other_messages?: boolean;
2280
2298
  /** _True_, if the user is allowed to add web page previews to their messages */
2281
2299
  can_add_web_page_previews?: boolean;
2300
+ /** _True_, if the user is allowed to edit their own tag */
2301
+ can_edit_tag?: boolean;
2282
2302
  /** _True_, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */
2283
2303
  can_change_info?: boolean;
2284
2304
  /** _True_, if the user is allowed to invite new users to the chat */
@@ -3570,7 +3590,7 @@ export declare namespace Types {
3570
3590
  mime_type: 'application/pdf' | 'application/zip';
3571
3591
  /** Short description of the result */
3572
3592
  description?: string;
3573
- /** Inline keyboard attached to the message */
3593
+ /** [Inline keyboard](https://core.telegram.org/bots/features#inline-keyboards) attached to the message */
3574
3594
  reply_markup?: Types.InlineKeyboardMarkup;
3575
3595
  /** Content of the message to be sent instead of the file */
3576
3596
  input_message_content?: Types.InputMessageContent;
@@ -5115,7 +5135,7 @@ export interface MethodParams {
5115
5135
  message_effect_id?: string;
5116
5136
  /** An object for description of the message to reply to */
5117
5137
  reply_parameters?: Types.ReplyParameters;
5118
- /** An object for an inline keyboard */
5138
+ /** An object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards) */
5119
5139
  reply_markup?: Types.InlineKeyboardMarkup;
5120
5140
  };
5121
5141
  sendDice: {
@@ -5273,6 +5293,8 @@ export interface MethodParams {
5273
5293
  can_manage_topics?: boolean;
5274
5294
  /** Pass _True_ if the administrator can manage direct messages within the channel and decline suggested posts; for channels only */
5275
5295
  can_manage_direct_messages?: boolean;
5296
+ /** Pass _True_ if the administrator can edit the tags of regular members; for groups and supergroups only */
5297
+ can_manage_tags?: boolean;
5276
5298
  };
5277
5299
  setChatAdministratorCustomTitle: {
5278
5300
  /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */
@@ -5282,6 +5304,14 @@ export interface MethodParams {
5282
5304
  /** New custom title for the administrator; 0-16 characters, emoji are not allowed */
5283
5305
  custom_title: string;
5284
5306
  };
5307
+ setChatMemberTag: {
5308
+ /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */
5309
+ chat_id: number | string;
5310
+ /** Unique identifier of the target user */
5311
+ user_id: number;
5312
+ /** New tag for the member; 0-16 characters, emoji are not allowed */
5313
+ tag?: string;
5314
+ };
5285
5315
  banChatSenderChat: {
5286
5316
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
5287
5317
  chat_id: number | string;
@@ -5982,7 +6012,7 @@ export interface MethodParams {
5982
6012
  message_id: number;
5983
6013
  /** An object for the new checklist */
5984
6014
  checklist: Types.InputChecklist;
5985
- /** An object for the new inline keyboard for the message */
6015
+ /** An object for the new [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards) for the message */
5986
6016
  reply_markup?: Types.InlineKeyboardMarkup;
5987
6017
  };
5988
6018
  editMessageReplyMarkup: void | {
@@ -6443,6 +6473,7 @@ export interface MethodResults {
6443
6473
  restrictChatMember: true;
6444
6474
  promoteChatMember: true;
6445
6475
  setChatAdministratorCustomTitle: true;
6476
+ setChatMemberTag: true;
6446
6477
  banChatSenderChat: true;
6447
6478
  unbanChatSenderChat: true;
6448
6479
  setChatPermissions: true;