adrianwijaya584 / telegram-bot-ts

Telegram bot example using typescript language and telegraf as the library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telegraf with TS

Contents

Description

This repository is just a small project in my free time. You can clone this repo and use it as you liked ;).

How To Use

Create bot token

first you should open this link https://t.me/botfather, then you will see this chat room.

After that use /newbot then insert your bot name then add username for the bot it should end with bot. so for the example is Testbotforgithub_bot. Foila you've made your own bot. Please secure and store your HTTP API Token.

clone project

to clone project open terminal or CMD and type git clone https://github.com/adrianwijaya584/telegram-bot-ts.git --branch=master folder_name you can add folder_name as you liked. ex: telebots.

config environment

After cloning the project you will see

what is next

Development

you need nodemon npm i -g nodemon

Production with PM2

If you want to use pm2 for production you should install pm2 in your server or pc first using npm i -g pm2. Then you will see pm2.config.json file.

Typescript can't run plainly on node js so we have to build it into js file so type npm run build and you will see build folder generated in the project.

Then type pm2 start pm2.config.json in your terminal/cmd. The prod with pm2 is finished.

  • Tips :

You can use pm2 save for saving current process list so if your server is down you just have to use pm2 resurrect to bring back process so you don't have to search pm2 configuration one by one.

to restart or reload you can use pm2 restart or pm2 reload you can read the differnce here !

Production with Docker

coming soon for docker configuration

About

Telegram bot example using typescript language and telegraf as the library.


Languages

Language:TypeScript 92.2%Language:JavaScript 4.4%Language:Dockerfile 2.7%Language:Shell 0.7%