diff --git a/README.md b/README.md index 1c9620d..354464f 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ resume_key | After starting the exe botty will wait for this keypress to atually color_checker_key | Pressing this key will start a debug mode to check if the color filtering works with your settings. It also includes the item search and marks items it would pick up with red circles logger_lvl | Can be any of [info, debug] and determines how much output you see on the command line randomize_runs | If 0, the order will always be pindle -> eldritch/shenk. If 1 the order will be random. +send_drops_to_discord | If 1 sends your drops to the discord channel "drop-log" +custom_discord_hook | If 1 sends a message about drops to this hook and will update you in case botty got stuck and can not resume [routes] | Descriptions --------------------------------|--------------------------------------------- diff --git a/environment.yml b/environment.yml index 4f86bdf..a3fb62d 100644 --- a/environment.yml +++ b/environment.yml @@ -16,3 +16,4 @@ dependencies: - beautifultable - zstandard - pytweening + - requests diff --git a/params.ini b/params.ini index ff3a309..c77a973 100644 --- a/params.ini +++ b/params.ini @@ -7,6 +7,8 @@ auto_settings_key=f9 color_checker_key=f10 logg_lvl=info randomize_runs=0 +send_drops_to_discord=1 +custom_discord_hook= [routes] run_pindle=1 diff --git a/src/bot.py b/src/bot.py index 66aeb72..7bbdbb1 100644 --- a/src/bot.py +++ b/src/bot.py @@ -14,7 +14,7 @@ from health_manager import HealthManager from death_manager import DeathManager from npc_manager import NpcManager, Npc from pickit import PickIt -from utils.misc import wait +from utils.misc import wait, send_discord import keyboard import threading import time @@ -103,7 +103,11 @@ class Bot: self._timer = time.time() found, _ = self._template_finder.search_and_wait("D2_LOGO_HS", time_out=70) if not found: - Logger.error("Something went wrong here, bot is unsure about current location. Exit game and closing down bot.") + Logger.error("Something went wrong here, bot is unsure about current location. Closing down bot.") + if self._config.general["custom_discord_hook"] != "": + send_discord_thread = threading.Thread(target=send_discord, args=("Botty got stuck and can not resume", self._config.general["custom_discord_hook"])) + send_discord_thread.daemon = True + send_discord_thread.start() self._ui_manager.save_and_exit() os._exit(1) self._ui_manager.start_hell_game() diff --git a/src/config.py b/src/config.py index f08046f..76be933 100644 --- a/src/config.py +++ b/src/config.py @@ -30,6 +30,8 @@ class Config: "color_checker_key": self._select_val("general", "color_checker_key"), "logg_lvl": self._select_val("general", "logg_lvl"), "randomize_runs": bool(int(self._select_val("general", "randomize_runs"))), + "send_drops_to_discord": bool(int(self._select_val("general", "send_drops_to_discord"))), + "custom_discord_hook": self._select_val("general", "custom_discord_hook"), } self.routes = {} diff --git a/src/pickit.py b/src/pickit.py index 10dd3ac..2245625 100644 --- a/src/pickit.py +++ b/src/pickit.py @@ -7,7 +7,8 @@ from char.i_char import IChar from logger import Logger from screen import Screen from ui_manager import UiManager -import random +import threading +from utils.misc import send_discord class PickIt: @@ -54,6 +55,17 @@ class PickIt: time.sleep(0.1) mouse.click(button="left") time.sleep(0.5) + + if self._config.general["send_drops_to_discord"]: + send_discord_thread = threading.Thread(target=send_discord, args=(closest_item.name,)) + send_discord_thread.daemon = True + send_discord_thread.start() + + if self._config.general["custom_discord_hook"] != "": + send_discord_thread = threading.Thread(target=send_discord, args=(closest_item.name, self._config.general["custom_discord_hook"])) + send_discord_thread.daemon = True + send_discord_thread.start() + if self._ui_manager.is_overburdened(): Logger.warning("Inventory full, skipping pickit!") # TODO: should go back to town and stash stuff then go back to picking up more stuff diff --git a/src/utils/misc.py b/src/utils/misc.py index f170400..c0d07c6 100644 --- a/src/utils/misc.py +++ b/src/utils/misc.py @@ -4,8 +4,15 @@ import ctypes from logger import Logger import cv2 from typing import List, Tuple +import requests +def send_discord(item_name, url:str = None): + if url is None: + url = "https://discord.com/api/webhooks/908045354061160459/8-HQRLPTHxMlf5VpvScuvNEpLLIe8KHqxgRIk6p17u6LMPvzCCQotT_iGioQHQVU5u_P" + data = {"content": f"Botty just found: {item_name}"} + requests.post(url, json=data) + def wait(min_seconds, max_seconds = None): if max_seconds is None: max_seconds = min_seconds