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
npx create-tgsnake-app myapp --ts
The command above will create a tgsnake app that is in the myapp
folder using the typescript language.
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 Name | Parameter | Description |
---|---|---|
--ts or --typescript | Create a tgsnake application using the typescript language. | |
--yarn or --use-yarn | Use yarn to install the required dependencies. | |
--npm or --use-npm | Use npm to install the required dependencies. | |
--pnpm or --use-pnpm | Use pnpm to install the required dependencies. | |
--rds or --use-redis-session | Create tgsnake app using @tgsnake/redis-session framework instead of built-in session. | |
--template | simple or composer or git(hub)? url | Use template provided or use git(hub)? url which will be cloned into that directory. |
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('message.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.