telegraf / micro-bot

:robot: Zero-configuration Telegram bot runner
MIT License
182 stars 29 forks source link

Loading enviroment variables #4

Closed manzanit0 closed 7 years ago

manzanit0 commented 7 years ago

Hi,

I was wondering how can I load the environment variables from a file using dotenv or any other package. This is because even though I load them before even requiring themicro-bot module, it won't let me:

μ-bot: Please supply Bot token

Is it possible to do this? I tried with the following code while having a .env file in the root directory with the BOT_TOKEN:

'use strict';

// Configure enviroment variables.
require('dotenv').config();

console.log(process.env.BOT_TOKEN);

// Telegraf based framework.
const { Composer } = require('micro-bot');
const app = new Composer();

Thanks.

dotcypress commented 7 years ago

Hi,

Actually you must set environment variables before starting micro-bot script. Example: source .env & npm run dev

dotcypress commented 7 years ago

New version of micro-bot now supports -e flag.