1. johannes
  2. sms

Commits

johannes  committed f8bb6cc

Remove spaces and dashes from phone numbers

  • Participants
  • Parent commits 417e9b0
  • Branches default

Comments (0)

Files changed (1)

File sms.py

View file
 def sendsms(cookies, number, message):
 	url = 'https://www.onecall.no/minesider/send_sms.php'
 	message = codecs.encode(message, 'latin-1') # you may puke
+	number = number.replace(' ', '').replace('-', '')
+	assert(all(digit in '0123456789+' for digit in number))
 	req = requests.post(url, cookies=cookies, data={'nummer': number, 'smsmsg': message, 'submit': 'Send SMS'})
 
 	return 'Melding er sendt' in req.content