Skip to content

Commit

Permalink
extra checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rayer456 committed Apr 23, 2023
1 parent e4fd9eb commit 1a62942
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ config/config.toml
tokens/
logs/
test.py
test2.py
test2.py
predictions/
5 changes: 4 additions & 1 deletion electrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ def read_data():
elif msg[1] == "PRIVMSG": #TODO commands, modcommands, song, pb, wr
chat_interact(buffer.splitlines(), mods)
except ssl.SSLWantReadError: #timeout
continue
continue
except KeyboardInterrupt:
LOG.logger.info("Closing bot...")
break
except Exception:
LOG.logger.error("Exception in read_data", exc_info=True)

Expand Down
2 changes: 1 addition & 1 deletion predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_self_starting_predictions():

auto_predictions = [] #auto start based on current split
for p in data['predictions']:
if p['auto_predict']['auto_start'] == True:
if p['auto_predict']['auto_start']:
auto_pred = {
"name": p['name'],
"split_name": p['auto_predict']['split_name']
Expand Down
15 changes: 6 additions & 9 deletions predictions/predictions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@
"predictions": [
{
"auto_predict": {
"auto_start": false,
"split_name": ""
"auto_start": true,
"split_name": "repo"
},
"data": {
"broadcaster_id": "",
"outcomes": [
{
"title": "Yes"
"title": "yes"
},
{
"title": "No"
},
{
"title": "Maybe"
"title": "no"
}
],
"prediction_window": 600,
"title": "Is this an example?"
"title": "is something?"
},
"name": "example"
"name": "repo"
}
]
}
32 changes: 22 additions & 10 deletions predictions_manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import tkinter as tk
import json
import os


if not os.path.exists('predictions'):
os.makedirs('predictions')

with open('predictions/predictions.json', 'r') as file:
dict = json.load(file)
while 1:
try:
with open('predictions/predictions.json', 'r') as file:
dict = json.load(file)
break
except FileNotFoundError:
default_content = {
"predictions": []
}
with open('predictions/predictions.json', 'w') as file:
file.write(json.dumps(default_content))


def handle_select_pred(event):
Expand Down Expand Up @@ -87,14 +99,6 @@ def handle_save():
lbl_error.config(text="Saved changes", fg="green")


def refresh_list():
#erase, write
lb_list.delete(0, tk.END)

for i, pred in enumerate(dict['predictions']):
lb_list.insert(i, pred['name'])


def handle_delete():
delete_name = ent_name.get()

Expand All @@ -109,6 +113,14 @@ def handle_delete():
refresh_list()


def refresh_list():
#erase, write
lb_list.delete(0, tk.END)

for i, pred in enumerate(dict['predictions']):
lb_list.insert(i, pred['name'])


def validate_form():
try:
lbl_error.config(text="", fg="red")
Expand Down

0 comments on commit 1a62942

Please sign in to comment.