예제 #1
0
def timers(event, bot):
	command, args = commandSplit(event.argument)
	
	if command == "show":
		bot.say("Timers:")
		for timer in Timers.getTimers().itervalues():
			bot.say(" - %s: reps = %s, delay = %s, f = %s" % (timer.name, timer.reps, timer.interval, timer.f))
		
	elif command == "add":
		args = argumentSplit(args, 4) #add timername delay reps msg
		if not args:
			bot.say("Not enough arguments. Need: timername delay reps message (reps <= 0 means forever)")
			return
		try:
			if Timers.addtimer(args[0], float(args[1]), timercallback, reps=int(args[2]), msg=args[3], bot=bot, channel=event.target):
				bot.say("Timer added (%s)" % args[0])
			else:
				bot.say("Timer not added for some reason?")
		except TimerExists:
			bot.say("Timer not added because it exists already.")
		except TimerInvalidName:
			bot.say("Timer not added because it has an invalid name.")

	elif command == "stop":
		try: 
			Timers.deltimer(args)
			bot.say("Timer stopped (%s)" % args)
		except (TimerNotFound, TimerInvalidName):
			bot.say("Can't stop (%s) because timer not found or internal timer." % args)
예제 #2
0
def nickChanged(event, bot):
	if bot.getOption("restorenick", module="pbm_nicktools"):
		snick = bot.getOption("nick")
		if event.newname != snick:
			# start timer to checkandrecov
			try: Timers.addtimer("NICKTOOLS_%s" % bot.network, float(bot.getOption("checkevery", module="pbm_nicktools")), 
				nickCheckAndRecover, reps=-1, bot=bot )
			except TimerExists: pass
		else:
			# have desired nick, delete check timers
			try: Timers.deltimer("NICKTOOLS_%s" % bot.network)
			except TimerNotFound: pass
			# TODO: like below, when state can track +r, this should be checked before attempting identify
			identify(bot, snick)
예제 #3
0
def timers(event, bot):
    command, args = commandSplit(event.argument)

    if command == "show":
        bot.say("Timers:")
        for timer in Timers.getTimers().itervalues():
            bot.say(" - %s: reps = %s, delay = %s, f = %s" %
                    (timer.name, timer.reps, timer.interval, timer.f))

    elif command == "add":
        args = argumentSplit(args, 4)  #add timername delay reps msg
        if not args:
            bot.say(
                "Not enough arguments. Need: timername delay reps message (reps <= 0 means forever)"
            )
            return
        msg = Timers.addtimer(args[0],
                              float(args[1]),
                              timercallback,
                              reps=int(args[2]),
                              msg=args[3],
                              bot=bot,
                              channel=event.target)[1]
        bot.say("%s (%s)" % (msg, args[0]))

    elif command == "stop":
        bot.say(Timers.deltimer(args)[1])
예제 #4
0
def timers(event, bot):
    command, args = commandSplit(event.argument)

    if command == "show":
        bot.say("Timers:")
        for timer in Timers.getTimers().itervalues():
            bot.say(" - %s: reps = %s, delay = %s, f = %s" %
                    (timer.name, timer.reps, timer.interval, timer.f))

    elif command == "add":
        args = argumentSplit(args, 4)  #add timername delay reps msg
        if not args:
            bot.say(
                "Not enough arguments. Need: timername delay reps message (reps <= 0 means forever)"
            )
            return
        try:
            if Timers.addtimer(args[0],
                               float(args[1]),
                               timercallback,
                               reps=int(args[2]),
                               msg=args[3],
                               bot=bot,
                               channel=event.target):
                bot.say("Timer added (%s)" % args[0])
            else:
                bot.say("Timer not added for some reason?")
        except TimerExists:
            bot.say("Timer not added because it exists already.")
        except TimerInvalidName:
            bot.say("Timer not added because it has an invalid name.")

    elif command == "stop":
        try:
            Timers.deltimer(args)
            bot.say("Timer stopped (%s)" % args)
        except (TimerNotFound, TimerInvalidName):
            bot.say(
                "Can't stop (%s) because timer not found or internal timer." %
                args)
예제 #5
0
def nickChanged(event, bot):
    if bot.getOption("restorenick", module="pbm_nicktools"):
        snick = bot.getOption("nick")
        if event.newname != snick:
            # start timer to checkandrecov
            try:
                Timers.addtimer("NICKTOOLS_%s" % bot.network,
                                float(
                                    bot.getOption("checkevery",
                                                  module="pbm_nicktools")),
                                nickCheckAndRecover,
                                reps=-1,
                                bot=bot)
            except TimerExists:
                pass
        else:
            # have desired nick, delete check timers
            try:
                Timers.deltimer("NICKTOOLS_%s" % bot.network)
            except TimerNotFound:
                pass
            # TODO: like below, when state can track +r, this should be checked before attempting identify
            identify(bot, snick)
예제 #6
0
파일: pbm_gdq.py 프로젝트: Clam-/pyBurlyBot
def unload():
	Timers.deltimer(TIMER_NAME)