/aoitelegram

A powerful package to create Telegram Bots with built-in string functions

Primary LanguageTypeScriptOtherNOASSERTION

AoiTelegram

NPM Version Bot API NPM Downloads License

aoitelegram is a JavaScript/TypeScript library for creating Telegram bots with ease. It simplifies the process of building and managing Telegram bot functionality, similar to aoijs but tailored for Telegram.

Features

  • Over 200 Pre-built Functions: aoitelegram comes equipped with more than 200 pre-built functions, empowering you to effortlessly create dynamic and interactive Telegram bots.

  • Built-in Custom Function System: aoitelegram has very good support for custom functions. Besides, aoitelegram has classes for working with extensions that you can create.

  • CommonJS/ESM Support: aoitelegram now supports modules like CommonJS/ESM for more convenient development on NodeJS.

  • User-Friendly Design: aoitelegram is perfect for beginners with its straightforward function interface. The $ prefix simplifies command writing, ensuring a swift launch for your bot. 🚀

Starting from v1, aoitelegram has an improved parser/interpreter that ensures proper functioning of $if/$else/$endif similar to bdfd.

Installation

To use aoitelegram in your project, you can install it via npm:

npm install aoitelegram

Usage

Here's a quick example of how to use aoitelegram to create a Telegram bot:

// CommonJS
const { AoiClient, LoadCommands } = require("aoitelegram");
// Esm/TypeScript
import { AoiClient, LoadCommands } from "aoitelegram";

const bot = new AoiClient("YOUR_BOT_TOKEN_HERE", {
  /** Optional request options for fetch **/
  telegram?: RequestInit;
  /** Functions that will be removed from the library's loading functions. **/
  disableFunctions?: string[],
  /** An array of AoiExtension functions **/
  extension?: AoiExtension[],
  /** For the error handler of functions **/
  functionError?: boolean,
  /** To disable text errors **/
  sendMessageError?: boolean,
  /** Outputting system messages to the console. **/
  logging?: boolean,
  /** Auto register bot commands **/
  myCommands?: {
    /** Allow command registration **/
    register?: boolean,
    /** An object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. */
    scope?: BotCommandScope,
   /** A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands */
    language_code?: string,
  },
  /** Checks for available package updates and performs an update if enabled **/
  autoUpdate?: {
    /** Displaying messages about new versions. **/
    aoiWarning?: boolean,
    /**  Whether automatic updates are enabled. **/
    autoUpdate?: boolean,
    /** Whether to enable development versions. **/
    enableDev?: boolean,
    /** Whether to enable beta versions. **/
    enableBeta?: boolean,
  },
});

bot.functionErrorCommand({
  code: `$sendMessage[Sorry, but there was an error in the $handleError[function] function within the $handleError[command] command: $handleError[error]]`,
});

bot.readyCommand({
  code: `$print[Starting @$getMe[username]]`,
});

bot.messageCommand({
  code: `$print[Message Handle]`,
});

bot.callbackQueryCommand({
  code: `$print[Action Handle]`,
});

// Define a command to print a message.
bot.addCommand({
  command: "say",
  code: `$replyMessage[$message]`,
});

// Define a command to check the bot's ping.
bot.addCommand({
  command: "ping",
  code: `$replyMessage[Bot ping: $pingms]`,
});

// Define a command to display bot information.
bot.addCommand({
  command: "botinfo",
  code: `
$replyMessage[
Bot ID: $getMe[id]
Name: $getMe[first_name]
Username: $getMe[username]
Ping: $pingms
]`,
});

const loader = new LoadCommands(bot);
loader.loadCommands("./command/");

bot.connect();

Documentation

For detailed documentation and usage instructions, please refer to the aoitelegram Wiki.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please create a GitHub issue or submit a pull request. Additionally, feel free to reach out to me on Telegram via my group AoiTelegram or on Discord using my username sempaika_chess.

Asayukiii gdeVanezus