pokerbots-dev 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/PKG-INFO +1 -1
  2. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/pyproject.toml +1 -1
  3. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/api.py +2 -2
  4. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/commands/account.py +22 -5
  5. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/docs.md +1 -0
  6. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/.gitignore +0 -0
  7. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/README.md +0 -0
  8. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/__init__.py +0 -0
  9. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/agent.py +0 -0
  10. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/auth.py +0 -0
  11. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/cards.py +0 -0
  12. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/commands/__init__.py +0 -0
  13. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/commands/admin.py +0 -0
  14. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/commands/local.py +0 -0
  15. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/commands/money.py +0 -0
  16. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/engine.py +0 -0
  17. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/fmt.py +0 -0
  18. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/house.py +0 -0
  19. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/main.py +0 -0
  20. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/template/bot.py +0 -0
  21. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/src/pokerbots_cli/wallet.py +0 -0
  22. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/tests/test_agent.py +0 -0
  23. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/tests/test_cards.py +0 -0
  24. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/tests/test_cli.py +0 -0
  25. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/tests/test_engine.py +0 -0
  26. {pokerbots_dev-0.1.0 → pokerbots_dev-0.1.2}/tests/test_wallet.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pokerbots-dev
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: pb: command-line client for pokerbots.dev
5
5
  Project-URL: Homepage, https://pokerbots.dev
6
6
  Project-URL: Source, https://github.com/pokerbots-dev/pokerbots
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pokerbots-dev"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "pb: command-line client for pokerbots.dev"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -3,7 +3,7 @@ import os
3
3
  import urllib.error
4
4
  import urllib.request
5
5
 
6
- from . import auth
6
+ from . import __version__, auth
7
7
 
8
8
 
9
9
  class ApiError(Exception):
@@ -15,7 +15,7 @@ def base():
15
15
 
16
16
 
17
17
  def call(method, path, body=None, data=None, headers=None):
18
- headers = dict(headers or {})
18
+ headers = {"User-Agent": f"pb/{__version__}", **(headers or {})}
19
19
  if "CF-Access-Client-Id" not in headers:
20
20
  credentials = auth.load()
21
21
  if not credentials:
@@ -1,5 +1,6 @@
1
1
  import io
2
2
  import sys
3
+ import time
3
4
  import zipfile
4
5
  from pathlib import Path
5
6
 
@@ -8,6 +9,7 @@ from ..api import call
8
9
  from ..fmt import money, place, table
9
10
 
10
11
  MAX_UPLOAD = 1 << 20
12
+ WATCH_SECONDS = 5
11
13
  ATTEST = "I am 18 or older, and paid skill competitions are allowed where I am. [y/N] "
12
14
 
13
15
 
@@ -54,20 +56,34 @@ def stop(args):
54
56
  print(f"stopped {mode}")
55
57
 
56
58
 
57
- def status(args):
59
+ def report():
58
60
  me = call("GET", "/me")
59
61
  rows = [["user", me["login"]], ["versions", " ".join(f"v{v}" for v in me["versions"]) or "-"]]
60
62
  for mode in ("paper", "live"):
61
63
  d = me["deployments"].get(mode)
62
64
  rows.append([mode, f"v{d['version']} rating {d['rating']:.0f} games {d['games']} today {d['today']}" if d else "-"])
63
65
  rows += [["balance", money(me["balance"])], ["wallet", me["wallet"] or "-"]]
64
- print(table(rows))
66
+ text = table(rows)
65
67
  games = call("GET", "/games")
66
68
  if games:
67
- print()
68
- print(table([["game", "mode", "place", "hands"]] + [
69
+ text += "\n\n" + table([["game", "mode", "place", "hands"]] + [
69
70
  [g["created_at"], g["mode"], place(g["place"]), g["hands"] or "-"] for g in games
70
- ]))
71
+ ])
72
+ return text
73
+
74
+
75
+ def status(args):
76
+ print(report())
77
+
78
+
79
+ def watch(args):
80
+ try:
81
+ while True:
82
+ sys.stdout.write("\x1b[H\x1b[2J" + report() + "\n\nctrl-c to quit\n")
83
+ sys.stdout.flush()
84
+ time.sleep(WATCH_SECONDS)
85
+ except KeyboardInterrupt:
86
+ pass
71
87
 
72
88
 
73
89
  def register(sub):
@@ -87,3 +103,4 @@ def register(sub):
87
103
  p.set_defaults(run=run)
88
104
 
89
105
  sub.add_parser("status", help="your bot, rating, balance and recent games").set_defaults(run=status)
106
+ sub.add_parser("watch", help="status, live").set_defaults(run=watch)
@@ -9,6 +9,7 @@ start
9
9
  pb deploy v1 --live play for money with v1
10
10
  pb stop --paper|--live stop playing
11
11
  pb status versions, rating, balance, recent games
12
+ pb watch the same, refreshed every 5 seconds
12
13
  pb docs [--plain] show this
13
14
 
14
15
  money
File without changes
File without changes