Skip to content

Commit

Permalink
removed reminder repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Mole1424 committed Jun 22, 2024
1 parent 3c68528 commit 0856a22
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 59 deletions.
58 changes: 1 addition & 57 deletions cogs/commands/reminders.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import asyncio
import logging
from datetime import datetime, timedelta
from datetime import datetime

import discord
from discord import AllowedMentions
from discord.ext import commands
from discord.ext.commands import Bot, Context
from humanize import precisedelta
from pytimeparse.timeparse import timeparse
from pytz import timezone
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy_utils import ScalarListException
Expand Down Expand Up @@ -88,61 +87,6 @@ async def add(self, ctx: Context, when: str, *, reminder_content: str):
result = self.add_base(new_reminder)
await ctx.send(**result)

@reminder.command(help="Add a repeating reminder.")
async def repeat(
self,
ctx: Context,
start: str,
repeat: str,
until: str,
*,
reminder_content: str,
):
repeat_time = timeparse(repeat)
if repeat_time is None:
return ctx.reply(
"I just flat out did not understand what you meant with that repeat time"
)
repeat_time = timedelta(seconds=repeat_time)
until_time = parse_time(until)
start_time = (
datetime.now(timezone("Europe/London"))
if start is None
else parse_time(start)
)
if start_time is None or until_time is None:
return ctx.reply(
"I just flat out did not understand what you meant with that start time"
)
if until_time < start_time:
return ctx.reply("The until time is before the start time")

display_name = get_name_string(ctx.message)
if user_is_irc_bot(ctx):
author_id, irc_n = 1, display_name
else:
author_id, irc_n = get_database_user(ctx.author).id, None

num_reminders = 0
first_reminder = None
while start_time <= until_time:
new_reminder = Reminder(
user_id=author_id,
reminder_content=reminder_content,
trigger_at=start_time,
triggered=False,
playback_channel_id=ctx.message.channel.id,
irc_name=irc_n,
)
_ = self.add_base(new_reminder)
num_reminders += 1
if not first_reminder:
first_reminder = int(new_reminder.trigger_at.timestamp())
start_time += repeat_time
await ctx.reply(
f"Added {num_reminders} reminders, first one at <t:{first_reminder}:R>, last one at <t:{int(new_reminder.trigger_at.timestamp())}:R>"
)

def add_base(self, reminder):
now = datetime.now(timezone("Europe/London"))
if not reminder.trigger_at:
Expand Down
3 changes: 1 addition & 2 deletions voting/splitutils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import _csv
import re
from csv import QUOTE_ALL, Sniffer, reader
from typing import List

import _csv


# Customized sniffer with custom delimiter order
class ArgSniffer(Sniffer):
Expand Down

0 comments on commit 0856a22

Please sign in to comment.