예제 #1
0
파일: eve.py 프로젝트: CaptainFake/EveBot
def timeout(inp, nick='', chan='', db=None, say=None, input=None):
    ".timeout [Nick]"
    db_init(db)

    if not inp:
        pass
    else:
        nick = inp

    try:
        res=evemisc.get_apiID_by_nick(db, nick)
        if res == None:
            return "No entry found. Please use .eveadd"

        keyID, vCode, charName = res
        api, auth, cid=evemisc.get_characterID(keyID, vCode, charName)
        if cid == None:
            return "No character found"

        accountStatus = auth.account.AccountStatus()
        timeOut = accountStatus.paidUntil
        logonMinutes = accountStatus.logonMinutes
        playTime = datetime(1, 1, 1) + timedelta(minutes = float(logonMinutes))
        playTimeStr = (u"(you played %dd %dh %dmn %ds)" % (playTime.day - 1, playTime.hour, playTime.minute, playTime.second))
        now = time.time()
        t, d = evemisc.sectostr(now, timeOut)
        remainingTime = u"\u000310" + t + u"\u000f"
        if t.index('-'):
            remainingTime = u"\u000304" + t + u"\u000f"
        say(u"%s account expires in %s, on \u000307%s\u000f, %s" % (nick, remainingTime, d, playTimeStr))
    except (RuntimeError, ssl.SSLError) as e:
        return "Error: " + e.message
예제 #2
0
파일: eve.py 프로젝트: CaptainFake/EveBot
def alert(inp, nick='', chan='', db=None, say=None, input=None):
    db_init(db)

    try:
        global alive
        if inp == "start":
            say("Start skill notifier")
            alive = True
            while alive:
                now = time.time()
                row = db.execute("select nick, skill, time, level, character, bool from EveSurvey where 1").fetchall()
                for en in row:
                    n, skill, end, level, character, boo=en
                    if end <= now:
                        t, d=evemisc.sectostr(end, now)
                        msg = u"%s: Your character \u0002%s\u000f has finished to train \u000308%s\u000f to level \u000308%d\u000f (since \u000310%s\u000f)" % (n.title(), character.title(), skill, level, t)
                        if boo == 0:
                            say(msg)
                        msg=None
                        row = db.execute("select nick, keyID, vCode, character from EveKey where nick=lower(?)", (n,)).fetchall()
                        update_skill(row[0], db)
                        break
                time.sleep(5)
            say("Stopping skill notifier...")
    except (RuntimeError, ssl.SSLError) as e:
        return "Error: " + e.message
예제 #3
0
파일: eve.py 프로젝트: CaptainFake/EveBot
def notif(inp, nick='', chan='', db=None, say=None, input=None):
    db_init(db)
    try:
        global alive
        if inp == "check":
            now = time.time()
            row = db.execute("select nick, skill, time, level, character from EveSurvey where 1").fetchall()
            for en in row:
                n, skill, end, level, character=en
                print("Next alert for %s: %s (finish in %s)" % (n, skill, evemisc.sectostr(now, end)))
            say("Check OK")
        if inp == "init":
            db.execute("drop table if exists EveSurvey")
            db.commit()
            db.execute("create table if not exists EveSurvey(nick primary key, skill, time, level, character, bool)")
            db.commit()
            row = db.execute("select nick, keyID, vCode, character from EveKey where 1").fetchall()
            for en in row:
                n, c =update_skill(en, db, True)
            say("DB Updated")
        if inp == "up":
            row = db.execute("select nick, keyID, vCode, character from EveKey where nick=?", (nick.lower(), )).fetchall()
            n, c =update_skill(row[0], db)
            say("Notifier DB updated for %s" % nick.title())
        if inp == "stop":
            alive = False
        if inp == "status":
            if alive == False:
                say(u"Notifier daemon [\u000304stopped\u000f]")
            else:
                say(u"Notifier daemon [\u000309started\u000f]")
    except (RuntimeError, ssl.SSLError) as e:
        return "Error: " + e.message
예제 #4
0
파일: eve.py 프로젝트: CaptainFake/EveBot
def next(inp, nick='', chan='', db=None, say=None, input=None):
    ".next [Nick]"
    db_init(db)

    if not inp:
        pass
    else:
        nick = inp

    try:
        res=evemisc.get_apiID_by_nick(db, nick)
        if res == None:
            return "No entry found. Please use .eveadd"

        keyID, vCode, charName = res
        api, auth, cid=evemisc.get_characterID(keyID, vCode, charName)
        if cid == None:
            return "No character found"
        queue = auth.char.SkillQueue(characterID=cid).skillqueue
        if len(queue) > 1:
            s=api.eve.TypeName(ids=queue[1].typeID)
            skillName=s.types[0].typeName
            t, d=evemisc.sectostr(time.time(), queue[1].endTime)
            msg = u"\u0002%s\u000f: Next skill in queue \u000308%s\u000f to level \u000308%d\u000f (finish in \u000310%s\u000f, %s)" \
                  % (charName.title(), skillName, queue[0].level, t, d)
            say(msg)
        else:
            say("No skill in queue.")
    except (RuntimeError, ssl.SSLError) as e:
        return "Error: " + e.message
예제 #5
0
파일: eve.py 프로젝트: CaptainFake/EveBot
def eta(inp, nick='', chan='', db=None, say=None, input=None):
    ".eta [Nick]"
    db_init(db)

    if not inp:
        pass
    else:
        nick = inp

    try:
        res=evemisc.get_apiID_by_nick(db, nick)
        if res == None:
            return "No entry found. Please use .eveadd"

        keyID, vCode, charName = res
        api, auth, cid=evemisc.get_characterID(keyID, vCode, charName)
        if cid == None:
            return "No character found"

        skill = auth.char.SkillInTraining(characterID=cid)
        if skill.skillInTraining == 0:
            say("No skill in training")
        else:
            print "Skill in training"
            s=api.eve.TypeName(ids=skill.trainingTypeID)
            skillName=s.types[0].typeName
            t, d=evemisc.sectostr(time.time(), skill.trainingEndTime)
            msg = u"\u0002%s\u000f: Currently training \u000308%s\u000f to level \u000308%d\u000f (finish in \u000310%s\u000f, %s)" \
                  % (charName.title(), skillName, skill.trainingToLevel, t, d)
            say(msg)
    except (RuntimeError, ssl.SSLError) as e:
        return "Error: " + e.message
예제 #6
0
파일: eve.py 프로젝트: CaptainFake/EveBot
def queue(inp, nick='', chan='', db=None, say=None, input=None):
    ".queue [nick]"
    db_init(db)

    if not inp:
        pass
    else:
        nick = inp

    try:
        res=evemisc.get_apiID_by_nick(db, nick)
        if res == None:
            return "No entry found. Please use .eveadd"

        keyID, vCode, charName = res
        api, auth, cid=evemisc.get_characterID(keyID, vCode, charName)
        if cid == None:
            return "No character found"

        queue = auth.char.SkillQueue(characterID=cid).skillqueue
        snk=""
        qEnd=0
        if len(queue) > 0:
            for sk in queue:
                s=api.eve.TypeName(ids=sk.typeID)
                skillName=s.types[0].typeName
                snk = snk + u"[\u000308" + skillName + u"\u000f lvl. \u000308" + str(sk.level) + u"\u000f] "
                qEnd = sk.endTime
        else:
            return "No skill in queue."
        print snk
        t, d=evemisc.sectostr(time.time(), qEnd)
        msg = u"%s: Skill in queue: %s (finish in \u000310%s\u000f, %s)" % (charName.title(), snk, t, d)
        say(msg)
    except (RuntimeError, ssl.SSLError) as e:
        return "Error: " + e.message