Example #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))
Example #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()
Example #3
0
def stash_resources():
    stock = status.get_stock();
    stash_resources = pcp.get("stash_resources")
    if stash_resources == "":
        return

    for r in stash_resources.split(','):
        r = int(r)
        if r in stock and stock[r] > 0:
            strr = str(r)
            if len(strr) == 1:
                strr = '0' + strr
            telega.send_command("/g_deposit " + strr + " " + str(stock[r]))
Example #4
0
def go_def():
    if status.stupid_human():
        return
    if status.is_rest() == True:
        def_target = pcp.get("def_target")
        if def_target == "guild":
            telega.send_command("/g_def")
        elif def_target == "alliance":
            telega.send_command("/ga_def")
        else:
            telega.send_command("🛡Защита")
        util.log("It's defense time! Go to sleep..")
Example #5
0
        break

    return 9999


while True:
    offer = telega.last_offer()
    txt = offer.message
    bet = txt.split("\n")[-1]
    if offer.id != last_msg_id:
        bf = open('bids')
        for i in bf.read().split("\n"):
            first_s = i.find(' ')
            if first_s < 1 or len(
                    i[first_s + 1:]) == 0 or not util.is_number(i[:first_s]):
                if len(i) > 0:
                    print("Wrong format for bid: " + i)
                continue

            if i[first_s + 1:] in txt and init_cost(i) <= int(i[:first_s]):
                sleep(random.randrange(1, 15))
                telega.send_command(bet + "_" + i[:first_s])
        bf.close()

    if last_msg_id != offer.id:
        print("New offer: " + bet + "; " + txt.split("\n")[1])

    last_msg_id = offer.id
    sleep(1)
Example #6
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
Example #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
Example #8
0
    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
        util.log("Bot says: " + message.message)
        if 'Он пытается ограбить КОРОВАН' in message.message:
            if status.stupid_human():
                time.sleep(300)
                continue
            if '/go' in message.message:
                telega.send_command('/go')
            else:
                telega.click(message, 0, "🧹Вмешаться")
Example #9
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: Denis Deryugin <*****@*****.**>
# Copyleft 2019, The ChatWars3 Grinder project
# License: GPL v3

import telega, util
from telethon import TelegramClient, sync
import random
from time import sleep

last_msg_id = 0

while True:
    telega.send_command("🏰Замок")
    telega.send_command("🍺Таверна")
    telega.send_command("🎲Играть в кости")
    for i in range(0, 300):
        message = telega.last_msg()
        if '🎲Вы бросили кости на стол:' in message.message:
            sleep(random.randrange(0, 5))
            break
        sleep(1)
Example #10
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