tgx-core Documentation

website·Indexed 29 days ago

https://tgx-core.js.org

Developer documentation for tgx-core, featuring a comprehensive API reference for interfaces, enumerations, and namespaces. Includes guides on managing Telegram bot clients, handling events, implementing commands, and utilizing auxiliaries and extensions.

Tokens
77.5K
Snippets
572
Records
724
Agent score
49%

What's inside tgx-core

  1. Overview of tgx-core for Telegram bots

    tgx-core is an object-oriented, modular, and flexible Node.js library designed for building Telegram bots. It provides approximately 99% coverage of the Telegram API, making it suitable for both experienced developers and server owners.
  2. Overview of tgx-core

    tgx-core is a customizable, modular, and object-oriented Node.js library designed for building Telegram bots. It provides approximately 99% coverage of the Telegram API, making it suitable for both experienced developers and server owners with minimal coding knowledge.
  3. QueryResultAudioPayload interface definition

    The QueryResultAudioPayload interface represents the payload for an audio result returned from a query. It contains metadata about the audio file, such as its URL, duration, and optional captions or reply markups.
    export interface QueryResultAudioPayload {
      id: string;
      audio_url: string;
      title: string;
      audio_duration?: number;
      caption?: string;
      caption_entities?: MessageEntities | MessageEntityPayload[];
      input_message_content?: InputMessageContent;
      parse_mode?: string;
      performer?: string;
      reply_markup?: InlineKeyboardMarkup;
      type?: "audio";
    }
  4. SuperGroupChat class overview

    The SuperGroupChat class extends BaseGroupChat and is used to represent and manage a Telegram supergroup. It provides access to members, messages, topics, and invite links, as well as methods to modify chat settings and send various types of messages.
    new SuperGroupChat(client, packet);
  5. Retrieve user data and profile photos

    Methods available to fetch detailed information about the ClientUser and their profile:
    // Refresh/get the current ClientUser object
    await clientUser.asyncget();
    
    // Get profile photos with pagination
    await clientUser.asyncgetProfilePhotos(offset, limit);
    
    // Get a specific business connection
    await clientUser.asyncgetBusinessConnection('business_connection_id');
    
    // Get the chat menu button
    await clientUser.asyncgetChatMenuButton(chatId, force);
  6. Use the QueryResultVideoPayload interface for video query results

    The QueryResultVideoPayload interface defines the structure of a video payload returned from a query. It includes metadata about the video (URL, dimensions, duration), optional captions with entity support, and display settings like whether the caption should appear above the media.
    export interface QueryResultVideoPayload {
      id: string;
      title: string;
      video_url: string;
      mime_type: "text/html" | "video/mp4";
      thumbnail_url: string;
      caption?: string;
      caption_entities?: MessageEntities | MessageEntityPayload[];
      description?: string;
      input_message_content?: InputMessageContent;
      parse_mode?: string;
      reply_markup?: InlineKeyboardMarkup;
      show_caption_above_media?: boolean;
      type?: "video";
      video_duration?: number;
      video_height?: number;
      video_width?: number;
    }
  7. Use the BusinessIntro interface for business introductions

    The BusinessIntro interface is used to represent a business introduction packet. It consists of a title, a text message, and an associated sticker file.
    export interface BusinessIntro {
      message: string;
      sticker: StickerFilePacket;
      title: string;
    }
  8. Use the InlineQueryPacket interface for inline queries

    The InlineQueryPacket interface represents an inline query sent by a user. It contains details about the user who sent the query, the query string itself, and optional context such as the chat type and location.
    export interface InlineQueryPacket {
      id: string;
      from: User;
      query: string;
      offset: string;
      chat_type?: "private" | "group" | "supergroup" | "channel";
      location?: LocationPacket;
    }
  9. Use the PollAnswerPacket interface for poll responses

    The PollAnswerPacket interface represents the data structure for a poll answer. It contains the identifier of the poll, the selected options, and optional information about the user and the chat where the vote occurred.
    export interface PollAnswerPacket {
      option_ids: number[];
      poll_id: string;
      user?: UserPacket;
      voter_chat?: ChatPacket;
    }
  10. Access PollAnswer properties and getters

    The PollAnswer class provides the following properties to retrieve information about a poll response:

    • id (number): The unique identifier of the poll answer.
    • poll (Poll): The poll object associated with this answer.
    • user (User | undefined): The user who cast the vote, if available.
    • voter_chat (SuperGroupChat | GroupChat | ChannelChat | PrivateChat | undefined): The chat where the vote was cast.
    • option_ids (number[]): An array of the IDs of the options selected by the user.
    • poll_id (string): The unique identifier of the poll.
    • client (Client): The client instance used to create this object.
  11. Use the PollAnswer class to handle poll responses

    The PollAnswer class represents a response to a poll. It extends BaseClass and implements PollAnswerPacket. It provides metadata about the poll, the user who voted, and the specific options selected.
    const answer = new PollAnswer(client, packet);