def create_reminder(message, people, content, trigger_time, freq): for user in list(people.split()): if int(freq) <= 0: t_time = datetime.strptime(trigger_time, '%b-%d-%Y_%H:%M:%S') schedule.once(t_time).do( message.send, "Hey, %s! It's time to do some work:\n %s" % (user, content)) else: schedule.every(int(freq)).seconds.do( message.send, "Hey, %s! It's time to do some work again:\n %s" % (user, content))
def schedule_every(self, message: Message, seconds: int): """Schedules a reply every x seconds. Use the `cancel jobs` command to stop. Arguments: - seconds (int): number of seconds between each reply. """ schedule.every(int(seconds)).seconds.do( self.driver.reply_to, message, f"Scheduled message every {seconds} seconds!")
def citation_auto(message): global quote_enabled if (quote_enabled == False): message.reply("Citations activées : une citation toute les 12 heures") schedule.every(12 * 3600).seconds.do(reply_random_quote, message) quote_enabled = True else: message.reply("Citations désactivées") schedule.clear() quote_enabled = False
def reply_every_seconds(message, content, seconds): schedule.every(int(seconds)).seconds.do(message.reply, content)
def watch_key(message, key): utils.reply(message, "start observing key {key}".format(key=key)) schedule.every(20).seconds.do(lambda: utils.reply(message, kv.eget(key)))
def observe_results(message): ks = kv.part_keys("raw_result") for k in ks: message.reply("start observing key {key}".format(key=k)) schedule.every(20).seconds.do(lambda: utils.reply(message, kv.eget(k)))
def observe_info(message): message.reply("start observing key info") schedule.every(20).seconds.do(lambda: utils.reply(message, kv.eget('info@0')))
def observe_target_pressure(message): message.reply("start observing key target_pressure") schedule.every(20).seconds.do(lambda: utils.reply(message, kv.eget('current_target_pressure@0')))