0.8.2 • Published 12 days ago

aoitelegram v0.8.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

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

  • Easy setup and configuration for Telegram bot integration.
  • Event-driven approach for handling ready events and messages.
  • Command management for defining and executing bot commands.
  • User session management with variables and tables.

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:

const { AoiClient, LoadCommands } = require("aoitelegram");

const aoijs = new AoiClient({
  token: "YOUR_BOT_TOKEN_HERE",
  telegram: {
    /** The maximum number of updates to fetch at once. Defaults to 100. */
    limit: 100,
    /** The timeout for long polling in seconds. Defaults to 60 seconds. */
    timeout: 60000,
    /** An array of allowed update types to receive. Defaults to all updates. */
    allowed_updates: [],
    /** An optional session object for managing user sessions  */
    session: {},
  },
  database: {
    /** The file path to the database storage. */
    path: "./database/",
    /** An array of table names within the database.*/
    table: ["main"],
    /** The file extension name used for the database file. */
    extname: ".sql",
  },
});

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

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

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

// Define a command to print a message.
aoijs.command({
  name: "say",
  code: `$sendMessage[$message]`,
});

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

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

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

// Set user variables in a table.
aoijs.variables(
  {
    sempai: 10,
    string: "Hello, world!",
    aoijs: true,
    webapp: false,
    mz: {},
  },
  "main",
);

// Connect to the Telegram service.
aoijs.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.

Important

aoitelegram utilizes the source code of the bds.js library.

1.0.0-beta.1

12 days ago

0.8.1

3 months ago

0.8.0

3 months ago

0.8.2

3 months ago

0.7.0

3 months ago

0.6.0

4 months ago

0.5.0

4 months ago

0.4.0-beta.1

4 months ago

0.4.0

4 months ago

0.3.0

5 months ago

0.2.0-beta.1

5 months ago

0.2.1

5 months ago

0.2.0

5 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.3-beta.1

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago