Skip to content
Snippets Groups Projects
Commit 1adfb83c authored by dnns01's avatar dnns01
Browse files

Added Einkaufsliste

parent e00e33d9
No related branches found
No related tags found
No related merge requests found
import json
from twitchio.ext import commands
class Einkaufsliste(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.items = []
self.load()
def load(self):
try:
file = open("einkaufsliste.json", mode="r")
self.items = json.load(file)
except:
self.items = []
self.save()
def save(self):
file = open("einkaufsliste.json", mode="w")
json.dump(self.items, file)
@commands.command(name="einkaufsliste")
async def cmd_giveaway(self, ctx, add=None, *item):
""" take part at the giveaway """
if add == "add":
item = " ".join(item)
self.items.append(item)
else:
if len(self.items) > 0:
msg = "Auf Marcus Einkaufsliste stehen folgende Dinge: "
for item in self.items:
if len(msg) + len(item) >= 500:
await ctx.send(msg[:-2])
msg = ""
msg += item + ", "
await ctx.send(msg[:-2])
else:
await ctx.send(f"Auf Marcus Einkaufsliste steht noch nix!")
......@@ -9,7 +9,7 @@ from twitchio import Channel, Message
from twitchio.ext import commands
from twitchio.ext.commands import Context
import chat_commands, giveaway, klassenbuch, link_protection, spotify_cog, vote_cog, countdown
import chat_commands, giveaway, klassenbuch, link_protection, spotify_cog, vote_cog, countdown, einkaufsliste
load_dotenv()
......@@ -35,6 +35,7 @@ class StrolchiBot(commands.Bot, ABC):
self.add_cog(giveaway.Giveaway(self))
self.add_cog(chat_commands.Commands(self))
self.add_cog(countdown.Countdown(self))
self.add_cog(einkaufsliste.Einkaufsliste(self))
@staticmethod
async def send_me(ctx, content):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment