Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickle gizmo #71

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cog_modules/random/cog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import asyncio

Check warning on line 1 in cog_modules/random/cog.py

View workflow job for this annotation

GitHub Actions / autocodestyle

Reformatting Needed

This file needs reformatting with black
import os
import random

Expand All @@ -10,6 +10,8 @@
from gizmopics import *
from resources import gizmoResources

import pickle

load_dotenv()
CATS = os.getenv("x-api-key")
botDMs = int(os.getenv("DMChannel"))
Expand Down Expand Up @@ -42,6 +44,8 @@
info = f"Gizmo #{num + 1} of {len(gizmoPics)}."
pic = gizmoPics[num]
gizmoResources[pic] += 1
with open('gizmoResources','wb') as f:
pickle.dump(gizmoResources, f)
most_common = gizmoResources.most_common(1)
if pic == most_common[0][0]:
info += f" HammerBot's favorite Gizmo pic! Shown {most_common[0][1]} times."
Expand Down
9 changes: 6 additions & 3 deletions resources.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from collections import Counter

Check warning on line 1 in resources.py

View workflow job for this annotation

GitHub Actions / autocodestyle

Reformatting Needed

This file needs reformatting with black

import pickle
serverResources = {
"quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "12"},
"bshammer": {"Food": "-1250", "Wood": "-622", "Gold": "-850", "Stone": "1942"},
"probablybutter": {"Food": "295", "Wood": "-2024", "Gold": "-1006", "Stone": "-2044"},
"olaf_the_shrew": {"Food": "323", "Wood": "0", "Gold": "0", "Stone": "0"},
".harristotle": {"Food": "-2241", "Wood": "560", "Gold": "-986", "Stone": "-706"},
}

gizmoResources = Counter()
try:
with open('gizmoResources','rb') as f:
gizmoResources = pickle.load(f)
except FileNotFoundError:
gizmoResources = Counter()
Loading