Skip to content

Commit

Permalink
made it way bettetrrer
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorashi committed Sep 10, 2023
1 parent aaf398d commit 454033f
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 314 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
output.json
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ git clone https://github.com/viktorashi/bingobaker.com-autoplayer && cd bingobak
python autobingo.py -h
```
```string
usage: autobingo [-h] [-d {chrome,edge,firefox,safari,ie,default}] [-u URL] [-cnt COUNT] [-i INPUT_PATH] [-o OUTPUT_PATH] [-c CARDS_PATH] [-t TIMEOUT]
[-gm {normal,blackout,peen,3in6,loser}] [-s SIZE] [-r] [-hdls] [-strt START] [-fs FREE_SPACE] [-fsm FREE_SPACE_IN_MIDDLE]
[{editconfig,generate,checkbingos,mark,clear,markmid}]
usage: autobingo [-h] [-d {chrome,edge,firefox,safari,ie,default}] [-u URL] [-cnt COUNT]
[-i INPUT_PATH] [-o OUTPUT_PATH] [-c CARDS_PATH]
[-gm {normal,blackout,peen,3in6,loser}] [-s SIZE] [-r] [-hdls] [-strt START]
[-fs FREE_SPACE] [-fsm FREE_SPACE_IN_MIDDLE]
[{editconfig,generate,check}]
Auto Bingo playing command line tool. Currently only being used for bingobaker.com
positional arguments:
{editconfig,generate,checkbingos,mark,clear,markmid}
{editconfig,generate,check}
The mode to run the program in. [default: editconfig]
options:
Expand All @@ -44,26 +46,30 @@ options:
-cnt COUNT, --count COUNT
Number of bingo cards to generate from the generator link
-i INPUT_PATH, --input INPUT_PATH
The file containing the keywords to search for on the bingo cards [default: input.txt]
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.txt]
File to write the bingo'ed cards to [default: output.json]
-c CARDS_PATH, --cards CARDS_PATH
The path you want the cards to be saved in
-t TIMEOUT, --timeout TIMEOUT
Timeout in seconds for the webdriver to wait before clicking on each element to prevent malfunction [default : 0.2 ]
-gm {normal,blackout,peen,3in6,loser}, --gamemode {normal,blackout,peen,3in6,loser}
The gamemode to play in. [default: normal]
-s SIZE, --size SIZE The size of the bingo card [default: 5 ]
-r, --reverse Reverse the bingo card order when reading from [cards.txt] [default False]
-hdls, --headless Run the webdriver in headless mode (no interface for less VRAM consumption i think idk lol) [only possible for chrome, edge, firefox] [default False]
-r, --reverse Reverse the bingo card order when reading from [cards.txt] [default
False]
-hdls, --headless Run the webdriver in headless mode (no interface for less VRAM
consumption i think idk lol) [only possible for chrome, edge, firefox]
[default False]
-strt START, --start START
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']
-fsm FREE_SPACE_IN_MIDDLE, --free-space-middle FREE_SPACE_IN_MIDDLE
Whether to search for the freespace in the middle of the card [default: 1]
Whether to search for the freespace in the middle of the card
[default: 1]
ion care how u use my code lol
```
for the operation and options

Expand All @@ -72,10 +78,7 @@ for the operation and options
### <font size=5> Positional arguments</font> reffer to the first thing you type after ```python autobingo.py```, meaning the function you want to execute, generating, checking the bingos, marking the spots (which includes checking the bingo's if any spots containing the keywords have been found), and clearing the cards in case jack got a bigo already :'(

- generate : generates {--count} bingo cards from the specified {--url}, writes their links to {--cards [default cards.txt]} (middle free space is always checked)
- mark : starts checking each card from {--cards} to see if they contain any keywords from {--input}, if they do, they check for a bingo, which, if found will output the link of those cards tp {--output}
- clear : clears the cards in {--cards}
- checkbingos :checks bingos for each card, will be less used since it automatically checks the bingo eitherway for each card as it searches
- markmid : mark all the middle free space spots for some reason i barely remember why i made this
- 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> --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
Expand All @@ -85,8 +88,8 @@ freebooting a freebooted
fake laugh
bro
```
### <font size=5> --output <sub>[default: output.txt, shorthand -o]</sub></font> : file that outputs the bingos
#### **`output.txt`**
### <font size=5> --output <sub>[default: output.json, shorthand -o]</sub></font> : file that outputs the bingos
#### **`output.json`**
```
https://bingobaker.com/#64e7dce5f63bda5a
https://bingobaker.com/#64e7dce69d2d0c80
Expand Down Expand Up @@ -152,7 +155,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. <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 to see if the size provided is accurate 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>
idk how well i've tested this but i believe it starts messing up if you do. But delete it all-togather if you have and it doesn't work anymore, it will just generate another one.


Expand All @@ -174,9 +177,9 @@ should do the job, then you would create an **input.txt** right next to this and

##### **`zsh`**
```bash
python autobingo.py mark
python autobingo.py check
```
ez, peek into the console once in a while and see if it outputed anything about a congratilations, then go to output.txt to check it.
ez, peek into the console once in a while and see if it outputed anything about a congratilations, then go to output.json to check it.
#### This opens up Microsoft Edge browser and and generates 75 bingo cards with the generator link you have provided to it, the bingo's of which will be saved to the ***wins.txt*** file, also increases the timeout.

##### **`zsh`**
Expand Down
96 changes: 39 additions & 57 deletions autobingo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
e pe moduri:
- editconfig [defaultu daca nu e specificat]
- generate
- checkbingos
- check
- help
- mark
- clear
Expand All @@ -22,7 +22,7 @@
parser.add_argument(
"mode",
help="The mode to run the program in. [default: editconfig]",
choices=["editconfig", "generate", "checkbingos", "mark", "clear", "markmid"],
choices=["editconfig", "generate", "check"],
nargs="?",
)

Expand Down Expand Up @@ -69,19 +69,13 @@
dest="cards_path",
type=str,
)
parser.add_argument(
"-t",
"--timeout",
help="Timeout in seconds for the webdriver to wait before clicking on each element to prevent malfunction [default : 0.2 ]",
type=float,
)
parser.add_argument(
"-gm",
"--gamemode",
help="The gamemode to play in. [default: normal] ",
type=str,
choices=["normal", "blackout", "peen", "3in6", "loser"],
dest="type",
dest="gamemode",
)
parser.add_argument(
"-s",
Expand Down Expand Up @@ -159,21 +153,11 @@
options["count"] = 10
case _:
pass
# if arg in bingoconfig.json: set it in options
# else: check if:
# arg == "mode": set it to "editconfig"
# arg == "driver": set it to "chrome"
# arg == "count" : set it to 10
# else pass
else:
# because this is a default that we don't want to set in bingoconfig.json as it depends on the user's call of the program
if not arg == "mode":
options[arg] = args[arg]

if "gamemode" in options:
if options["gamemode"] == "3in6":
options["size"] = 6

update_config(options)

if args["mode"] == "editconfig":
Expand All @@ -188,36 +172,6 @@
print(f"{option} : {options[option]}")


match options["driver"]:
case "chrome":
if options["headless"]:
opts = webdriver.ChromeOptions()
opts.add_argument("--headless=new")
options["driver"] = webdriver.Chrome(options=opts)
else:
options["driver"] = webdriver.Chrome()
case "edge":
if options["headless"]:
opts = webdriver.EdgeOptions()
opts.add_argument("--headless=new")
options["driver"] = webdriver.Edge(options=opts)
else:
options["driver"] = webdriver.Edge()
case "firefox":
if options["headless"]:
opts = webdriver.FirefoxOptions()
opts.add_argument("--headless=new")
options["driver"] = webdriver.Firefox(options=opts)
else:
options["driver"] = webdriver.Firefox()
case "safari":
options["driver"] = webdriver.Safari()
case "ie":
options["driver"] = webdriver.Ie()
case _:
options["driver"] = webdriver.Chrome()
from main import autobingo

not_for_class = ["count", "headless"]
# preparing it for the autobingo class
input_options = {}
Expand All @@ -227,17 +181,45 @@
if not (option in not_for_class):
input_options[option] = options[option]

bingo = autobingo(**input_options)
from main import autobingo


match args["mode"]:
case "generate":
match options["driver"]:
case "chrome":
if options["headless"]:
opts = webdriver.ChromeOptions()
opts.add_argument("--headless=new")
input_options["driver"] = webdriver.Chrome(options=opts)
else:
input_options["driver"] = webdriver.Chrome()
case "edge":
if options["headless"]:
opts = webdriver.EdgeOptions()
opts.add_argument("--headless=new")
input_options["driver"] = webdriver.Edge(options=opts)
else:
input_options["driver"] = webdriver.Edge()
case "firefox":
if options["headless"]:
opts = webdriver.FirefoxOptions()
opts.add_argument("--headless=new")
input_options["driver"] = webdriver.Firefox(options=opts)
else:
input_options["driver"] = webdriver.Firefox()
case "safari":
input_options["driver"] = webdriver.Safari()
case "ie":
input_options["driver"] = webdriver.Ie()
case _:
input_options["driver"] = webdriver.Chrome()

# kinda like object destructuring in js
bingo = autobingo(**input_options)
bingo.createCards(options["count"])
print("Cards generated! Check the cards.txt file for the links")
case "checkbingos":

case "check":
bingo = autobingo(**input_options)
bingo.check_bingo_of_all_cards()
case "mark":
bingo.mark_spots()
case "clear":
bingo.clear_all_cards()
case "markmid":
bingo.mark_all_middle_spots()
File renamed without changes.
Loading

0 comments on commit 454033f

Please sign in to comment.