예제 #1
0
def sendmessage(text, receiver):

    client = Courier(auth_token="pk_prod_REDACTED")

    resp = client.send(event="courier-quickstart",
                       recipient=receiver,
                       data={"message": text})

    print(resp['messageId'])
예제 #2
0
def send_sms(phone_number, message):
    client = Courier(auth_token="pk_prod_3NF6S5AZ4S4TSRPEM6AJVNRVCFJT")
    resp = client.send(
        event="3T9NBKMKHV4WTVPHZRPKF1Y5NVQ5",
        recipient="3T9NBKMKHV4WTVPHZRPKF1Y5NVQ5",
        profile={
            "email": "*****@*****.**",
            "phone_number": phone_number
        },
        data={
            "unique_text": message,
        },
    )
    print(resp['messageId'])
예제 #3
0
 def notify(self):
     # Local notfication
     rumps.notification(
         title=self.config["app_name"],
         subtitle="Zoom Camera Alert",
         message="Looks like you've forgotten to turn of your camera while on Zoom. We've hidden it for you!",
     )
     # Courier notification, sends to phone number
     client = Courier(auth_token=courier_auth)
     resp = client.send(
         event=courier_event,
         recipient="me",
         profile={"phone_number": my_phone_number},
         data={},
     )
예제 #4
0
def send(event, data):
    """Send an emails with the sent event id, email settings and data.
    :param str event: courier notification id
    :param dict data: Required data for the courier template
    :return: response of the courier request if possible, None otherwise
    :rtype: Optional(Response)
    """
    client = Courier(auth_token=COURIER_AUTH_TOKEN)
    try:
        return client.send(
            event=event,
            recipient=str(uuid.uuid4()),
            profile={"email": COURIER_DOMAIN_EMAIL},
            data=data,
        )
    except CourierAPIException:
        return None
예제 #5
0
    def postScore(self, Name, Score, Phone):
        conn = psycopg2.connect(
            database='pure-lamb-1277.Scoreboard',
            user='******',
            password='******',
            port=26257,
            host='free-tier.gcp-us-central1.cockroachlabs.cloud')

        phoneNum = 0
        name = ""

        # Add the new score to the leaderboard and return the current place.
        with conn.cursor() as cur:
            cur.execute(
                "INSERT INTO Scoreboard.Scores (Name, Score, Phone) VALUES ('"
                + Name + "', " + Score + ", " + Phone + ") RETURNING *;")
            conn.commit()
            rowID = cur.fetchone()[3]

            cur.execute("SELECT * FROM Scoreboard.Scores ORDER BY Score DESC;")
            rows = cur.fetchall()
            currRow = 0
            currPlace = 0
            for row in rows:
                currRow += 1
                if (row[3] == rowID):
                    currPlace = currRow
                    break

            if currRow < 11 and len(rows) > 10:
                phoneNum = rows[10][2]
                name = rows[10][0]

        conn.close()

        client = Courier(auth_token="dk_prod_2VGMFMHMF7459HQ4HN4GXW3SC3WD")
        resp = client.send(event="YP143Y45M4MXFGP648AVD0TMPTQ1",
                           recipient="204a8da9-603e-4916-b567-970f54c40204",
                           profile={"phone_number": phoneNum},
                           data={
                               "name": name,
                               "source_url": "https://knightrider.tech"
                           })

        return {"Place": currPlace, "Response": resp['messageId']}
예제 #6
0
class Notifier:
    def __init__(self):
        self.client = Courier(auth_token=COURIER_API_TOKEN)

    def notify(self,
               comms_name,
               recipient_id,
               data,
               profile=None,
               idempotency_key=None):
        """Send communications via courier"""
        event_id = COMMS_TO_EVENT_MAP[comms_name]
        resp = self.client.send(
            event=event_id,
            recipient=recipient_id,
            data=data,
            profile=profile,
            idempotency_key=idempotency_key,
        )
        return resp

    def notify_organizer(self, message):
        """Send communications via courier"""
        event_id = COMMS_TO_EVENT_MAP["generic_organizer_notification"]
        resp = self.client.send(
            event=event_id,
            recipient="organizer",
            data={"message": message},
            profile=config.ADMIN_NOTIFICATION_PROFILE,
            idempotency_key=None,
        )
        return resp

    def replace_or_create_profile(self, recipient_id, profile):
        """Create or replace profile"""
        resp = self.client.replace_profile(recipient_id, profile)
        return resp

    def update_or_create_profile(self, recipient_id, profile):
        """Create or update profile"""
        resp = self.client.merge_profile(recipient_id, profile)
        return resp
예제 #7
0
from trycourier import Courier

client = Courier(auth_token="pk_prod_REDACTED")

resp = client.send(event="courier-quickstart",
                   recipient="REDACTED",
                   data={"favoriteAdjective": "awesomeness"})

print(resp['messageId'])
예제 #8
0
 def __init__(self):
     self.client = Courier(auth_token=COURIER_API_TOKEN)