Telegram bot to welcome new makers at the MakersUPV oficial Telegram group. The bot is program in NodeJS using Telegraf.
In order to develop new features for the MakersUPV Telegram bot there is a process that needs to be follow.
- First fork this Github repository to your own Github account
- Then clone this repository to your local environment and create a new branch named as follow:
- If it is a new feature: user-feature-1
- If it is a path: user-path-1
- Make the changes you need and do the commits you need
- Then push the changes to your remote repository
- Go to Github and make a pull request to master/develop branch on the original MakersUPV repository.
In case of any doubt please be in contact with the maintainer jaimelaborda@gmail.com
In order to do some update to the code (add feature or correct some bugs) on the MakersUPV run environment it has been implemented a CI&CD (Continuous Integration & Deployment). This service runs on the background and will take care of deploying the code wherever a commit is merged into master branch. This is done by means of a service running on the Makers VPS that will take care of deploy update the new commit whenever Github Webhooks feature informs there is a new update (more info: https://github.com/backmeupplz/ci-ninja).
It is mandatory to ensure that the code runs perfectly without crashes. The responsible to accept the merge request will take care of that before merging to the master branch but it will be awsome if you could help him.
- Create a user to run the service with and clone the repo to the production environment, this can be either a VPS running NodeJS or a local remote server. Please take into account that the server must have Internet connection in order to communicate with Telegram bot API.
sudo useradd newmakerbot
sudo passwd newmakerbot
cd /home/newmakerbot
git clone https://github.com/makers-upv/newmakerbot.git
-
Run npm install to install all the dependencies on the running environment (npm & NodeJS have to be installed):
npm install
That will download and install all the dependencies and will create the node_modules folder.
-
Create a .env file where Telegram API TOKEN will be store. It could be also use to add new future updates and features that needs environment configurations as tokens, passwords or others. There is a sample.env as a template. Run the following
cd newmakerbot
cp sample.env .env
vi .env
- Edit .env file with the Bothfather Telegram Token:
TELEGRAM_BOT_TOKEN=BotFather_token_goes_here
- Change owner privilege and make newmakerbot.js executable:
sudo chown newmakerbot:newmakerbot /home/newmakerbot/newmakerbot/*
sudo chmod -x /home/newmakerbot/newmakerbot/newmakerbot.js
- Create a systemd file to run it as a service:
vi /lib/systemd/system/newmakerbot.servicev
Copy the following and save the file (with :wq):
[Unit]
Description=Telegram bot
Documentation=https://github.com/makers-upv/newmakerbot
After=network.target
[Service]
#Environment=NODE_PORT=3001
Type=simple
User=newmakerbot
WorkingDirectory=/home/newmakerbot/newmakerbot
ExecStart=/usr/bin/node -r dotenv/config /home/newmakerbot/newmakerbot/newmakerbot.js
Restart=on-failure
StartLimitInterval=300
[Install]
WantedBy=multi-user.target
- Update systemd and run the service:
sudo systemctl daemon-reload
sudo systemctl start newmakerbot
- Check that the status is active (running):
● newmakerbot.service - Telegram bot
Loaded: loaded (/lib/systemd/system/newmakerbot.service; disabled; vendor pre
Active: active (running) since Sat 2018-10-27 12:18:19 CEST; 4 days ago
Docs: https://github.com/makers-upv/newmakerbot
Main PID: 11221 (node)
Tasks: 10
Memory: 19.7M
CPU: 16.963s
CGroup: /system.slice/newmakerbot.service
└─11221 /usr/bin/node -r dotenv/config /home/newmakerbot/newmakerbot/