Beispiel #1
0
def try_buy(code, max_cost):
    telega.send_command("/t_"+str(code))
    amount = int(status.get_money() / max_cost)
    if 'по ' + str(max_cost) + '💰' in telega.last_msg().message:
        if amount == 0:
            return
        telega.send_command("/wtb_"+str(code)+"_"+str(amount))
Beispiel #2
0
def transmute_try():
    trm_from = pcp.get("trm_from")
    trm_to = pcp.get("trm_to")
    trm_mana = pcp.get("trm_mana")

    if trm_from == '' or trm_to == '' or trm_mana == '':
        return

    if status.get_mana() < int(trm_mana):
        return

    herbs = status.get_herbs()

    force_upd = False
    do_trm = True
    for h in trm_from.split(','):
        h = int(h)
        if (h == 0) or not h in herbs:
            continue

        if do_trm and herbs[h] >= 50 and status.get_mana() > int(trm_mana):
            force_upd = True
            trm_cmd = '/use_trm ' + str(h) + ' ' + trm_to
            telega.send_command(trm_cmd)
            if '[Недостаточно маны]' in telega.last_msg().message:
                do_trm = False


        if random.random() < 0.1:
            try_buy(h, 1)

    if force_upd:
        status.upd()
Beispiel #3
0
def handle_bartrender():
    global last_bar_msg
    src = pcp.get("bartrender_chat")
    if src == "":
        return
    m = telega.last_msg_uname(src)
    if m is None:
        return
    if m.message is None:
        return
    if m.message == last_bar_msg:
        return

    if last_bar_msg == "" or \
            not "/g_withdraw" in m.message or \
            (not " p0" in m.message and \
            not " p1" in m.message and \
            not " p2" in m.message):
        last_bar_msg = m.message
        return

    last_bar_msg = m.message

    log("Doing bartrender stuff: " + m.message)

    m.forward_to(telega.game_bot)

    time.sleep(2)

    last = telega.last_msg()
    if 'Withdrawing' in last.message:
        last.forward_to(telega.get_tentity(src))
Beispiel #4
0
def handle_outer_monsters():
    global last_known_msg
    src = pcp.get("monsters_source")
    m = telega.last_msg_uname(src)
    if m is None:
        return
    if m.message is None:
        return
    if m.message == last_known_msg:
        return

    if last_known_msg == "" or not "/fight_" in m.message:
        last_known_msg = m.message
        return

    last_known_msg = m.message
    dl = pcp.get("monsters_delay")
    if dl != "":
        time.sleep(int(dl))

    log("Helping monsters: " + m.message)
    fhp = pcp.get("fight_hp")
    hp = status.get_hp()
    if fhp != "" and int(fhp) > hp:
        log("Low hp: " + str(hp))
        return

    if status.get_stamina(weak=True) < 1:
        log("No stamina")
        return

    if status.is_aiming():
        log("Aiming")
        return

    if not status.is_rest():
        log("Busy")
        return

    m.forward_to(telega.game_bot)

    time.sleep(2)

    if 'Ты собрался напасть на врага' in telega.last_msg().message:
        target_chat = pcp.get("monsters_ack_dest")
        telega.send_msg(target_chat, "+ ❤️" + str(int(hp)) + "%hp")

    if "⚜️Forbidden Champion" in m.message and pcp.get("champ_pots") == "true":
        telega.send_command("/use_p03")
        telega.send_command("/use_p02")
        telega.send_command("/use_p01")
        telega.send_command("/use_p06")
        telega.send_command("/use_p05")
        telega.send_command("/use_p04")

    last_known_msg = m.message
Beispiel #5
0
def arena_wait():
    util.log("Wait for arena finish..")
    for i in range(0, 300):
        util.sleep(1)
        message = telega.last_msg()
        if 'Рейтинги обновлены:' in message.message:
            return
        if 'Даже драконы не могут' in message.message:
            return
        if 'Тебе бы подлечиться.' in message.message:
            return
        if 'У тебя нет денег, чтобы оплатить вход.' in message.message:
            return
    util.log("Arena waiting timeout!")
Beispiel #6
0
def handle_hidden_location():
    global last_known_location

    m = telega.last_msg()
    if m is None:
        return

    if m.message is None:
        return

    if not "То remember the route you associated it with simple combination:" in m.message:
        return

    if m.message == last_known_location:
        return

    last_known_location = m.message

    dst = pcp.get("location_dst")
    if dst == "":
        return

    m.forward_to(dst)
Beispiel #7
0
def arena_try():
    global limit
    global wait_hr
    global wait_day

    if status.get_money() < 5:
        return

    cur_day = int(datetime.datetime.utcnow().strftime('%d'))
    time = datetime.datetime.time(datetime.datetime.utcnow())

    # Check if arena was reset
    if time.hour == 10 and time.minute < 10 and cur_day != wait_day:
        limit = False
        wait_day = cur_day

    # If arena is over for today, do nothing
    if limit:
        return

    # Arena is closed for night
    if util.get_day_time(time) == util.day_time.NIGHT:
        return

    # If we have no money, wait for next hour
    if wait_hr == time.hour:
        return

    util.sleep(random.randrange(0, 1200))
    telega.send_command('🗺Квесты')
    message = telega.last_msg()
    if '📯Арена 🔒' in message.message:
        limit = True
        return

    if message.button_count < 4:
        return

    telega.click(message, 4, "📯Арена")
    message = telega.last_msg()

    if 'Ты сейчас занят другим приключением' in message.message:
        util.sleep(300)
        return

    if not 'Пыльный воздух пропитан густым приторным' in message.message:
        return

    if '5/5' in message.message:
        # It's over for today
        limit = True
    else:
        for i in range(0, 5):
            util.sleep(5)
            telega.send_command('▶️Быстрый бой')
            arena_wait()
            message = telega.last_msg()
            hp = status.get_hp()
            if 'У тебя нет денег' in message.message or 'Тебе бы подлечиться.' in message.message or hp < 100:
                wait_hr = time.hour
                return
            if 'Даже драконы не могут' in message.message:
                limit = True
                return
Beispiel #8
0
#if not status.stupid_human():
#    telega.send_command('/report')
#    status.send_report()
status.upd()

while True:
    now = datetime.datetime.time(datetime.datetime.utcnow())

    if pcp.get("night_mode") != "":
        h = int(pcp.get("night_mode"))
        if now.hour == h:
            time.sleep(random.randrange(0, 1200))
            quest.go_def()
            time.sleep(8 * 60 * 60 + random.randrange(0, 1200))
    message = telega.last_msg()
    if ('завывает по окрестным лугам' in message.message):
        util.log("Battle is not finished, wait 2 minutes")
        last_msg_id = message.id
        if now.minute < 8:
            util.sleep(60 * (8 - now.minute))
        else:
            util.sleep(120)
        if not status.stupid_human():
            telega.send_command('/report')
            status.send_report()
        continue

    message = telega.last_msg()
    if message.id != last_msg_id:
        last_msg_id = message.id
Beispiel #9
0
def run():
    global wait_hr
    global time

    time = datetime.datetime.time(datetime.datetime.utcnow())
    if wait_hr != -1:
        if time.hour > wait_hr:
            wait_hr = -1
        else:
            return

    iterator = 0
    qrange = 1
    fp = open('quest')
    lines = fp.read().split("\n")
    fp.close()

    stamina = status.get_stamina(weak=True)

    print("Required stamina points: " + str(req_stam(lines)) + ", got " +
          str(stamina))

    if stamina < req_stam(lines):
        return

    if not day_time_ok(lines):
        print("Bad day time")
        return
    #if util.get_day_time(time) == util.day_time.NIGHT: # or get_day_time(time) == day_time.EVENING:
    #    telega.send_command('/on_tch')
    #    qrange = 4
    stamina = status.get_stamina(weak=False)
    if stamina < req_stam(lines):
        return
    for i in lines:
        if len(i) == 0:
            continue
        if "#" in i:
            continue

        util.log("Iterator = " + i)

        if i[0] == '/':
            if not status.stupid_human():
                telega.send_command(i)
            continue

        telega.send_command('🗺Квесты')

        q_message = telega.last_msg()
        w = i.split(" ")
        q = ""
        if is_number(w[0]):
            q_idx = 0
            if w[1][0] == 's':
                q_idx = 1
            elif w[1][0] == 'm':
                q_idx = 2
            elif w[1][0] == 'k':
                q_idx = 3

            if q_message.button_count < q_idx:
                return

            for it in range(0, int(w[0])):
                if w[1][0] == 'r':
                    q_idx = random.randrange(0, 3)

                if pcp.get("seeker") != "":
                    if it > 0:
                        telega.send_command('🗺Квесты')
                        q_message = telega.last_msg()
                    for line in q_message.text.split('\n'):
                        if 'Лес' in line and '🔥' in line:
                            q_idx = 0
                        elif 'Болото' in line and '🔥' in line:
                            q_idx = 1
                        elif 'Горная долина' in line and '🔥' in line:
                            q_idx = 2
                    print("Seeker q_idx: ", q_idx)
                q = quest_cmd[q_idx]
                telega.click(q_message, q_idx, q)
                message = telega.last_msg()

                last_msg_id = message.id
                if '3' in message.message:
                    util.log("Wait 3 min..")
                    util.sleep(3 * 60 + random.randrange(15, 60))
                if '4' in message.message:
                    util.log("Wait 4 min..")
                    util.sleep(4 * 60 + random.randrange(15, 60))
                elif '5' in message.message:
                    util.log("Wait 5 min..")
                    util.sleep(5 * 60 + random.randrange(15, 60))
                elif '6' in message.message:
                    util.log("Wait 6 min..")
                    util.sleep(6 * 60 + random.randrange(15, 60))
                elif '7' in message.message:
                    util.log("Wait 7 min..")
                    util.sleep(7 * 60 + random.randrange(15, 60))
                elif '8' in message.message:
                    util.log("Wait 8 min..")
                    util.sleep(8 * 60 + random.randrange(15, 60))
                elif 'Тебе бы подлечиться.' in message.message or 'Слишком мало единиц выносливости. Приходи попозже, когда отдохнешь.' in message.message:
                    wait_hr = time.hour
                    return
                else:
                    util.log("Strange forest time: " + message.message)
                    util.log("Try to wait 5 mins anyway")
                    util.sleep(5 * 60)
            if status.stupid_human():
                return

            message = telega.last_msg()

            if 'И свой факел' in message.message:  # Craft a new torch
                telega.send_command('/bind_tch')
                telega.send_command('/on_tch')

            if 'Он пытается ограбить КОРОВАН' in message.message:
                if '/go' in message.message:
                    telega.send_command('/go')
                else:
                    if message.button_count > 0:
                        message.click(0)

    status.stamina = 0