sms.py 805 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import ovh
from twilio.rest import Client

from amonit import util


def twilio_sms(context, sid, token, sender, message, dest):
    rendered = util.render(message, context)
    client = Client(sid, token)
    for phone in dest:
        client.messages.create(body=rendered, from_=sender, to=dest)


def ovh_sms(context, application_key, application_secret,
            consumer_key, service, message, dest):
    rendered = util.render(message, context)

    client = ovh.Client('ovh-eu', application_key,
                        application_secret, consumer_key)

    endpoint = '/sms/%s/jobs' % service
    client.post(endpoint,
                noStopClause=True,
                senderForResponse=True,
                priority='high',
                message=rendered,
                receivers=dest)