#!/user/bin/env python import threading message_threads_list =[] def setup(bot): message="Check out our home page at vespa.org.vt.edu to find out about more about us" bot.say(message) thread=threading.Timer(600, spawn_thread, [bot, message, 600, 0]) message_threads_list.append(thread) thread.start() setup.setup=0 def spawn_message(bot, nick, message): args=message.split(None, 2) if int(args[1])<4: bot.say("message interval must be greater than 4 seconds") return bot.say(args[2]) index = len(message_threads_list) thread=threading.Timer(int(args[1]), spawn_thread, [bot, args[2], int(args[1]), index]) message_threads_list.append(thread) thread.start() spawn_message.privilege="owners" spawn_message.commands=["^!spawnThread [1-9]+ [^\s].+"] def spawn_thread(bot, msg, time, index): bot.say(msg) message_threads_list[index]=threading.Timer(time, spawn_thread, [bot, msg, time, index]) message_threads_list[index].start() def end_threads(bot): for thread in message_threads_list: try: thread.cancel() except Exception as e: print('failed to properly close '+thread) del message_threads_list[:] end_threads.register_terminate=0