| Name | PokerNow JSON |
| Version |
0.7.2655
JSON |
| download |
| home_page | https://github.com/Zehmosu/PokerNow/ |
| Summary | A Python client for interacting with PokerNow games via the web. |
| upload_time | 2024-05-03 00:54:51 |
| maintainer | None |
| docs_url | None |
| author | Zehm |
| requires_python | >=3.7 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# PokerNow Client
A client for interacting with PokerNow.club using Selenium.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [PokerClient](#pokerclient)
- [Initialization](#initialization)
- [Methods](#methods)
- [GameStateManager](#gamestatemanager)
- [get_game_state](#get_game_state)
- [get_winners](#get_winners)
- [get_community_cards](#get_community_cards)
- [get_players_info](#get_players_info)
- [get_player_status](#get_player_status)
- [get_player_cards](#get_player_cards)
- [get_dealer_position](#get_dealer_position)
- [get_current_player](#get_current_player)
- [get_blinds](#get_blinds)
- [parse_stack_value](#parse_stack_value)
- [ActionHelper](#actionhelper)
- [get_available_actions](#get_available_actions)
- [perform_action](#perform_action)
- [handle_raise](#handle_raise)
- [check_and_handle_fold_confirmation](#check_and_handle_fold_confirmation)
- [ElementHelper](#elementhelper)
- [wait_for_element](#wait_for_element)
- [is_element_present](#is_element_present)
- [get_text](#get_text)
- [get_element](#get_element)
- [get_elements](#get_elements)
- [Models](#models)
- [Card](#card)
- [GameState](#gamestate)
- [PlayerInfo](#playerinfo)
- [PlayerState](#playerstate)
- [CookieManager](#cookiemanager)
- [load_cookies](#load_cookies)
- [save_cookies](#save_cookies)
- [Support](#support)
- [Contributing](#contributing)
- [License](#license)
## Installation
You can install the PokerNow Client using pip:
```
pip install PokerNow
```
## Usage
Here's an example of how to use the PokerNow Client:
```python
from selenium import webdriver
from pokernow import PokerClient
import time
# Create a new instance of a WebDriver
driver = webdriver.Firefox()
# Initialize the PokerClient with the driver and specify the cookie file path
client = PokerClient(driver, cookie_path='cookie_file.pkl')
# Navigate to the PokerNow.club login page
client.navigate('https://network.pokernow.club/sessions/new')
# Wait for the user to manually complete the login process and press Enter
input("Please complete the login process in the browser and press Enter to continue...")
# Save the cookies after successful login
client.cookie_manager.save_cookies()
# Navigate to a specific game or table (replace with your actual game link)
client.navigate('https://www.pokernow.club/games/pglev4PZzEvMv6DGgVNGbZz5J')
# Wait for the game to load
time.sleep(5)
# Retrieve the current game state
game_state = client.game_state_manager.get_game_state()
print("Game Type:", game_state.game_type)
print("Pot Size:", game_state.pot_size)
print("Community Cards:", [str(card) for card in game_state.community_cards])
print("Players:")
for player in game_state.players:
print(" Name:", player.name)
print(" Stack:", player.stack)
print(" Bet:", player.bet_value)
print(" Cards:", [str(card) for card in player.cards])
print(" Status:", player.status)
print(" Hand Message:", player.hand_message)
print("Dealer Position:", game_state.dealer_position)
print("Current Player:", game_state.current_player)
print("Blinds:", game_state.blinds)
print("Winners:")
for winner in game_state.winners:
print(" Name:", winner['name'])
print(" Stack Info:", winner['stack_info'])
# Perform actions based on the game state and your strategy
available_actions = client.action_helper.get_available_actions()
print("Available Actions:", list(available_actions.keys()))
if 'Call' in available_actions:
client.action_helper.perform_action('Call')
elif 'Check' in available_actions:
client.action_helper.perform_action('Check')
elif 'Raise' in available_actions:
client.action_helper.perform_action('Raise', amount=100)
else:
client.action_helper.perform_action('Fold')
# Close the browser when finished
driver.quit()
```
Make sure to have the appropriate WebDriver (e.g., ChromeDriver) installed and available in your system's PATH.
## PokerClient
The `PokerClient` class is the main entry point for interacting with PokerNow.club.
### Initialization
```python
def __init__(self, driver, cookie_path='pokernow_cookies.pkl')
```
- `driver`: The Selenium WebDriver instance.
- `cookie_path` (optional): The path to the cookie file for storing and loading cookies. Default is 'pokernow_cookies.pkl'.
### Methods
- `navigate(url)`: Navigates to the specified URL.
## GameStateManager
The `GameStateManager` class is responsible for managing and retrieving the game state information.
### get_game_state
```python
def get_game_state(self)
```
Retrieves the current game state, including game type, pot size, community cards, players' information, dealer position, current player, blinds, and winners.
### get_winners
```python
def get_winners(self)
```
Retrieves the winners of the current hand, including their names and stack information.
### get_community_cards
```python
def get_community_cards(self)
```
Retrieves the community cards on the table.
### get_players_info
```python
def get_players_info(self)
```
Retrieves information about all players at the table, including their names, stack sizes, bet values, cards, status, and hand messages.
### get_player_status
```python
def get_player_status(self, player_element)
```
Determines the status of a player based on the player element.
### get_player_cards
```python
def get_player_cards(self, player_element)
```
Retrieves the cards of a player based on the player element.
### get_dealer_position
```python
def get_dealer_position(self)
```
Retrieves the position of the dealer button.
### get_current_player
```python
def get_current_player(self)
```
Retrieves the name of the current player.
### get_blinds
```python
def get_blinds(self)
```
Retrieves the values of the blinds.
### parse_stack_value
```python
def parse_stack_value(self, stack_value)
```
Parses the stack value string and returns the numeric value.
## ActionHelper
The `ActionHelper` class provides methods for interacting with the game and performing actions.
### get_available_actions
```python
def get_available_actions(self)
```
Retrieves the available actions for the current player.
### perform_action
```python
def perform_action(self, action, amount=None)
```
Performs the specified action (e.g., 'Call', 'Raise', 'Check', 'Fold') with an optional amount for raising.
### handle_raise
```python
def handle_raise(self, amount)
```
Handles the raise action by entering the raise amount and confirming the bet.
### check_and_handle_fold_confirmation
```python
def check_and_handle_fold_confirmation(self)
```
Checks for a fold confirmation dialog and handles it if present.
## ElementHelper
The `ElementHelper` class provides utility methods for interacting with web elements using Selenium.
### wait_for_element
```python
def wait_for_element(self, selector, timeout=10)
```
Waits for an element to be present on the page within the specified timeout.
### is_element_present
```python
def is_element_present(self, selector)
```
Checks if an element is present on the page.
### get_text
```python
def get_text(self, selector, context=None)
```
Retrieves the text of an element specified by the selector, optionally within a specific context element.
### get_element
```python
def get_element(self, selector)
```
Retrieves a single element specified by the selector.
### get_elements
```python
def get_elements(self, selector)
```
Retrieves multiple elements specified by the selector.
## Models
The `models` module contains data models used throughout the project.
### Card
Represents a playing card with rank and suit.
### GameState
Represents the state of the game, including game type, pot size, community cards, players' information, dealer position, current player, blinds, and winners.
### PlayerInfo
Represents information about a player, including name, stack size, bet value, cards, status, and hand message.
### PlayerState
Enum representing the possible states of a player (CURRENT, FOLDED, OFFLINE, ACTIVE).
## CookieManager
The `CookieManager` class handles loading and saving cookies for the PokerNow.club website.
### load_cookies
```python
def load_cookies(self)
```
Loads cookies from the specified cookie file, if it exists.
### save_cookies
```python
def save_cookies(self)
```
Saves the current cookies to the specified cookie file.
## Support
If you find this project helpful and would like to support its development, you can buy me a coffee at [https://buymeacoffee.com/zehm](https://buymeacoffee.com/zehm). Your support is greatly appreciated!
## Contributing
Contributions are welcome! Please submit a pull request or open an issue on the GitHub repository.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
Raw data
{
"_id": null,
"home_page": "https://github.com/Zehmosu/PokerNow/",
"name": "PokerNow",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Zehm",
"author_email": "mrtentacleshasallthetalent@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f1/c4/2208001b7eb4a6a648ce2c5a074654da49561456cb6ba84d3e39d4920a38/pokernow-0.7.2655.tar.gz",
"platform": null,
"description": "# PokerNow Client\r\n\r\nA client for interacting with PokerNow.club using Selenium.\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n- [PokerClient](#pokerclient)\r\n - [Initialization](#initialization)\r\n - [Methods](#methods)\r\n- [GameStateManager](#gamestatemanager)\r\n - [get_game_state](#get_game_state)\r\n - [get_winners](#get_winners)\r\n - [get_community_cards](#get_community_cards)\r\n - [get_players_info](#get_players_info)\r\n - [get_player_status](#get_player_status)\r\n - [get_player_cards](#get_player_cards)\r\n - [get_dealer_position](#get_dealer_position)\r\n - [get_current_player](#get_current_player)\r\n - [get_blinds](#get_blinds)\r\n - [parse_stack_value](#parse_stack_value)\r\n- [ActionHelper](#actionhelper)\r\n - [get_available_actions](#get_available_actions)\r\n - [perform_action](#perform_action)\r\n - [handle_raise](#handle_raise)\r\n - [check_and_handle_fold_confirmation](#check_and_handle_fold_confirmation)\r\n- [ElementHelper](#elementhelper)\r\n - [wait_for_element](#wait_for_element)\r\n - [is_element_present](#is_element_present)\r\n - [get_text](#get_text)\r\n - [get_element](#get_element)\r\n - [get_elements](#get_elements)\r\n- [Models](#models)\r\n - [Card](#card)\r\n - [GameState](#gamestate)\r\n - [PlayerInfo](#playerinfo)\r\n - [PlayerState](#playerstate)\r\n- [CookieManager](#cookiemanager)\r\n - [load_cookies](#load_cookies)\r\n - [save_cookies](#save_cookies)\r\n- [Support](#support)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n## Installation\r\n\r\nYou can install the PokerNow Client using pip:\r\n\r\n```\r\npip install PokerNow\r\n```\r\n\r\n## Usage\r\n\r\nHere's an example of how to use the PokerNow Client:\r\n\r\n```python\r\nfrom selenium import webdriver\r\nfrom pokernow import PokerClient\r\nimport time\r\n\r\n# Create a new instance of a WebDriver\r\ndriver = webdriver.Firefox()\r\n\r\n# Initialize the PokerClient with the driver and specify the cookie file path\r\nclient = PokerClient(driver, cookie_path='cookie_file.pkl')\r\n\r\n# Navigate to the PokerNow.club login page\r\nclient.navigate('https://network.pokernow.club/sessions/new')\r\n\r\n# Wait for the user to manually complete the login process and press Enter\r\ninput(\"Please complete the login process in the browser and press Enter to continue...\")\r\n\r\n# Save the cookies after successful login\r\nclient.cookie_manager.save_cookies()\r\n\r\n# Navigate to a specific game or table (replace with your actual game link)\r\nclient.navigate('https://www.pokernow.club/games/pglev4PZzEvMv6DGgVNGbZz5J')\r\n\r\n# Wait for the game to load\r\ntime.sleep(5)\r\n\r\n# Retrieve the current game state\r\ngame_state = client.game_state_manager.get_game_state()\r\nprint(\"Game Type:\", game_state.game_type)\r\nprint(\"Pot Size:\", game_state.pot_size)\r\nprint(\"Community Cards:\", [str(card) for card in game_state.community_cards])\r\nprint(\"Players:\")\r\nfor player in game_state.players:\r\n print(\" Name:\", player.name)\r\n print(\" Stack:\", player.stack)\r\n print(\" Bet:\", player.bet_value)\r\n print(\" Cards:\", [str(card) for card in player.cards])\r\n print(\" Status:\", player.status)\r\n print(\" Hand Message:\", player.hand_message)\r\nprint(\"Dealer Position:\", game_state.dealer_position)\r\nprint(\"Current Player:\", game_state.current_player)\r\nprint(\"Blinds:\", game_state.blinds)\r\nprint(\"Winners:\")\r\nfor winner in game_state.winners:\r\n print(\" Name:\", winner['name'])\r\n print(\" Stack Info:\", winner['stack_info'])\r\n\r\n# Perform actions based on the game state and your strategy\r\navailable_actions = client.action_helper.get_available_actions()\r\nprint(\"Available Actions:\", list(available_actions.keys()))\r\n\r\nif 'Call' in available_actions:\r\n client.action_helper.perform_action('Call')\r\nelif 'Check' in available_actions:\r\n client.action_helper.perform_action('Check')\r\nelif 'Raise' in available_actions:\r\n client.action_helper.perform_action('Raise', amount=100)\r\nelse:\r\n client.action_helper.perform_action('Fold')\r\n\r\n# Close the browser when finished\r\ndriver.quit()\r\n```\r\n\r\nMake sure to have the appropriate WebDriver (e.g., ChromeDriver) installed and available in your system's PATH.\r\n\r\n## PokerClient\r\n\r\nThe `PokerClient` class is the main entry point for interacting with PokerNow.club.\r\n\r\n### Initialization\r\n\r\n```python\r\ndef __init__(self, driver, cookie_path='pokernow_cookies.pkl')\r\n```\r\n\r\n- `driver`: The Selenium WebDriver instance.\r\n- `cookie_path` (optional): The path to the cookie file for storing and loading cookies. Default is 'pokernow_cookies.pkl'.\r\n\r\n### Methods\r\n\r\n- `navigate(url)`: Navigates to the specified URL.\r\n\r\n## GameStateManager\r\n\r\nThe `GameStateManager` class is responsible for managing and retrieving the game state information.\r\n\r\n### get_game_state\r\n\r\n```python\r\ndef get_game_state(self)\r\n```\r\n\r\nRetrieves the current game state, including game type, pot size, community cards, players' information, dealer position, current player, blinds, and winners.\r\n\r\n### get_winners\r\n\r\n```python\r\ndef get_winners(self)\r\n```\r\n\r\nRetrieves the winners of the current hand, including their names and stack information.\r\n\r\n### get_community_cards\r\n\r\n```python\r\ndef get_community_cards(self)\r\n```\r\n\r\nRetrieves the community cards on the table.\r\n\r\n### get_players_info\r\n\r\n```python\r\ndef get_players_info(self)\r\n```\r\n\r\nRetrieves information about all players at the table, including their names, stack sizes, bet values, cards, status, and hand messages.\r\n\r\n### get_player_status\r\n\r\n```python\r\ndef get_player_status(self, player_element)\r\n```\r\n\r\nDetermines the status of a player based on the player element.\r\n\r\n### get_player_cards\r\n\r\n```python\r\ndef get_player_cards(self, player_element)\r\n```\r\n\r\nRetrieves the cards of a player based on the player element.\r\n\r\n### get_dealer_position\r\n\r\n```python\r\ndef get_dealer_position(self)\r\n```\r\n\r\nRetrieves the position of the dealer button.\r\n\r\n### get_current_player\r\n\r\n```python\r\ndef get_current_player(self)\r\n```\r\n\r\nRetrieves the name of the current player.\r\n\r\n### get_blinds\r\n\r\n```python\r\ndef get_blinds(self)\r\n```\r\n\r\nRetrieves the values of the blinds.\r\n\r\n### parse_stack_value\r\n\r\n```python\r\ndef parse_stack_value(self, stack_value)\r\n```\r\n\r\nParses the stack value string and returns the numeric value.\r\n\r\n## ActionHelper\r\n\r\nThe `ActionHelper` class provides methods for interacting with the game and performing actions.\r\n\r\n### get_available_actions\r\n\r\n```python\r\ndef get_available_actions(self)\r\n```\r\n\r\nRetrieves the available actions for the current player.\r\n\r\n### perform_action\r\n\r\n```python\r\ndef perform_action(self, action, amount=None)\r\n```\r\n\r\nPerforms the specified action (e.g., 'Call', 'Raise', 'Check', 'Fold') with an optional amount for raising.\r\n\r\n### handle_raise\r\n\r\n```python\r\ndef handle_raise(self, amount)\r\n```\r\n\r\nHandles the raise action by entering the raise amount and confirming the bet.\r\n\r\n### check_and_handle_fold_confirmation\r\n\r\n```python\r\ndef check_and_handle_fold_confirmation(self)\r\n```\r\n\r\nChecks for a fold confirmation dialog and handles it if present.\r\n\r\n## ElementHelper\r\n\r\nThe `ElementHelper` class provides utility methods for interacting with web elements using Selenium.\r\n\r\n### wait_for_element\r\n\r\n```python\r\ndef wait_for_element(self, selector, timeout=10)\r\n```\r\n\r\nWaits for an element to be present on the page within the specified timeout.\r\n\r\n### is_element_present\r\n\r\n```python\r\ndef is_element_present(self, selector)\r\n```\r\n\r\nChecks if an element is present on the page.\r\n\r\n### get_text\r\n\r\n```python\r\ndef get_text(self, selector, context=None)\r\n```\r\n\r\nRetrieves the text of an element specified by the selector, optionally within a specific context element.\r\n\r\n### get_element\r\n\r\n```python\r\ndef get_element(self, selector)\r\n```\r\n\r\nRetrieves a single element specified by the selector.\r\n\r\n### get_elements\r\n\r\n```python\r\ndef get_elements(self, selector)\r\n```\r\n\r\nRetrieves multiple elements specified by the selector.\r\n\r\n## Models\r\n\r\nThe `models` module contains data models used throughout the project.\r\n\r\n### Card\r\n\r\nRepresents a playing card with rank and suit.\r\n\r\n### GameState\r\n\r\nRepresents the state of the game, including game type, pot size, community cards, players' information, dealer position, current player, blinds, and winners.\r\n\r\n### PlayerInfo\r\n\r\nRepresents information about a player, including name, stack size, bet value, cards, status, and hand message.\r\n\r\n### PlayerState\r\n\r\nEnum representing the possible states of a player (CURRENT, FOLDED, OFFLINE, ACTIVE).\r\n\r\n## CookieManager\r\n\r\nThe `CookieManager` class handles loading and saving cookies for the PokerNow.club website.\r\n\r\n### load_cookies\r\n\r\n```python\r\ndef load_cookies(self)\r\n```\r\n\r\nLoads cookies from the specified cookie file, if it exists.\r\n\r\n### save_cookies\r\n\r\n```python\r\ndef save_cookies(self)\r\n```\r\n\r\nSaves the current cookies to the specified cookie file.\r\n\r\n## Support\r\n\r\nIf you find this project helpful and would like to support its development, you can buy me a coffee at [https://buymeacoffee.com/zehm](https://buymeacoffee.com/zehm). Your support is greatly appreciated!\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please submit a pull request or open an issue on the GitHub repository.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python client for interacting with PokerNow games via the web.",
"version": "0.7.2655",
"project_urls": {
"Homepage": "https://github.com/Zehmosu/PokerNow/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f1c42208001b7eb4a6a648ce2c5a074654da49561456cb6ba84d3e39d4920a38",
"md5": "16ede694f4d92609aa5c2fe1c750743b",
"sha256": "05e82938972068ee51bafdb4a2a7502c4e20e7adf9fc270de39fc2b6a8d5149f"
},
"downloads": -1,
"filename": "pokernow-0.7.2655.tar.gz",
"has_sig": false,
"md5_digest": "16ede694f4d92609aa5c2fe1c750743b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11843,
"upload_time": "2024-05-03T00:54:51",
"upload_time_iso_8601": "2024-05-03T00:54:51.582294Z",
"url": "https://files.pythonhosted.org/packages/f1/c4/2208001b7eb4a6a648ce2c5a074654da49561456cb6ba84d3e39d4920a38/pokernow-0.7.2655.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-03 00:54:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Zehmosu",
"github_project": "PokerNow",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pokernow"
}