Compare commits
1 commit
master
...
update-twi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
268915e7cc |
2 changed files with 14 additions and 8 deletions
plugins/twilio
|
@ -1,7 +1,8 @@
|
|||
|
||||
import logging
|
||||
import os
|
||||
from twilio.rest import TwilioRestClient
|
||||
from twilio.rest import Client
|
||||
from twilio.base.exceptions import TwilioRestException
|
||||
|
||||
try:
|
||||
from alerta.plugins import app # alerta >= 5.0
|
||||
|
@ -33,10 +34,15 @@ class SendSMSMessage(PluginBase):
|
|||
','.join(alert.service), alert.resource, alert.event
|
||||
)
|
||||
|
||||
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
message = client.messages.create(body=message, to=TWILIO_TO_NUMBER, from_=TWILIO_FROM_NUMBER)
|
||||
client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
for twilio_to in TWILIO_TO_NUMBER.split(','):
|
||||
LOG.debug('Twilio SMS: Send message from {}, to {}'.format(TWILIO_FROM_NUMBER, twilio_to))
|
||||
try:
|
||||
message = client.messages.create(body=message, to=twilio_to, from_=TWILIO_FROM_NUMBER)
|
||||
except TwilioRestException as e:
|
||||
LOG.error('Twilio SMS: ERROR - {}'.format(str(e)))
|
||||
else:
|
||||
LOG.info("Twilio SMS: Message ID: %s", message.sid)
|
||||
|
||||
LOG.info("Twilio SMS Message ID: %s", message.sid)
|
||||
|
||||
def status_change(self, alert, status):
|
||||
def status_change(self, alert, status, text):
|
||||
return
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
version = '5.3.1'
|
||||
version = '5.4.0'
|
||||
|
||||
setup(
|
||||
name="alerta-twilio",
|
||||
|
@ -14,7 +14,7 @@ setup(
|
|||
packages=find_packages(),
|
||||
py_modules=['alerta_twilio_sms'],
|
||||
install_requires=[
|
||||
'twilio'
|
||||
'twilio>=6.0.0'
|
||||
],
|
||||
include_package_data=True,
|
||||
zip_safe=True,
|
||||
|
|
Loading…
Add table
Reference in a new issue