def sender(messenger, message, receivers_carriers):
    # SMS get Spam filtered for any mention of IKEA, Notification or Store
    sms = Message(subject="Update Text/Test", email=email, password=password) if email and password else None

    for receiver, carrier in receivers_carriers:
        if carrier in {'gmail'} and messenger:
            messenger.send(to_recv=receiver, carrier=carrier, message=message)
        elif sms:
            sms.send(to_recv=receiver, carrier=carrier, message=message)
        
    # For Desktop notifications   
    if notification_flag:
        message = message.split('\n')
        for msg in message:
            notification.notify(title='IKEA Stores Notification!', message=msg, app_icon='./bell.ico', timeout=30)
示例#2
0
def sender(messenger, message, receivers_carriers):
    # SMSs get Spam filtered for any mention of IKEA, Notification or Store with tmobile carries for some reason.
    sms = Message(subject="Update Text/Test", email=email, password=password)

    for receiver, carrier in receivers_carriers:
        if carrier in {'gmail'}:
            messenger.send(to_recv=receiver, carrier=carrier, message=message)
            continue
        sms.send(to_recv=receiver, carrier=carrier, message=message)

    # For Desktop notifications
    if notification_flag:
        notification.notify(title='IKEA Stores Notification!',
                            message=message,
                            app_icon='./bell.ico',
                            timeout=30)
from msg import Message
from collections import defaultdict
import requests
import time

# DO NOT COMMIT FILES WITH CREDENTIALS
email = 'EMAIL'
password = '******'
numbers_carriers = [('0000000000 or 000-000-0000', 'carrier')]

var = "PLZ WORK"
test = Message(subject="Update Text/Test", email=email, password=password)
msg = "Wubba Lubba Dub Dub\n"
for _ in range(5):
    msg += f'Wubba Lubba Dub Dub {var}\n'

ikea_stores = defaultdict(bool)
r = requests.get('https://ikea-status.dong.st/latest.json')
for store in r.json():
    if store['last_open'] and store['last_open'] > store['last_closed']:
        ikea_stores[(store['country'], store['state'], store['name'])] = True

msg += f'First notification from script about IKEA store availability ran at {time.strftime("%d-%b-%Y %H:%M:%S", time.localtime())} Local Time.\n'
for country, state, name in ikea_stores.keys():
    msg += f'{country}, {state}, {name} - OPEN\n'

for number, carrier in numbers_carriers:
    test.send(to_recv=number, carrier=carrier, message=msg)

print('OK')