This project uses Feathers. An open source web framework for building modern real-time applications.
See Docs for many information
The Dockerfile is an alpine-aarch64 based image node.js, yarn and localtunnel.
Change the section FROM ... to fit your needs. The following command runs the default configuration:
$ docker run -t lunhg/assistente
But you can change:
$ docker run -t lunhg/assistente HOST=localhost PORT=3000 SUBDOMAIN=r4dar
Install dependencies first with npm or yarn.
npm install
yarn install
In your package.json, set the running mode, i.e, development, test, production or custom mode:
{
...
"scripts": {
"start": "NODE_ENV='<environment mode>' node src/"
}
...
}
Where, <environment mode> can be any json file found in config/ folder. These files are a set of configurations for database, express, passport, telegram, cookies, jwt and swagger. The default.json file is relative to development mode:
developmentmode: edit yourconfig/default.jsonproductionmode: edit yourconfig/production.jsoncustommode: edit yourconfig/<custom mode>.json
Among serveral configurations made by default, you will need to setup some credentials:
- your Telegram username, telegram token and bot administrators:;
- your database access credentials;
- open id credentials;
So, cp .env.template .env and do properly changes:
TELEGRAM_USERNAME=<BOT>
TELEGRAM_TOKEN=<TOKEN>
TELEGRAM_ADMINS="<chaid 1> <chatid 2> <chatid 3>"
MONGODB_USER=<user>
MONGODB_PWD=<pwd>
MONGODB_HOST=<host>
MONGODB_PORT=<port>
MONGODB_DBNAME=<name>
OPENID_CLIENT_ID=<clientid>
OPENID_CLIENT_SECRET=<clientsecret>
AUDIENCE=<your bot domain>
AUTHENTICATION_SECRET=<senha de cookie>
and add the following variables: HOST, PORT and AUDIENCE.
If you are using a local server, starts the database with authentication
$ sudo mongod --dbpath /data/db [...args] &
If you are using a remote database, simply insert the adequated credentials in environment variables. The variables started with MONGODB_* will be joined to MONGODB_URL (see src/dotenv.js).
$ npm run start
This server will use src/views/index.tml (tml is a customized html template with properly environment variables inserted in html and js code) as GET /.
If you run and access this as localhost:*, you will see a Bot domain invalid message in the place of telegram button.
To solve this, you will need to run a valid domain name to the bot and place this as AUDIENCE variable in .env file, and run a tunnel:
Tunnel, in this application, is the usage of localtunnel CLI. This will get our localhost server and expose this to a secure proxy on the internet. :
npm install -g localtunnel
Before run localtunnel, keep in mind that you will need use a fixed proxy, or in other words, the same domain registered in BotFather
And run, as a service, a child processes or a another background command:
lt --port <ACCESS_PORT> --subdomain <SUBDOMAIN>
If you like nginx, you can use a reverse proxy and use:
lt --port 80 --subdomain <SUBDOMAIN>
For more information on all the things you can do with Feathers visit docs.feathersjs.com.
__ 0.1.14__
- /bot
- Added GET /bot as pre-compiler of message to POST /bot
- Issuer
- melhorado serviço do cliente
- todo:
- cliente executa, mas obtem erro de acesso
- issue
__ 0.1.13__
- Grupos
- Added /grupos to API
- Issuer
- Added /issuer to API
0.1.12
- Tests
- Added some CRUD tests in
/botand/users
- Added some CRUD tests in
- Simplified index.html
- added
afterandbeforehooks tousersservice, where we eill send messages
0.1.11
- Bot service
- Setup bot and send message to adminstrators at runtime
- Implemented the cycle of first messages as website dashboard (with telegram keyboards)
- Fixed unhandledErrors
0.1.1
- Bot service
POST /botand requires (TODO require authentication), and adatawith the following properties:idof the user where a message will be sent- a
message, aobjectwith propertiestype(astringorkeyboard) andvalue:- if
typeisstring, thenvalueneeds to be astring - if
typeiskeyboard, thenvalueneeds to be an array of object, defined in methods triggered by./src/bot.js
- if
0.1.0
- Initial release:
- Have a backend authentication with a
auth0Idas parameter, most likely used to be a telegram authorization GET,POSTmessages to/usersGET,PATCH,DELETEmessages to/users/:id
- Have a backend authentication with a
CC BY-SA 4.0
Licensed under the CC-BY-SA license.