3939
4040
4141@asyncio .coroutine
42- def delete_reminder (async , db , network , remind_time , added_user ):
42+ def delete_reminder (async , db , network , remind_time , user ):
4343 query = table .delete () \
44- .where (table .c .network == network ) \
44+ .where (table .c .network == network . lower () ) \
4545 .where (table .c .remind_time == remind_time ) \
46- .where (table .c .added_user == added_user )
46+ .where (table .c .added_user == user .lower ())
47+ yield from async (db .execute , query )
48+ yield from async (db .commit )
49+
50+
51+ @asyncio .coroutine
52+ def delete_all (async , db , network , user ):
53+ query = table .delete () \
54+ .where (table .c .network == network .lower ()) \
55+ .where (table .c .added_user == user .lower ())
4756 yield from async (db .execute , query )
4857 yield from async (db .commit )
4958
5059
5160@asyncio .coroutine
5261def add_reminder (async , db , network , added_user , added_chan , message , remind_time , added_time ):
5362 query = table .insert ().values (
54- network = network ,
63+ network = network . lower () ,
5564 added_user = added_user .lower (),
5665 added_time = added_time ,
57- added_chan = added_chan ,
66+ added_chan = added_chan . lower () ,
5867 message = message ,
5968 remind_time = remind_time
6069 )
@@ -78,7 +87,7 @@ def _load_cache_db(db):
7887
7988
8089@asyncio .coroutine
81- @hook .periodic (2.5 , initial_interval = 30 )
90+ @hook .periodic (30 , initial_interval = 30 )
8291def check_reminders (bot , async , db ):
8392 current_time = datetime .now ()
8493
@@ -114,9 +123,19 @@ def check_reminders(bot, async, db):
114123
115124
116125@asyncio .coroutine
117- @hook .command ('remind' )
126+ @hook .command ('remind' , 'reminder' )
118127def remind (text , nick , chan , db , conn , notice , async ):
119- """remind <1 minute, 30 seconds>: <do task> -- reminds you to <do task> in <1 minute, 30 seconds>"""
128+ """<1 minute, 30 seconds>: <do task> -- reminds you to <do task> in <1 minute, 30 seconds>"""
129+
130+ count = len ([x for x in reminder_cache if x [0 ] == conn .name and x [3 ] == nick .lower ()])
131+
132+ if text == "clear" :
133+ if count == 0 :
134+ return "You have no reminders to delete."
135+
136+ yield from delete_all (async , db , conn .name , nick )
137+ yield from load_cache (async , db )
138+ return "Deleted all ({}) reminders for {}!" .format (count , nick )
120139
121140 # split the input on the first ":"
122141 parts = text .split (":" , 1 )
@@ -126,9 +145,9 @@ def remind(text, nick, chan, db, conn, notice, async):
126145 notice (remind .__doc__ )
127146 return
128147
129- count = len ([x for x in reminder_cache if x [0 ] == conn .name and x [3 ] == nick .lower ()])
130148 if count > 10 :
131- return "Sorry, you already have too many reminders queued, you will need to wait or clear your reminders to add any more."
149+ return "Sorry, you already have too many reminders queued (10), you will need to wait or " \
150+ "clear your reminders to add any more."
132151
133152 time_string = parts [0 ].strip ()
134153 message = colors .strip_all (parts [1 ].strip ())
0 commit comments