[英]How can I use a secret on Repl.it with my JavaScript code for Telegram using Telegraf?
I have this code:我有这段代码:
const bot = new Telegraf('tokengoeshereblablablabla')
And I want it to look like this:我希望它看起来像这样:
const bot = new Telegraf(TOKEN)
So my Telegram token wont be leaked.所以我的 Telegram 令牌不会被泄露。 I know it's possible, but I don't find it eather here in StackOverflow either Google.
我知道这是可能的,但我在 StackOverflow 或 Google 中都找不到它。
Thanks in advance.提前致谢。
In repl.it you can set your secret variables in specific section Look at this image below you can set key as TOKEN and value [YOURTOKEN]在 repl.it 中,您可以在特定部分设置您的秘密变量看下面的这张图片,您可以将键设置为 TOKEN 并将值设置为 [YOURTOKEN]
Simply you can use it in nodejs file like:只需在 nodejs 文件中使用它,例如:
const bot = new Telegraf(process.env.TOKEN)
Note: if you can't access it like above line, you will need to install dotenv package to load environment variables.注意:如果你不能像上面那样访问它,你需要安装 dotenv package 来加载环境变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.