These two python scripts will accept a mail message at STDIN and call or text via the Twillio service.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

41 lignes
899B

  1. #!/usr/bin/python3
  2. from twilio.rest import Client
  3. import sys
  4. import email
  5. import re
  6. import unidecode
  7. def slugify(text):
  8. text = unidecode.unidecode(text).lower()
  9. return re.sub(r'\W+', '-', text)
  10. # Find these values at https://twilio.com/user/account
  11. account_sid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  12. auth_token = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
  13. client = Client(account_sid, auth_token)
  14. raw_msg = ""
  15. for line in sys.stdin:
  16. raw_msg = raw_msg + line
  17. msg = email.message_from_string(raw_msg)
  18. text = msg['Subject']
  19. if msg.is_multipart():
  20. for payload in msg.get_payload():
  21. text = text + payload.get_payload()
  22. else:
  23. text = text + msg.get_payload()
  24. text = text[:160] if len(text) > 160 else text
  25. text = slugify(text)
  26. call = client.calls.create(
  27. to = "+357XXXXXX",
  28. from_ = "+177XXXXXXXX",
  29. url="http://twimlets.com/message?Message%5B0%5D=" + text + "&",
  30. )