像python-telegram-bot一样调度
我现在正在玩 /学习Python 1周 - 所以我很新。 我使用 python-telegram-bot 成功实施了一个工作电报机器人。 我使用apscheduler创建了一个工作脚本,而没有机器人,我想为我的机器人实施相同的计划。
无机器人的工作:
sched = BackgroundScheduler()
sched.add_job(my_funct, 'cron', day_of_week = 'mon-fri,sun', hour='11,15,19,23', minute = 55)
不使用机器人:
context.job_queue.run_custom(my_funct, 'cron', days = 'mon-fri,sun', hour='11,15,19,23', minute = 55)
我得到所有使用过的关键字的“ typeError:run_custom()获得了意外的关键字参数...”。 根据 telethon-bot文档< /a>调度程序基于apscheduler。但是我找不到有关如何正确使用该功能的任何线索。
I am playing / learning python now of 1 week - so I am quite new.
I implemented successfully a working Telegram Bot using python-telegram-bot.
I created a working script using APScheduler without the bot and I would like to implement the same scheduling for my bot.
Working without the bot:
sched = BackgroundScheduler()
sched.add_job(my_funct, 'cron', day_of_week = 'mon-fri,sun', hour='11,15,19,23', minute = 55)
Not working with the bot:
context.job_queue.run_custom(my_funct, 'cron', days = 'mon-fri,sun', hour='11,15,19,23', minute = 55)
I get "TypeError: run_custom() got an unexpected keyword argument ..." for all of the used keywords.
According to the telegram-python-bot documentation the scheduler is based on APScheduler. But I did not find any clues on how to use the function correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎您以错误的方式提供关键字参数。根据您包含的文档链接,关键字参数应传递给
job_kwargs
。像这样:
Seems like you're providing the keyword arguments the wrong way. According to the documentation link you included, the keyword arguments should be passed to
job_kwargs
.Like this: