コード例 #1
0
ファイル: test.py プロジェクト: Lujeni/old-projects
def dotest(bot, event, filter="", direct=False):
    """ do 1 test loop on the bot, e.g. execute all the examples found. """
    global teller
    global errors
    match = filter
    waiting = []
    if True:
        examplez = examples.getexamples()
        random.shuffle(examplez)
        for example in examplez:
            if match and match not in example: continue
            skip = False
            for dont in donot:
                if dont in example: skip = True
            if skip: continue
            teller += 1
            e = bot.make_event(event.auth, event.channel, ";" + example, cbtype=event.cbtype)
            e.speed = teller % 5
            try:
                if direct: e.execute()
                else: bot.put(e)
            except NoSuchCommand, ex: logging.error("failed to find %s command" % str(ex)) ; continue
            teller += 1
            time.sleep(0.01)
        event.reply("%s commands executed" % teller)
    if errors:
        event.reply("there are %s errors .. " % len(errors))
        for cmnd, error in errors.iteritems(): event.reply("%s - %s" % (cmnd, error))
    for (event, msg) in exceptionevents: event.reply("EXCEPTION: %s - %s" % (event.txt,msg))
    for msg in exceptionlist: event.reply("EXCEPTION: %s" % msg)
コード例 #2
0
def dotest(bot, event):
    global teller
    global errors
    match = ""
    waiting = []
    if True:
        examplez = examples.getexamples()
        random.shuffle(examplez)
        #logging.warn("test - running examples: %s" % ", ".join(examplez))
        for example in examplez:
            time.sleep(0.001)
            if match and match not in example: continue
            skip = False
            for dont in donot:
                if dont in example: skip = True
            if skip: continue
            teller += 1
            event.reply('command: ' + example)
            e = cpy(event)
            e.txt = example
            e.speed = 6
            e.bind(bot)
            bot.put(e)
            if not bot.isgae: waiting.append(e)
            teller += 1
        waitevents(waiting)
        event.reply("%s commands executed" % teller)
    if errors:
        event.reply("there are %s errors .. " % len(errors))
        for cmnd, error in errors.iteritems(): event.reply("%s - %s" % (cmnd, error))
    for (event, msg) in exceptionevents: event.reply("EXCEPTION: %s - %s" % (event.txt,msg))
    for msg in exceptionlist: event.reply("EXCEPTION: %s" % msg)
コード例 #3
0
def dotest(bot, event, filter="", direct=False):
    """ do 1 test loop on the bot, e.g. execute all the examples found. """
    global teller
    global errors
    match = filter
    waiting = []
    if True:
        examplez = examples.getexamples()
        random.shuffle(examplez)
        for example in examplez:
            if match and match not in example: continue
            skip = False
            for dont in donot:
                if dont in example: skip = True
            if skip: continue
            teller += 1
            e = bot.make_event(event.auth,
                               event.channel,
                               ";" + example,
                               event=event,
                               cbtype=event.cbtype)
            e.speed = teller % 5
            try:
                if direct: e.execute()
                else: bot.put(e)
            except NoSuchCommand, ex:
                logging.error("failed to find %s command" % str(ex))
                continue
            teller += 1
            time.sleep(0.01)
        event.reply("%s commands executed" % teller)
コード例 #4
0
ファイル: test.py プロジェクト: jvanvinkenroye/painload
def dotest(bot, event):
    """ do 1 test loop on the bot, e.g. execute all the examples found. """
    global teller
    global errors
    match = ""
    waiting = []
    if True:
        examplez = examples.getexamples()
        random.shuffle(examplez)
        for example in examplez:
            time.sleep(0.01)
            if match and match not in example:
                continue
            skip = False
            for dont in donot:
                if dont in example:
                    skip = True
            if skip:
                continue
            teller += 1
            cmnd = "!" + example.strip()
            if bot.type != "tornado":
                event.reply("command: " + cmnd)
            time.sleep(0.01)
            bot.putevent(event.auth, event.channel, cmnd, event=event)
            if not bot.isgae:
                waiting.append(event)
            teller += 1
        event.reply("%s commands executed" % teller)
    if errors:
        event.reply("there are %s errors .. " % len(errors))
        for cmnd, error in errors.iteritems():
            event.reply("%s - %s" % (cmnd, error))
    for (event, msg) in exceptionevents:
        event.reply("EXCEPTION: %s - %s" % (event.txt, msg))
    for msg in exceptionlist:
        event.reply("EXCEPTION: %s" % msg)