TypeScript/JavaScript library untuk membangun Telegram client di Node.js dan Bun
📚 Dokumentasi Lengkap | 💬 Discussion Chat | 📢 Channel | 👨💻 Developer | 📄 License
- 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.
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"
}
}npm installAtau dengan Bun:
bun add github:techwiz37/techgramMenggunakan 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!");
}
});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.
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.