def repeat(session, *args, **kwargs): """ Call a named function repeatedly. Note that this is meant as an example of limiting the number of possible call functions. Kwargs: callback (str): The function to call. Only functions from the _repeatable dictionary earlier in this module are available. interval (int): How often to call function (s). Defaults to once every 60 seconds with a minimum of 5 seconds. stop (bool): Stop a previously assigned ticker with the above settings. """ from evennia.scripts.tickerhandler import TICKER_HANDLER name = kwargs.get("callback", "") interval = max(5, int(kwargs.get("interval", 60))) if name in _repeatable: if kwargs.get("stop", False): TICKER_HANDLER.remove(interval, _repeatable[name], idstring=session.sessid, persistent=False) else: TICKER_HANDLER.add(interval, _repeatable[name], idstring=session.sessid, persistent=False, session=session) else: session.msg("Allowed repeating functions are: %s" % (", ".join(_repeatable)))