Skip to content

Commit

Permalink
Merge pull request #4 from viktorashi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
viktorashi authored Sep 12, 2023
2 parents accc798 + 80d96b3 commit 09cde2e
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
output.json
click.py

12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ git clone https://github.com/viktorashi/bingobaker.com-autoplayer && cd bingobak
python autobingo.py -h
```
```string
usage: autobingo [-h] [-u URL] [-cnt COUNT] [-i INPUT_PATH] [-o OUTPUT_PATH] [-c CARDS_PATH] [-gm {normal,blackout,peen,3in6,loser}] [-r]
[-strt START] [-fs FREE_SPACE]
usage: autobingo [-h] [-u URL] [-cnt COUNT] [-i INPUT_PATH] [-o OUTPUT_PATH] [-c CARDS_PATH] [-gm {normal,blackout,peen,3in6,loser}] [-r] [-strt START] [-fs FREE_SPACE]
[-acc NUM_OF_THREADS]
[{editconfig,generate,check}]
Auto Bingo playing command line tool. Currently only being used for bingobaker.com
Expand All @@ -43,7 +43,7 @@ options:
-i INPUT_PATH, --input INPUT_PATH
The file containing the keywords to search for on the bingo cards [default: input.txt]
-o OUTPUT_PATH, --output OUTPUT_PATH
File to write the bingo'ed cards to [default: output.json]
File to write the bingo'ed cards to [default: output.txt]
-c CARDS_PATH, --cards CARDS_PATH
The path you want the cards to be saved in
-gm {normal,blackout,peen,3in6,loser}, --gamemode {normal,blackout,peen,3in6,loser}
Expand All @@ -53,6 +53,8 @@ options:
The index of the card to start doing anything from
-fs FREE_SPACE, --free-space FREE_SPACE
Name of the freespace to search for in the card [default: 'no credit']
-acc NUM_OF_THREADS, -accelleration NUM_OF_THREADS
The number of threads to use for speeding up
ion care how u use my code lol
```
Expand All @@ -66,6 +68,8 @@ for the operation and options
- check :checks bingos for each card, will be less used since it automatically checks the bingo eitherway for each card as it searches
- editconfig : is the default behaviour if nothing specified, it does nothing but update the ***bingoconfig.json***

### <font size=5> --accelleration <sub> [default: 7 , shorthand -acc]</sub> </font>: The number of threads to use for speeding it up, careful: too many and it's won't really work that well, I suggest around 10-15 the max, it's plenty fast eitherway

### <font size=5> --input <sub> [default: input.txt , shorthand -i]</sub> </font> is the file in which you have the keywords you want to search for on the bingo cards, each keyword on a new line. They DON'T have to be specified exactly as in the cards, lowercase values will be compared and they can just contain those strings
#### **`inpux.txt`**
```
Expand Down Expand Up @@ -129,7 +133,7 @@ python autobingo.py mark --reverse
<h3><span style="color:#F47174"> 3. It will all be saved </span></h3>


### Every parameter value you provide to the command will be saved in a file called ***bingoconfig.json*** right next to the program. Plus it will automatically check set the size to the card's size, if the free space is in the middle or not and update that in the config file <h3><span style="color:red"> DO NOT CHANGE THE CONFIG FILE DIRECTLY</span></h3>
### Every parameter value you provide to the command will be saved in a file called ***bingoconfig.json*** right next to the program. Plus it will automatically check set the size to the card's size, if the free space is in the middle or not and update that in the config file. Found bingo's are automatically clicked as well<h3><span style="color:red"> DO NOT CHANGE THE CONFIG FILE DIRECTLY</span></h3>



Expand Down
10 changes: 8 additions & 2 deletions autobingo.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@
type=str,
dest="free_space",
)

parser.add_argument(
"-acc",
"-accelleration",
help="The number of threads to use for speeding up",
type=int,
dest="num_of_threads",
)

# the rest of the defaults are in the autobingo class definition
parser.set_defaults(count=-1, mode="editconfig")
Expand Down Expand Up @@ -130,7 +136,7 @@
options[arg] = args[arg]

# this is not for the simpletons, code will figure it out
options_for_class_not_user = ["free_space_in_middle", "size"]
options_for_class_not_user = ["free_space_in_middle", "size", "bingo_id"]
for option in options_for_class_not_user:
if option in file_config:
options[option] = file_config[option]
Expand Down
21 changes: 0 additions & 21 deletions click.py

This file was deleted.

21 changes: 21 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import requests, re
from threading import Thread


def generate():
response = requests.post("https://bingobaker.com/play/64c998520e68afc5")
pattern = r'<meta property="og:url" content="([^"]+)"'

matches = re.findall(pattern, response.text)

if matches:
session = matches[0]
print(session)
else:
print("Error getting Session key")
return session


for i in range(20):
x = Thread(target=generate)
x.start()
29 changes: 23 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from threading import Thread
from utils import (
check_bingos_and_write_to_output,
read_cards_file,
update_if_free_space_in_middle,
generate_and_return_details,
update_card_size,
read_from_input,
generate_multiple_cards,
)

# do enums idk
Expand All @@ -25,6 +27,8 @@ def __init__(
free_space_in_middle: bool = False,
headless: bool = True,
size: int = 5,
bingo_id: str = "",
num_of_threads: int = 7,
) -> None:
"""
driver : selenium.webdriver
Expand All @@ -36,6 +40,7 @@ def __init__(
"""
# turn input phrases file path into list of strings
# dont mention input_path or cards_path if you're using the generate function
self.num_of_threads = num_of_threads
self.free_space_in_middle = free_space_in_middle
self.size = size
self.input_path = input_path
Expand All @@ -48,6 +53,7 @@ def __init__(
self.url = url
self.output_path = output_path
self.headless = headless
self.bingo_id = bingo_id

if gamemode == "3in6":
self.size = 6
Expand All @@ -59,14 +65,25 @@ def createCards(self, num: int) -> None:
# check for the first card to update the details
if self.url == "":
raise ValueError("generate url not provided")
card = generate_and_return_details(self)

card = generate_and_return_details(self, 0)
update_if_free_space_in_middle(self, card)
update_card_size(self, card)
for _ in range(1, num):
try:
generate_and_return_details(self)
except TimeoutError:
print(TimeoutError)

threads = []
for _ in range(self.num_of_threads):
t = Thread(
target=generate_multiple_cards,
args=(self, int(num / self.num_of_threads)),
)
t.daemon = True
threads.append(t)

for thread in threads:
thread.start()

for thread in threads:
thread.join()

def check_bingo_of_all_cards(self) -> None:
"""
Expand Down
28 changes: 0 additions & 28 deletions output.json

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ numpy==1.25.2
requests==2.31.0
soupsieve==2.5
urllib3==2.0.4
websockets==11.0.3
Loading

0 comments on commit 09cde2e

Please sign in to comment.