Python 如何在ErrBot中使用调度/Cron作业?

Python 如何在ErrBot中使用调度/Cron作业?,python,cron,scheduled-tasks,chatbot,errbot,Python,Cron,Scheduled Tasks,Chatbot,Errbot,我正在尝试安排一个cron作业,以便使用我的Err Bot在slack上发布消息。是否有人使用调度器/cron作业来完成相同的任务 def activate(self): super().activate() self.start_poller(60, self.oncall(msg,args), times=1) 上面是我的代码片段,我正在使用它来计划每60秒调用一次函数 @botcmd def oncall(self, msg, args): 上面是我试图从调度器/c

我正在尝试安排一个cron作业,以便使用我的Err Bot在slack上发布消息。是否有人使用调度器/cron作业来完成相同的任务

def activate(self):
     super().activate()
     self.start_poller(60, self.oncall(msg,args), times=1)
上面是我的代码片段,我正在使用它来计划每60秒调用一次函数

@botcmd
def oncall(self, msg, args):
上面是我试图从调度器/cronjob调用的函数

错误:-

Error: Example failed to activate: Example failed to start : name 'msg' is not defined..
Error: Example failed to activate: Example failed to start : oncall() missing 2 required positional arguments: 'msg' and 'args'..

在我尝试之后

def activate(self):
     super().activate()
     self.start_poller(60, self.oncall(), times=1)
错误:-

Error: Example failed to activate: Example failed to start : name 'msg' is not defined..
Error: Example failed to activate: Example failed to start : oncall() missing 2 required positional arguments: 'msg' and 'args'..

第二个问题:-最重要的是,我使用了@botcmd的所有其他函数,但不确定如何使用或不使用调度器来实现调度器@

编辑:-感谢马克·沙利文(@marksull)纠正了我的代码。我已修复了错误,但我的轮询仍无法按预期运行。 他的建议奏效了:-

您所犯的错误是在start poller中调用on_call方法,而不是仅仅传递该方法。例如,它应该是

def activate(self):
         super().activate()
         self.start_poller(60, self.oncall, 1, msg, args)

def oncall(self, msg, args):
    print("in on call")
我还注意到你的activate方法不包含变量msg或args,所以你是否假设它们存在?如果它们不存在,那么您的代码应该是:

def activate(self):
         super().activate()
         self.start_poller(60, self.oncall, 1)

def oncall(self):
    print("in on call")