Skip to content

Telegram library support bot & userbot

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

techwiz37/techgram

Repository files navigation

Techgram

TypeScript/JavaScript library untuk membangun Telegram client di Node.js dan Bun

📚 Dokumentasi Lengkap | 💬 Discussion Chat | 📢 Channel | 👨‍💻 Developer | 📄 License

Fitur Utama

  • Node.js & Bun. Mendukung Node.js dan Bun dengan ESM dan CommonJS.
  • Type-safe. Dibangun dengan TypeScript dengan type definitions yang akurat.
  • Mudah Digunakan. Menyediakan high-level API di atas Telegram API.
  • Extensible. Sistem middleware memungkinkan integrasi dengan kode eksternal.

Catatan: Techgram belum mencapai versi 1.0.0. Meskipun dapat berjalan di production, kami saat ini tidak merekomendasikan untuk digunakan pada proyek-proyek kritis.

Instalasi

1. Tambahkan ke package.json

ES Modules (ESM):

{
  "name": "my-telegram-bot",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "@techwiz/techgram": "github:techwiz37/techgram"
  }
}

CommonJS:

{
  "name": "my-telegram-bot",
  "version": "1.0.0",
  "type": "commonjs",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "@techwiz/techgram": "github:techwiz37/techgram"
  }
}

2. Install Dependencies

npm install

Atau dengan Bun:

bun add github:techwiz37/techgram

Memulai

Bot (Bot Token)

Menggunakan Environment Variables (Tanpa CLI):

export BOT_TOKEN="YOUR_BOT_TOKEN"
export API_ID=12345678
export API_HASH="your_api_hash"
const { Client, StorageMemory } = require("@techwiz/techgram");

const client = new Client({
  apiId: parseInt(process.env.API_ID || "0"),
  apiHash: process.env.API_HASH || "",
  storage: new StorageMemory(),
});

await client.connect();
await client.start();

client.on("message", async (ctx) => {
  if (ctx.message.text === "/start") {
    await ctx.reply("Halo!");
  }
});

Atau dengan Parameter Langsung:

const { Client, StorageMemory } = require("@techwiz/techgram");

const client = new Client({
  apiId: 12345678,
  apiHash: "your_api_hash",
  storage: new StorageMemory(),
});

await client.connect();
await client.start({
  botToken: "YOUR_BOT_TOKEN"
});

client.on("message", async (ctx) => {
  if (ctx.message.text === "/start") {
    await ctx.reply("Halo!");
  }
});

User Account (Bukan Bot)

Menggunakan Environment Variables:

export PHONE_NUMBER="+1234567890"
export VERIFICATION_CODE="12345"
export PASSWORD="your_password"
export API_ID=12345678
export API_HASH="your_api_hash"
const { Client, StorageMemory } = require("@techwiz/techgram");

const client = new Client({
  apiId: parseInt(process.env.API_ID || "0"),
  apiHash: process.env.API_HASH || "",
  storage: new StorageMemory(),
});

await client.connect();
await client.start();

client.on("message", async (ctx) => {
  if (ctx.message.text === "/start") {
    await ctx.reply("Halo dari user account!");
  }
});

Atau dengan Parameter Langsung:

const { Client, StorageMemory } = require("@techwiz/techgram");

const client = new Client({
  apiId: 12345678,
  apiHash: "your_api_hash",
  storage: new StorageMemory(),
});

await client.connect();
await client.start({
  phone: "+1234567890",
  code: "12345",
  password: "your_password"
});

client.on("message", async (ctx) => {
  if (ctx.message.text === "/start") {
    await ctx.reply("Halo dari user account!");
  }
});

Catatan: Untuk user account, jika akun memiliki 2FA (Two-Factor Authentication), Anda perlu menyediakan PASSWORD. Jika tidak, cukup PHONE_NUMBER dan VERIFICATION_CODE.

License

Techgram dibuat open-source di bawah GNU Lesser General Public License version 3, atau sesuai pilihan Anda, versi yang lebih baru. Lihat COPYING dan COPYING.LESSER untuk detail lebih lanjut.

About

Telegram library support bot & userbot

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published