made the /bk_week_get function properly... and a bunch more that i forgor

This commit is contained in:
2025-02-09 15:53:50 +01:00
parent b816c12a6c
commit dc2342737c
14 changed files with 285 additions and 40 deletions
+9 -3
View File
@@ -66,20 +66,26 @@ def read_data(bot: botPy.Bot):
except FileNotFoundError:
py_print("reddit_data.json not found, creating new from preset...")
with open(data_path + "\\reddit_data_preset.json", "r") as f:
data_preset_json = json.load(f)
data_preset_json["bk_weekly_art_posts"].pop("EXAMPLE VALUE", None)
data_preset_json["bk_weekly_art_posts"].pop("EXAMPLE VALUE DELETED", None)
with open(data_path + "\\reddit_data.json", "w") as f:
f.write(open(data_path + "\\reddit_data_preset.json", "r").read())
json.dump(data_preset_json, f, indent = 2)
bot.data_f = open(data_path + "\\reddit_data.json", "r+")
data_str = bot.data_f.read()
bot.data = json.loads(data_str)
json_data = json.loads(data_str)
bot.data = json_data
if not bot.data["file_created_correctly"]:
raise Exception("reddit_data.json file wasn't created properly. Delete the file and retry.")
def write_data(bot: botPy.Bot):
bot.data["TEST"] = True
bot.data_f.seek(0)
json.dump(bot.data, bot.data_f, indent=2)
bot.data_f.truncate()
+2 -2
View File
@@ -4,7 +4,7 @@ def py_print(*args: str):
print(
PrintColors.FG.blue + "Py",
"-",
" ".join(args)
" ".join(args) + PrintColors.Special.reset
)
def py_error(*args: str):
@@ -12,6 +12,6 @@ def py_error(*args: str):
PrintColors.BG.red + "ERROR" + PrintColors.Special.reset,
PrintColors.FG.blue + "Py",
"-",
" ".join(args)
" ".join(args) + PrintColors.Special.reset
)
quit()
+6 -1
View File
@@ -7,6 +7,7 @@ from macros import *
import bot as botPy
import data
import py_websocket
import posts
def main():
@@ -32,4 +33,8 @@ def main():
time.sleep(1)
continue
asyncio.run(py_websocket.send_message("[Connection test] Hello from Python!"))
asyncio.run(py_websocket.send_message("[Connection test] Hello from Python!"))
if __name__ == "__main__":
main()
+2 -2
View File
@@ -4,7 +4,7 @@ import data
import bot as botPy
from macros import *
def add_new_posts(bot: botPy.Bot, debug_print: bool = False):
def add_new_posts(bot: botPy.Bot):
check_emoji = emoji.emojize(":check_mark_button:")
cross_emoji = emoji.emojize(":cross_mark:")
@@ -21,7 +21,7 @@ def add_new_posts(bot: botPy.Bot, debug_print: bool = False):
media_urls = "\n ".join(media[3])
if debug_print: print(
if bot.args["dev"]: py_print(
f"\n{post.title}",
f"\n {post.shortlink}"
f"\n {check_emoji if media[0] else cross_emoji} Media ({media[1]}) [{media[2]}]",
+1 -1
View File
@@ -58,4 +58,4 @@ def json_to_func(v: dict, bot: botPy.Bot):
case _: value_supported = False
if bot.args["dev"] and not value_supported:
print(f"Value {v['value']} is not supported")
py_print(f"Value {v['value']} is not supported")