From 8fc71c17f56c128d66b6271da7430d18568ba167 Mon Sep 17 00:00:00 2001 From: ProbablyButter Date: Mon, 18 Sep 2023 09:58:38 -0700 Subject: [PATCH 1/3] Properly rigged HammerBot's favorite Gizmo pic --- gizmopics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gizmopics.py b/gizmopics.py index d5fd2ba..31a7599 100644 --- a/gizmopics.py +++ b/gizmopics.py @@ -5,7 +5,7 @@ "https://cdn.discordapp.com/attachments/1105932220838989834/1105937238124154911/IMG_2434.jpg", "https://cdn.discordapp.com/attachments/1105932220838989834/1105932514851307530/IMG_2420.jpeg", "https://cdn.discordapp.com/attachments/1105932220838989834/1105932515291701278/IMG_2413.jpeg", - "https://cdn.discordapp.com/attachments/1105932220838989834/1105938814515548220/IMG_1758.jpg", + "https://cdn.discordapp.com/attachments/1105932220838989834/1105939040756301864/IMG_1758.jpg", "https://cdn.discordapp.com/attachments/1105932220838989834/1105939038642372608/70537439627__C6FD10EC-06A5-47DD-83DC-1573F2EECA1E.jpg", "https://cdn.discordapp.com/attachments/1105932220838989834/1105939040756301864/IMG_1758.jpg", "https://cdn.discordapp.com/attachments/1105932220838989834/1105939045466521600/IMG_1748.jpg", From 6406b178801f4476b57232ad1fd54f5cfabf2ccc Mon Sep 17 00:00:00 2001 From: ProbablyButter Date: Sat, 23 Sep 2023 15:26:34 -0700 Subject: [PATCH 2/3] Fixed which Gizmo picture is HammerBot's favorite Added a counter since new Tao pictures --- cog_modules/random/cog.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cog_modules/random/cog.py b/cog_modules/random/cog.py index 4d7ef0b..1e13cb9 100644 --- a/cog_modules/random/cog.py +++ b/cog_modules/random/cog.py @@ -2,6 +2,7 @@ import os import pickle import random +import datetime import discord import requests @@ -45,8 +46,8 @@ async def gizmo(self, ctx: commands.Context): 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]: + most_common = gizmoResources.most_common(2) + if most_common[0][1] != most_common[1][1] and pic == most_common[0][0]: info += f" HammerBot's favorite Gizmo pic! Shown {most_common[0][1]} times." elif gizmoResources[pic] == 1: info += " First! ^_^" @@ -65,10 +66,12 @@ async def gizmo_error(self, ctx, error): @commands.command(name="!tao", aliases=["!taø"]) @commands.cooldown(1, 30, commands.BucketType.user) async def tao(self, ctx: commands.Context): - # num = random.randint(0, len(gizmoPics) - 1) - # info = f"Gizmo #{num + 1} of {len(gizmoPics)}" + last_update = datetime.datetime.fromisoformat('2023-08-25T12:58:32-04:00') + time_delta = datetime.datetime.now(datetime.timezone.utc) - last_update + + info = f" {str(time_delta)} since a new Tao sighting" pic = taoPics[0] - # await ctx.send(info) + await ctx.send(info) await ctx.send(pic) @tao.error From 388e7f18f5dbfc49863d7ddaf0e23144bfb2ebd7 Mon Sep 17 00:00:00 2001 From: ProbablyButter Date: Tue, 26 Sep 2023 09:23:00 -0700 Subject: [PATCH 3/3] Pickle server resources --- cog_modules/taunts/cog.py | 4 ++++ resources.py | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cog_modules/taunts/cog.py b/cog_modules/taunts/cog.py index 2c6d1fb..c5bff9a 100644 --- a/cog_modules/taunts/cog.py +++ b/cog_modules/taunts/cog.py @@ -124,6 +124,8 @@ async def stockpile(self, ctx: commands.Context): ) else: serverResources[user] = {"Food": "0", "Wood": "0", "Gold": "0", "Stone": "0"} + with open("serverResources", "wb") as f: + pickle.dump(serverResources, f) embed = discord.Embed( title=f"{ctx.message.author.display_name}'s Resource Stockpile", description=f"The amount of resources HammerBot has gifted you.", @@ -160,6 +162,8 @@ async def no_38(self, ctx: commands.Context): else: serverResources[user] = {"Food": "0", "Wood": "0", "Gold": "0", "Stone": "0"} serverResources[user][res] = str(num) + with open("serverResources", "wb") as f: + pickle.dump(serverResources, f) await ctx.send(response) @no_38.error diff --git a/resources.py b/resources.py index 3e9f12b..744a933 100644 --- a/resources.py +++ b/resources.py @@ -1,13 +1,18 @@ import pickle from collections import Counter -serverResources = { - "quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "12"}, - "bshammer": {"Food": "-1250", "Wood": "-1173", "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"}, -} +try: + with open("serverResources", "rb") as f: + serverResources = pickle.load(f) +except FileNotFoundError: + serverResources = { + "quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "12"}, + "bshammer": {"Food": "-1250", "Wood": "-1173", "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"}, + } + try: with open("gizmoResources", "rb") as f: gizmoResources = pickle.load(f)