Getting Started

tgsnake

tgsnake is a MTProto framework for JavaScript or TypeScript with some special features and experience that you might not find in other frameworks.

💡

Warning! Before logging in using a Telegram account, I warn you that there is a possibility that your account will be suspended or banned by Telegram! Do with your own risk! Read FAQ for more information.

Quick Start

terminal
npx create-tgsnake-app myapp --ts

The command above will create a tgsnake app that is in the myapp folder using the typescript language.

terminal
create-tgsnake-app location [options]

location is where the tgsnake will be created. The location must be an empty folder. Otherwise it will fail to build the app.

Option NameParameterDescription
--ts or --typescriptCreate a tgsnake application using the typescript language.
--yarn or --use-yarnUse yarn to install the required dependencies.
--npm or --use-npmUse npm to install the required dependencies.
--pnpm or --use-pnpmUse pnpm to install the required dependencies.
--rds or --use-redis-sessionCreate tgsnake app using @tgsnake/redis-session framework instead of built-in session.
--templatesimple or composer or git(hub)? urlUse template provided or use git(hub)? url which will be cloned into that directory.

Instalalation

Installing tgsnake

terminal
npm i tgsnake@latest 

Create file

Create your index.ts file or index.js file and copy the example code.

index.ts
import { Snake, shutdown } from 'tgsnake';
 
// we no need to pass the option here, because we will use config file (tgsnake.config.js) const client = new Snake();
 
client.on('msg.text', (update) => { return update.msg?.reply('I hear You!'); });
 
client.run();
 

Simple things, when a ‘client’ receives updates in the form of a text message, the ‘client’ will reply with the message ‘I hear you!’ It work both for deno and nodejs.

Run your code

If you use TypeScript, then you need to compile it first.

terminal
node index.js