Skip to content

Commit

Permalink
add tf2-data and option for pricer
Browse files Browse the repository at this point in the history
  • Loading branch information
offish committed Dec 10, 2023
1 parent 5bcc38b commit 063effe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions express/config.example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "nickname",
"check_versions_on_startup": true,
"listen_to_pricer": true,
"bots": [
{
"name": "bot1",
Expand All @@ -13,6 +14,7 @@
"identity_secret": "aA11aaaa/aa11a/aAAa1a1="
},
"options": {
"fetch_prices_on_startup": true,
"accept_donations": true,
"decline_bad_offers": false,
"decline_trade_hold": true,
Expand Down
5 changes: 3 additions & 2 deletions express/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ def __append_autopriced_items(self) -> None:
def run(self) -> None:
logging.info(f"Fetching offers every {self.options.poll_interval} seconds")

self.__append_autopriced_items()
self.__update_prices()
if self.options.fetch_prices_on_startup:
self.__append_autopriced_items()
self.__update_prices()

inventory = self.inventory.fetch(self.steam_id)
self.stock = get_inventory_stock(inventory)
Expand Down
4 changes: 3 additions & 1 deletion express/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@dataclass
class Options:
fetch_prices_on_startup: bool = True
accept_donations: bool = False
decline_bad_offers: bool = False
decline_trade_hold: bool = False
Expand All @@ -18,5 +19,6 @@ class Options:
@dataclass
class GlobalOptions:
bots: list[dict]
name: str = "express user" # nickname
name: str = "express user" # nickname for gui
check_versions_on_startup: bool = True
listen_to_pricer: bool = True
18 changes: 11 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from tf2_utils import PricesTFSocket
from tf2_utils import __version__ as tf2_utils_version
from tf2_data import __version__ as tf2_data_version
from express import __version__ as tf2_express_version
from tf2_sku import __version__ as tf2_sku_version

Expand All @@ -23,6 +24,7 @@
packages = [
(tf2_express_version, "tf2-express", "express"),
(tf2_utils_version, "tf2-utils", "src/tf2_utils"),
(tf2_data_version, "tf2-data", "src/tf2_data"),
(tf2_sku_version, "tf2-sku", "src/tf2_sku"),
]

Expand Down Expand Up @@ -88,11 +90,6 @@ def on_price_change(data: dict) -> None:
config = get_config()
options = GlobalOptions(**config)

prices_tf_socket = PricesTFSocket(on_price_change)
prices_thread = Thread(target=prices_tf_socket.listen, daemon=True)

logging.info("Listening to Prices.tf for price updates")

if options.check_versions_on_startup:
for i in packages:
current_version, repo, folder = i
Expand All @@ -107,7 +104,13 @@ def on_price_change(data: dict) -> None:
)
)

prices_thread.start()
if options.listen_to_pricer:
prices_tf_socket = PricesTFSocket(on_price_change)
prices_thread = Thread(target=prices_tf_socket.listen, daemon=True)
prices_thread.start()

logging.info("Listening to Prices.tf for price updates")

bot_threads: list[Thread] = []

for bot in options.bots:
Expand All @@ -122,4 +125,5 @@ def on_price_change(data: dict) -> None:
for thread in bot_threads:
thread.join()

prices_thread.join()
if options.listen_to_pricer:
prices_thread.join()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steampy>=1.1.0
tf2-sku>=2.0.1
tf2-data>=0.0.4
tf2-data>=0.0.5
tf2-utils>=2.0.7
requests
pymongo
Expand Down

0 comments on commit 063effe

Please sign in to comment.