[英]Reminder bot with Node.js
I am creating reminder bot. 我正在创建提醒机器人。 User inputs date eg 01.01.19, I'm using new Date() to get milisecs to event, then I call setTimeout() function and wait until it happens. 用户输入日期,例如01.01.19,我使用新的Date()获取事件的毫秒数,然后调用setTimeout()函数并等待它发生。 So the problem is about setTimeout() Is it OK to call it for a long period of time and many times? 所以问题是关于setTimeout()可以长时间调用它吗? If user will call it for eg 10000 times, will it break my bot and so on? 如果用户将其调用例如10000次,它将破坏我的机器人,等等吗? Is it optimal case or you can advice something else 这是最佳案例还是您可以建议别的东西
Well since you have a database, just do the following: 好吧,既然您有一个数据库,只需执行以下操作:
Should be pretty simple to do - just use setInterval
, a loop, and a little bit of working with Date
in JavaScript. 应该做起来非常简单-只需使用setInterval
,一个循环以及在JavaScript中使用Date
的一些方法即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.