Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在用户指定的时间段内随机发送信息 #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhangchi9
Copy link

根据issue #147 的建议, 在用户制定的时间段内, 随机挑选一个时间发送消息. 用户只需要在 _config.yaml 中添加时间段即可:
alarm_timed:
- "19:05 - 19:30"
- "7:30 -8:30"
- "6:30"

@sfyc23
Copy link
Owner

sfyc23 commented Jul 12, 2019

这种方式,只是在一段时间内,随机选取一个时间进行定时发送吧。但之后的每天也是最开始这个时间开始的。并没有真正随机时间发送。

@zhangchi9
Copy link
Author

是的, 之前的方式有问题, 做了更新, 现在是每天00:00:00生成随机时间, 然后设置运行时间为生成的时间

@sfyc23
Copy link
Owner

sfyc23 commented Jul 15, 2019

你这段代码也是一样,只生成一次随机时间,之后每次也是在这个生成的随机时间内生效。

@zhangchi9
Copy link
Author

zhangchi9 commented Jul 15, 2019

不是啊,每天00:00都会运行这个set_daily_alarm程序,每天都会生成新的随机时间
scheduler.add_job(set_daily_alarm, 'cron', [alarm_dict], hour = 0, id='set_daily_alarm')
然后会在新生成的随机时间发送信息
sched.add_job(send_alarm_msg, 'date', [key], run_date = run_time, id=key, misfire_grace_time=600)

@sfyc23
Copy link
Owner

sfyc23 commented Jul 15, 2019

抱歉,应该是我看错了逻辑。我下午测试一下这段代码。上个周末更新的代码太多了,合并可能会麻烦一点。

@poorsecretary
Copy link

所以,随机发送功能实现了吗。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants