コード例 #1
0
ファイル: adamtestbot.py プロジェクト: magomez96/AdamTestBot
        except Exception:
            print "...",

    if instanceAge % 10 == 0: #print 1 X every ten ticks
        print "Y"
    else:
        print "X",


    for u in updates:
        currentMessage = u.message
        try:
            user_id = currentMessage.chat.id
            if user_id not in blacklist:
                parsedCommand = re.split(r'[@\s:,\'*]', currentMessage.text.lower())[0]
                running = atbCommands.process(atb, user_id, parsedCommand, currentMessage.text, currentMessage, u, datetime.datetime.now() - startTime)


        except Exception as myException:
            print traceback.format_exc()

    currentTime = datetime.datetime.now().time()

    if previousTime.minute != currentTime.minute:
        if currentTime.hour == 16 and currentTime.minute == 21: #commit Blaze Database
            __builtin__.blazeDB.commit()
            atb.sendMessage(chat_id=-12788453, text="Successfully committed Blaze database.")

    previousTime = currentTime

コード例 #2
0
while running:
    networkFailure = True
    while networkFailure:
        try:
            updates = atb.getUpdates(offset=newestOffset+1)
            for u in updates:
                newestOffset = u.update_id
            networkFailure = False
        except Exception:
            print "...",

    if instanceAge % (refreshRate * 10) == 0: #print 1 X every eight ticks
        print "Y"
    else:
        print "X",


    for u in updates:
        currentMessage = u.message
        try:
            user_id = currentMessage.chat.id
            parsedCommand = re.split(r'[@\s:,\'*]', currentMessage.text.lower())[0]

            running = atbCommands.process(atb, user_id, parsedCommand, currentMessage.text, currentMessage, u, instanceAge)


        except Exception as myException:
            print traceback.format_exc()
    instanceAge += refreshRate
    time.sleep(refreshRate)