コード例 #1
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def clickBtn(img, timeout=3, threshold=ct['default']):
    """Search for img in the scree, if found moves the cursor over it and clicks.
    Parameters:
        img: The image that will be used as an template to find where to click.
        timeout (int): Time in seconds that it will keep looking for the img before returning with fail
        threshold(float): How confident the bot needs to be to click the buttons (values from 0 to 1)
    """

    logger(None, progress_indicator=True)
    start = time.time()
    has_timed_out = False
    while (not has_timed_out):
        matches = positions(img, threshold=threshold)

        if (len(matches) == 0):
            has_timed_out = time.time() - start > timeout
            continue

        x, y, w, h = matches[0]
        pos_click_x = x + w / 2
        pos_click_y = y + h / 2
        moveToWithRandomness(pos_click_x, pos_click_y, 1)
        pyautogui.click()
        return True

    return False
コード例 #2
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def refreshHeroes():
    logger('🏢 Search for heroes to work')

    goToHeroes()

    if c['select_heroes_mode'] == "full":
        logger('⚒️ Sending heroes with full stamina bar to work', 'green')
    elif c['select_heroes_mode'] == "green":
        logger('⚒️ Sending heroes with green stamina bar to work', 'green')
    else:
        logger('⚒️ Sending all heroes to work', 'green')

    buttonsClicked = 1
    empty_scrolls_attempts = c['scroll_attemps']

    while (empty_scrolls_attempts > 0):
        if c['select_heroes_mode'] == 'full':
            buttonsClicked = clickFullBarButtons()
        elif c['select_heroes_mode'] == 'green':
            buttonsClicked = clickGreenBarButtons()
        else:
            buttonsClicked = clickButtons()

        sendHeroesHome()

        if buttonsClicked == 0:
            empty_scrolls_attempts = empty_scrolls_attempts - 1
        scroll()
        time.sleep(2)
    logger('💪 {} heroes sent to work'.format(hero_clicks))
    goToGame()
コード例 #3
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def sendAllHeroesToWork():
    logger('🏢 Sending ALL heroes to work')

    goToHeroes()

    clickBtn(images['send-all-heroes'])
    goToGame()
コード例 #4
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def clickGreenBarButtons():
    # ele clicka nos q tao trabaiano mas axo q n importa
    offset = 140

    green_bars = positions(images['green-bar'], threshold=ct['green_bar'])
    logger('🟩 %d green bars detected' % len(green_bars))
    buttons = positions(images['go-work'], threshold=ct['go_to_work_btn'])
    logger('🆗 %d buttons detected' % len(buttons))

    not_working_green_bars = []
    for bar in green_bars:
        if not isWorking(bar, buttons):
            not_working_green_bars.append(bar)
    if len(not_working_green_bars) > 0:
        logger('🆗 %d buttons with green bar detected' %
               len(not_working_green_bars))
        logger('👆 Clicking in %d heroes' % len(not_working_green_bars))

    # se tiver botao com y maior que bar y-10 e menor que y+10
    hero_clicks_cnt = 0
    for (x, y, w, h) in not_working_green_bars:
        # isWorking(y, buttons)
        moveToWithRandomness(x + offset + (w / 2), y + (h / 2), 1)
        pyautogui.click()
        global hero_clicks
        hero_clicks = hero_clicks + 1
        hero_clicks_cnt = hero_clicks_cnt + 1
        if hero_clicks_cnt > 20:
            logger(
                '⚠️ Too many hero clicks, try to increase the go_to_work_btn threshold'
            )
            return
        #cv2.rectangle(sct_img, (x, y) , (x + w, y + h), (0,255,255),2)
    return len(not_working_green_bars)
コード例 #5
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def refreshHeroesPositions():

    logger('🔃 Refreshing Heroes Positions')
    clickBtn(images['go-back-arrow'])
    clickBtn(images['treasure-hunt-icon'])

    # time.sleep(3)
    clickBtn(images['treasure-hunt-icon'])
コード例 #6
0
def login():
    global login_attempts

    logger('😿 Checking if FireFox has crashed')

    if clickBtn(images['restore-this-tab'], timeout=5):
        logger('🎉 Restore tab button detected. Restoring FireFox Tab!')
        pyautogui.hotkey('ctrl', 'f5')

    logger('😿 Checking if game has disconnected')

    if login_attempts > 3:
        logger('🔃 Too many login attempts, refreshing')
        login_attempts = 0
        pyautogui.hotkey('ctrl', 'f5')
        return

    if clickBtn(images['connect-wallet'], timeout=15):
        logger('🎉 Connect wallet button detected, logging in!')
        login_attempts = login_attempts + 1
        #TODO mto ele da erro e poco o botao n abre
        # time.sleep(10)

    if clickBtn(images['select-wallet-2'], timeout=10):
        # sometimes the sign popup appears imediately
        login_attempts = login_attempts + 1
        # print('sign button clicked')
        # print('{} login attempt'.format(login_attempts))
        if clickBtn(images['treasure-hunt-icon'], timeout=15):
            # print('sucessfully login, treasure hunt btn clicked')
            login_attempts = 0
        return
        # click ok button

    if not clickBtn(images['select-wallet-1-no-hover'], ):
        if clickBtn(images['select-wallet-1-hover'],
                    threshold=ct['select_wallet_buttons']):
            pass
            # o ideal era que ele alternasse entre checar cada um dos 2 por um tempo
            # print('sleep in case there is no metamask text removed')
            # time.sleep(20)
    else:
        pass
        # print('sleep in case there is no metamask text removed')
        # time.sleep(20)

    if clickBtn(images['select-wallet-2'], timeout=20):
        login_attempts = login_attempts + 1
        # print('sign button clicked')
        # print('{} login attempt'.format(login_attempts))
        # time.sleep(25)
        if clickBtn(images['treasure-hunt-icon'], timeout=25):
            # print('sucessfully login, treasure hunt btn clicked')
            login_attempts = 0
        # time.sleep(15)

    if clickBtn(images['ok'], timeout=5):
        pass
コード例 #7
0
ファイル: dispatch.py プロジェクト: ryuichi1208/ImgConversion
def dispatch_exec_mode(args):
    """
    Dispatch to a function in the mode selected by the argument
    """
    if hasattr(args, 'quality'):
        if args.quality < 0 or 100 < args.quality:
            logger("ERROR", "Invalid argument of quality value", 1)
        compress_image(args)
    elif hasattr(args, 'height'):
        print("MODE resize")
    else:
        logger("ERROR", "Unkown Exec Mode", 1)
コード例 #8
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def clickButtons():
    buttons = positions(images['go-work'], threshold=ct['go_to_work_btn'])
    # print('buttons: {}'.format(len(buttons)))
    for (x, y, w, h) in buttons:
        moveToWithRandomness(x + (w / 2), y + (h / 2), 1)
        pyautogui.click()
        global hero_clicks
        hero_clicks = hero_clicks + 1
        #cv2.rectangle(sct_img, (x, y) , (x + w, y + h), (0,255,255),2)
        if hero_clicks > 20:
            logger(
                'too many hero clicks, try to increase the go_to_work_btn threshold'
            )
            return
    return len(buttons)
コード例 #9
0
ファイル: main.py プロジェクト: alxalx14/Discord-Logger
async def on_message(message):
    """
    Most importnat feature,
    gets called whenever a
    message is sent then builds
    the log structure.
    :param message:
    :return:
    """
    msg = message.clean_content if not message.attachments else message.attachments[
        0].url
    save_data = {
        message.id: {
            "guild": {
                "id": message.guild.id if message.guild else None,
                "name": message.guild.name if message.guild else None,
                "channel": {
                    "id": message.channel.id,
                }
            },
            "author": {
                "name": makeAuthor(message.author),
                "id": message.author.id
            },
            "message": {
                "type": str(message.channel.type),
                "content": msg
            },
            "time_stamp": f"{datetime.now()}"
        }
    }
    has_image = False if "http" not in msg else True
    stdout.write("\rUser: %s said: %s\n\n" % (makeAuthor(message.author), msg))
    log = logger(save_data, message.id)
    Thread(target=log.save, args=(has_image, )).start()
コード例 #10
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def clickFullBarButtons():
    offset = 100
    full_bars = positions(images['full-stamina'], threshold=ct['default'])
    buttons = positions(images['go-work'], threshold=ct['go_to_work_btn'])

    not_working_full_bars = []
    for bar in full_bars:
        if not isWorking(bar, buttons):
            not_working_full_bars.append(bar)

    if len(not_working_full_bars) > 0:
        logger('👆 Clicking in %d heroes' % len(not_working_full_bars))

    for (x, y, w, h) in not_working_full_bars:
        moveToWithRandomness(x + offset + (w / 2), y + (h / 2), 1)
        pyautogui.click()
        global hero_clicks
        hero_clicks = hero_clicks + 1

    return len(not_working_full_bars)
コード例 #11
0
def login_sid(account: dict):
    client = amino.Client()
    email = account.get("email")
    sid = account.get("sid")
    is_valid = account.get("isValid")
    if is_valid:
        while True:
            try:
                client.login_sid(sid)
                return client
            except amino.exceptions.ActionNotAllowed:
                client.device_id = client.headers.device_id = random.choice(
                    open(
                        os.path.join(os.getcwd(), "src", "devices",
                                     "devices.txt"),
                        "r").readlines()).replace("\n", "")
            except amino.exceptions.FailedLogin:
                service_log(email, "Failed login")
                return False
            except amino.exceptions.InvalidAccountOrPassword:
                service_log(email, "Invalid account or password")
                return False
            except amino.exceptions.InvalidPassword:
                service_log(email, "Invalid Password")
                return False
            except amino.exceptions.InvalidEmail:
                service_log(email, "Invalid Email")
                return False
            except amino.exceptions.AccountDoesntExist:
                service_log(email, "Account does not exist")
                return False
            except amino.exceptions.VerificationRequired as verify:
                service_log(email, str(verify))
                return False
            except Exception as e:
                service_log(email, str(e))
                logger(traceback.format_exc())
                return False
コード例 #12
0
    @property
    def ctime(self):
        return self.__ctime

    @property
    def height(self):
        return self.__height

    @property
    def width(self):
        return self.__width

    @filename.setter
    def filename(self, filename):
        self.__filename = filename


def main():
    """
    ImgConversion main function
    """
    args = get_option_and_parse()
    dispatch_exec_mode(args)


if __name__ == "__main__":
    logger("INFO", "START")
    main()
    logger("INFO", "END")
コード例 #13
0
import urllib.request, urllib.parse

from collections import defaultdict

from oyoyo.client import IRCClient
from oyoyo.parse import parse_nick

import botconfig
import src.settings as var
from src.dispatcher import MessageDispatcher
from src.utilities import *
from src.functions import get_players
from src.messages import messages
from src import channels, users, logger, errlog, events

adminlog = logger.logger("audit.log")

COMMANDS = defaultdict(list)
HOOKS = defaultdict(list)

# Error handler decorators and context managers

class _local(threading.local):
    handler = None
    level = 0

_local = _local()

# This is a mapping of stringified tracebacks to (link, uuid) tuples
# That way, we don't have to call in to the website everytime we have
# another error. If you ever need to delete pastes, do the following:
コード例 #14
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def main():
    """Main execution setup and loop"""
    # ==Setup==
    global hero_clicks
    global login_attempts
    global last_log_is_progress
    hero_clicks = 0
    login_attempts = 0
    last_log_is_progress = False

    global images
    images = load_images()

    if ch['enable']:
        global home_heroes
        home_heroes = loadHeroesToSendHome()
    else:
        print('>>---> Home feature not enabled')
    print('\n')

    print(cat)
    time.sleep(7)
    t = c['time_intervals']

    last = {
        "login": 0,
        "heroes": 0,
        "new_map": 0,
        "check_for_captcha": 0,
        "refresh_heroes": 0,
        "check_progress": 0,
    }
    # =========
    last["check_progress"] = time.time()

    p = s.Popen("wmctrl -l | grep Bombcrypto | awk '{print $1}'",
                shell=True,
                stdout=s.PIPE).communicate()[0].decode('utf-8').strip()
    win_ID = p.split('\n')

    while True:
        now = time.time()

        for i in win_ID:
            p = s.Popen(["wmctrl", "-ia", i])
            time.sleep(2)
            sendAllHeroesToWork()
            sys.stdout.flush()

            login()

            refreshFromStucked()

            refreshHeroesPositions()

            #clickBtn(teasureHunt)
            logger(None, progress_indicator=True)

            sys.stdout.flush()

            time.sleep(300)
コード例 #15
0
ファイル: spider.py プロジェクト: SainXIII/Spider_KS
	url = args.url
	depth = args.depth
	logfile = args.logfile
	loglevel = args.loglevel
	dbfile = args.dbfile
	threads = args.thread
	keyword = args.key
	testself = args.testself
	
	
	if testself is True:# 程序自测
		tester()
		exit(1)
	
	tasks = [url,]
	logger(logfile, loglevel)# 启动日志
	
	dbpool = Storepool(dbfile)# 启动数据库
	dbpool.createtable()
	
	analysis = Analysis(dbpool, keyword)# 启动页面分析模块
	linkpool = Linkpool(depth=depth)# 启动链接管理池
	fetchpool = Fetchpool(analysis, linkpool)# 启动爬虫工厂
	threadpool = Threadpool(fetchpool.fetcher())# 建立线程池
	threadpool.add(tasks)# 添加任务
	status = Status(threadpool, linkpool)# 创建状态反馈模块
	status.display()# 启动状态反馈模块
	
	threadpool.join()# 等待任务结束
	"""
	tasks = ["http://it.ouc.edu.cn/Default.aspx",]
コード例 #16
0
ファイル: main.py プロジェクト: bwdGitHub/discord_gen
from src.logger import logger
from src.config_parser import parse
from src.client import Gen_Client
from src.transform import GPT2_Transform, Postprocessor, Compose_Transform
import sys

# Set up logger
logger = logger()

# Parse config file
config_file = 'config.json'
if len(sys.argv) > 1:
    config_file = sys.argv[1]
config = parse(config_file)

# optional $github command will point to config['github']
# default just point to my repo.

github = config[
    'github'] if 'github' in config else 'https://github.com/bwdGitHub/discord_gen'

# Set up transformer to use
transformer = GPT2_Transform(max_length=100)
postprocessor = Postprocessor()
postprocessed_transformer = Compose_Transform(transformer, postprocessor)

# Set up client
client = Gen_Client(postprocessed_transformer, github=github)

# Run
client.run(config['token'])
コード例 #17
0
ファイル: index.py プロジェクト: ourlittletalk96/dap
def refreshFromStucked():
    logger('😿 Checking if stucked at progress bar')
    if clickBtn(images['progress-bar'], timeout=5):
        logger('🎉 Stucked at progress bar. Refreshing tab!')
        pyautogui.hotkey('ctrl', 'f5')
コード例 #18
0
def main():
    """Main execution setup and loop"""
    # ==Setup==
    global hero_clicks
    global login_attempts
    global last_log_is_progress
    hero_clicks = 0
    login_attempts = 0
    last_log_is_progress = False

    global images
    images = load_images()

    if ch['enable']:
        global home_heroes
        home_heroes = loadHeroesToSendHome()
    else:
        print('>>---> Home feature not enabled')
    print('\n')

    print(cat)
    time.sleep(7)
    t = c['time_intervals']

    last = {
        "login": 0,
        "heroes": 0,
        "new_map": 0,
        "check_for_captcha": 0,
        "refresh_heroes": 0,
        "check_progress": 0,
    }
    # =========
    last["check_progress"] = time.time()

    while True:
        now = time.time()

        #if now - last["check_for_captcha"] > addRandomness(t['check_for_captcha'] * 60):
        #    last["check_for_captcha"] = now

        if now - last["heroes"] > addRandomness(
                t['send_heroes_for_work'] * 60):
            last["heroes"] = now
            #refreshHeroes()
            sendAllHeroesToWork()

        if now - last["login"] > addRandomness(t['check_for_login'] * 60):
            sys.stdout.flush()
            last["login"] = now
            login()

        if now - last["check_progress"] >= 600:
            last["check_progress"] = now
            refreshFromStucked()
            login()

        if now - last["new_map"] > t['check_for_new_map_button']:
            last["new_map"] = now

            if clickBtn(images['new-map']):
                loggerMapClicked()

        if now - last["refresh_heroes"] > addRandomness(
                t['refresh_heroes_positions'] * 60):
            last["refresh_heroes"] = now
            refreshHeroesPositions()

        #clickBtn(teasureHunt)
        logger(None, progress_indicator=True)

        sys.stdout.flush()

        time.sleep(1)
コード例 #19
0
ファイル: decorators.py プロジェクト: Asorailahd/lykos
import traceback
import fnmatch
import socket
import types
from collections import defaultdict

from oyoyo.client import IRCClient
from oyoyo.parse import parse_nick

import botconfig
import src.settings as var
from src.utilities import *
from src import logger, errlog
from src.messages import messages

adminlog = logger.logger("audit.log")

COMMANDS = defaultdict(list)
HOOKS = defaultdict(list)

# Error handler decorators

class handle_error:

    def __new__(cls, func):
        if isinstance(func, cls): # already decorated
            return func

        self = super().__new__(cls)
        self.func = func
        return self