Exemplo n.º 1
0
def delete_reminder(uid):
    ns=notification.get_scheduled()
    for n in ns:
        args=n['action_url'].split('&argv=')
        if args[0].startswith('pythonista://reminder?'):
            if args[1]==uid:
                notification.cancel(n)
Exemplo n.º 2
0
def main():
    # Nacteme notifikace
    notes = notification.get_scheduled()

    # Pokud zadne nejsou, zobrazime alert
    if not notes:
        console.hud_alert('Žádné připomínky k zobrazení')
        return

    # Setridime notifikace podle data
    notes = sorted(notes, key=lambda x: x['fire_date'])

    # Prevedeme do vlastniho slovniku, neboli celou notifikaci ulozime
    # do klice note a pridame vlastni titulek (klic title) skladajici se z data & casu
    # a textu notifikace. Hodnotu klice title pouziva dialogs.edit_list_dialog.

    def title(note):
        dt = datetime.datetime.fromtimestamp(note['fire_date'])
        return f"{dt:%Y-%m-%d %H:%M} {note['message']}"

    reminders = [
        {
            'title': title(note),
            'note': note
        }
        for note in notes
    ]

    final = dialogs.edit_list_dialog('Připomínky', reminders, move=False, delete=True)
    if final is None:
        return

    cancel_removed_reminders_workaround(reminders, final)
Exemplo n.º 3
0
def schedule_notfications():
    nots = notification.get_scheduled()
    #print(nots)
    dayrange = list(range(7))

    #print('dayrange before: {}'.format(dayrange))
    today = datetime.datetime.now()
    '''
	for n in nots:
		d1 = datetime.datetime.fromtimestamp( n['fire_date'] )
		diff = d1 - today
		#print('diff: {}'.format(diff.days ))
		if diff.days in dayrange:
			dayrange.remove(diff.days)
	print('dayrange after: {}'.format(dayrange))
	'''

    notification.cancel_all()

    for i in dayrange:
        day = today + datetime.timedelta(days=i)
        h = 21
        m = 30

        desired_time = day.replace(hour=h, minute=m, second=0, microsecond=0)
        #print(desired_time)

        if desired_time > today:
            delta = desired_time - today
            delay_seconds = delta.total_seconds()

            notification.schedule(
                'Complete Triggers', delay_seconds, 'default',
                'pythonista3://triggers/enter-triggers.py?action=run&root=iCloud'
            )
Exemplo n.º 4
0
def get_uids():
    '''returns dict of uids containing the soonest notification.  get_uids().keys() returns valid keys'''
    ns=notification.get_scheduled()
    uids=dict()
    for n in reversed(ns):
        args=n['action_url'].split('&argv=')
        if args[0].startswith('pythonista://reminder?'):
            uids[args[1]]=n
    return uids
Exemplo n.º 5
0
def next_reminder(uid):
    ns=notification.get_scheduled()
    t=0
    for n in ns:
        args=n['action_url'].split('&argv=')
        if args[0].startswith('pythonista://reminder?'):
            if args[1]==uid:
                t=n['fire_date']
                return t
    return float('inf')
Exemplo n.º 6
0
 def init_and_schedule(cls, message, delay=None, sound_name=None, action_url=None):
     notification.schedule(message=message, delay=delay, sound_name=sound_name, action_url=action_url)
     return cls(notification.get_scheduled()[-1])
Exemplo n.º 7
0
 def get_scheduled():
     result = []
     for scheduled_notification in notification.get_scheduled():
         result.append(PlannedNoti(scheduled_notification))
     return result
Exemplo n.º 8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# CancelReminders Version 1.0

## Cancels all currently scheduled notifications in Pythonista.

import notification
import console
import webbrowser

scheduled = notification.get_scheduled()
url = 'launch://'

if scheduled == []:
	console.hud_alert('None.', 'error')
else:
	console.alert('Cancel all reminders?', 'Are you sure?', 'Yes')
	notification.cancel_all()
	console.hud_alert('Canceled.', 'success')
	
webbrowser.open(url)
Exemplo n.º 9
0
def printNots():
    notsList = notification.get_scheduled()
    for i in range(len(notsList)):
        print(notsList[i])
        print()
Exemplo n.º 10
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# CancelReminders Version 1.0

## Cancels all currently scheduled notifications in Pythonista.

import notification
import console
import webbrowser

scheduled = notification.get_scheduled()
url = 'launch://'

if scheduled == []:
    console.hud_alert('None.', 'error')
else:
    console.alert('Cancel all reminders?', 'Are you sure?', 'Yes')
    notification.cancel_all()
    console.hud_alert('Canceled.', 'success')

webbrowser.open(url)