def test_should_send_multiple_messages(self): """Sending multiple sms messages should work""" api = clockwork.API(self.api_key) sms1 = clockwork.SMS(to="441234567890", message="This is a test message 1") sms2 = clockwork.SMS(to="441234567890", message="This is a test message 2") response = api.send([sms1,sms2]) for r in response: self.assertTrue(r.success)
def test_should_send_multiple_messages_with_erros(self): """Sending multiple sms messages, one of which has an invalid message should work""" api = clockwork.API(self.api_key) sms1 = clockwork.SMS(to="441234567890", message="This is a test message 1") sms2 = clockwork.SMS(to="441234567890", message="") response = api.send([sms1, sms2]) self.assertTrue(response[0].success) self.assertFalse(response[1].success)
def test_should_send_single_message(self): """Sending a single SMS with the minimum detail and no errors should work""" api = clockwork.API(self.api_key) sms = clockwork.SMS(to="441234567890", message="This is a test message") response = api.send(sms) self.assertTrue(response.success)
def NewNewsSMS(): conn = sqlite3.connect("UserDB.db") cur = conn.cursor() cur.execute("SELECT PhoneNum FROM Users WHERE NotifMed = ?", [1]) phn = cur.fetchall() cur.execute("SELECT Title, URL, Sent FROM News WHERE Sent = ?", [0]) nws = cur.fetchall() phnlen = len(phn) nwslen = len(nws) j = 0 l = 0 #iterate through the array of phonenumbers from the database that have opped into the service for j in range(phnlen): for l in range(nwslen): PHONENUMBER = phn[j][0] TITLE = nws[l][0] URL = nws[l][1] BODY = str(TITLE + " / " + URL) message = clockwork.SMS(to=PHONENUMBER, message=TITLE) response = api.send(message) if response.success: print("responseID" + response.id) cur.execute("UPDATE News SET Sent = ? WHERE URL = ?", ("1", URL)) print("Sent") else: print("responseErrorCODE" + response.error_code) conn.commit() cur.close()
def sendtext(msg, phone): for m in [msg[i:i + 10] for i in range(0, len(msg), 10)]: m = "Urgent filter triggered for:\n" + "\n".join(m) message = clockwork.SMS(from_name="Pastehunter", to=phone, message=m) response = clockworkapi.send(message) if response.success: logger.warning("Urgent text sent!") else: logger.error("Something wrong with texting -> (%s)", response.error_message)
def sendMessage(self, telephone): msg = "Welcome to Steadlly. Please insert the following code, to confirm the account: " + str( randint(0, 9999)) api = clockwork.API(self.msgapi, from_name='Steadlly') message = clockwork.SMS(to=telephone, message=msg) response = api.send(message) if response.success: # print(response.id) return True else: raise ('Something went wrong sending the message', 'response.error_code + response.error_description') return False
def send_message(to, text): if os.environ.get('SEND_SMS') != 'True': print('Would have sent "' + text + '" to ' + to) else: from_name = os.environ.get('FROM_SMS') print('Sending "' + text + '" to ' + to + " from " + from_name) message = clockwork.SMS(to=to, message=text, from_name=from_name) response = api.send(message) if response.success: print(response.id) else: print(response.error_code) print(response.error_message)
def test_should_send_single_unicode_message(self): """Sending a single SMS with the full GSM character set (apart from ESC and form feed) should work""" api = clockwork.API(self.api_key) sms = clockwork.SMS( to="441234567890", #Message table copied from http://www.clockworksms.com/doc/reference/faqs/gsm-character-set/ message=u'''@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ''' u''' !"#¤%&'()*+,-./''' u'''0123456789:;<=>?''' u'''¡ABCDEFGHIJKLMNO''' u'''PQRSTUVWXYZÄÖÑܧ''' u'''¿abcdefghijklmno''' u'''pqrstuvwxyzäöñüà''' u'''€[\]^{|}~''' ,long=True) response = api.send(sms) self.assertTrue(response.success)
def smssender(sendername, time, message): if debug: print("DEBUG - smssender(): called") sms_rec_list = str(sms_receivers).split(",") api = clockwork.API(clockworkapikey) smsmsg = sendername + ", " + unicode(time) + ": " + message for s in sms_rec_list: message = clockwork.SMS( to = s, message = smsmsg) #message = sendername.encode('utf-8') + ", " + str(time) + ": " + message.encode('utf-8')) response = api.send(message) if response.success: print (response.id) else: print (response.error_code) print (response.error_message) if debug: print("DEBUG - smssender(): finished")
def texthere(phoneno, textmsg): from clockwork import clockwork api = clockwork.API('64cb471a7ba66565a1965ac118baadffb36e7b1e') message = clockwork.SMS(to=phoneno, message=textmsg) try: response = api.send(message) logfile = open("logfile", "a") if response.success: logfile.write(str(response.success) + "\n") else: logfile.writelines( [phoneno, response.error_code, response.error_message]) except: pass
def send_time_message(number, event, time): """ This will send a message with the time registered """ # Message variable message = clockwork.SMS( to=number, message= ("Tú tiempo ha sido {0}, puedes checar los detalles en http://actime.mx/event/rd/{1}. ¡Gracias por competir con Actime!" ).format(time, event.pk)) # get the response response = api.send(message) # validate if the response is successful if response.success: print(response.id) return True else: print(response.error_code) print(response.error_message) return False # End of validations # End of send_time_messsage function
__author__ = "Christopher Sweet" __version__ = 0.1 """ SMS Spoofer is a script to spoof sms messages from various senders """ from clockwork import clockwork import random area_codes = [301, 311, 316, 210, 310, 365, 380, 401, 432, 447, 505, 512, 567] api = clockwork.API("0e7f44b7bf646ccdf1361c37acd171ae4d1056da") recipient = 0 sender = 0 #Build random sender number rand_sender = int(str(area_codes[random.randint(0,12)]) + str(random.randint(0,585)) + str(random.randint(0,5000))) msg = "Testing" message = clockwork.SMS(from_name = sender, to = recipient, message = msg) response = api.send(message)
from clockwork import clockwork api = clockwork.API('58e9ab3962aad466a70f82c8f010296afea659be', from_name='Sparebank1') message = clockwork.SMS(to='4798232848', message='Sikkerhetsbrudd i banken. Kom snarest.') response = api.send(message) if response.success: print(response.id) else: print(response.error_code) print(response.error_message)
from clockwork import clockwork import time import random import logging logging.basicConfig(filename="status.log", level=logging.INFO) api = clockwork.API("SECRET_KEY_HERE") lyrics = open("bohemian.txt", "r").readlines() for line in lyrics: payload = line.replace("\n", "") logging.info("Sending: {}".format(payload)) message = clockwork.SMS(from_name="F Mercury", to="61000000000", message=payload) response = api.send(message) if response.success: logging.info("Success") logging.info(response.id) logging.info("\n") else: logging.info("Failure") logging.info(response.error_code) logging.info(response.error_message) logging.info("\n") time.sleep(random.randrange(300, 600)) time.sleep(10) logging.info("All done")
from clockwork import clockwork api = clockwork.API('6dbd7ee0c11c49d41c298bbb4cf84edea3eda846') message = clockwork.SMS(to='14196356328', message='Test Message - Steven Kast') response = api.send(message) if response.success: print('Success ' + response.id) else: print(response.error_code) print(response.error_message)
def test_should_fail_with_invalid_key(self): api = clockwork.API("this_key_is_wrong") sms = clockwork.SMS(to="441234567890", message="This is a test message 1") self.assertRaises(clockwork_exceptions.ApiException, api.send, sms)
from clockwork import clockwork import time api = clockwork.API('') print("Starting Program") message = clockwork.SMS( to='phone number', message= 'Hello I hope your day is as good as mines..........................') response = api.send(message) if response.success: print(response.id) else: print(response.error_code) print(response.error_message) print("Complete!")
def test_should_fail_with_no_to(self): """Sending a single SMS with no message should fail""" api = clockwork.API(self.api_key) sms = clockwork.SMS(to="", message="This is a test message") response = api.send(sms) self.assertFalse(response.success)
def NewTimer(): #Sends SMS related to Perscription conn = sqlite3.connect("UserDB.db") cur = conn.cursor() cur.execute( "SELECT Users.PhoneNum, Link.TimeMedHour, Link.TimeMedMin , Medication.MedicationName , Link.AmountLeft,Link.UserID FROM Users,Link,Medication WHERE NotifMed = ? AND Users.UserID = Link.UserID AND Medication.MedID = Link.MedID", [1]) #Pulling the PhoneNumber for a User aswell as the Time they need to take their medication, the name of the medication and the amount of medication they have left. data = cur.fetchall() datalen = len(data) j = 0 #iterate through the array of phonenumbers from the database that have opped into the service for j in range(datalen): now = datetime.datetime.now().replace(microsecond=0) #defining vars for function PHONENUMBER = data[j][0] HOUR = data[j][1] MIN = data[j][2] MED = data[j][3] AmountLeft = data[j][4] UserID = data[j][5] #Translating the time in the database to a version that is readable by the computer SpecifiedTime = now.replace(hour=int(HOUR), minute=int(MIN), second=0, microsecond=0) NewAmountLeft = 0 #checks to see if the current system time is the same as the time required for the perscription if (now == SpecifiedTime): #checks to see if there is medication availible to be taken if (AmountLeft > 0): #Checks to see if there is more than or less than 5 medication left if (AmountLeft > 0 and AmountLeft <= 5): NewAmountLeft = AmountLeft - 1 reminder = str( "Its Time to take your medication of " + MED + ". You now have " + str(NewAmountLeft) + " Medication Left. This Means you need to top up ASAP before they run out." ) if (AmountLeft > 5): NewAmountLeft = AmountLeft - 1 reminder = str("Its Time to take your medication of " + MED + ". You now have " + str(NewAmountLeft) + " Medication Left.") #sends the message to the user message = clockwork.SMS(to=PHONENUMBER, message=reminder) #gathers the response response = api.send(message) #check to see if the msg was delivered or not if response.success: print("responseID" + response.id) #print("Amount left before taking pill " + str(AmountLeft)) #updates the database with the new value of the Medication cur.execute( "UPDATE Link SET AmountLeft = ? WHERE UserID = ? AND TimeMedHour = ? AND TimeMedMin = ?", (NewAmountLeft, UserID, HOUR, MIN)) #print("New amount of pills left " + str(NewAmountLeft)) else: print("responseErrorCODE" + response.error_code) conn.commit() #If there is no Medication left then we fall into this statment which will inform the user that there is no more medication else: #sends msg to user message = clockwork.SMS( to=PHONENUMBER, message="WARNING! THERE IS NO MORE OF YOUR MEDICATION " + MED) response = api.send(message) #gathers response if response.success: print("responseID" + response.id) else: print("responseErrorCODE" + response.error_code) cur.close()
from clockwork import clockwork import time api = clockwork.API("0a5b9f809d353f0404525a6a7a116909178991cb") lyrics = open("lyrics.txt", "r").readlines() for line in lyrics: payload = line.replace("\n", "") message = clockwork.SMS(from_name = "MICHHI PUTTU", to = "917754915707", message = payload) response = api.send(message) print(response) time.sleep(300)
def sendsms(body, job, number, sender=False): # seperated function for checking global N, jobs Err_N = 0 while True: try: API_Key = get_account(N) client = clockwork.API(API_Key) print("[+]", API_Key, job) if sender: message = clockwork.SMS(to=number, message=body, from_name=sender) else: message = clockwork.SMS(to=number, message=body) response = client.send(message) if response.success: print("\t\t[-]", 'Sent message', ":".join(job)) print("\t\t[-]", 'Remaining balance is', client.get_balance()) success_jobs.append(job) return True else: er = int(response.error_code) print("\t\t[-]", "error code :", er) if er == 1: print("\t\t[-]", "Something went wrong in our API") elif er == 12: print("\t\t[-]", "Message text is too long") elif er == 13: print("\t\t[-]", "You don't have an international contract") elif er == 15: print("\t\t[-]", "you Cannot send SMS to this country") elif er == 17: print("\t\t[-]", "You IP address is blocked") elif er == 25: print( "\t\t[-]", "Your account is setup to require a unique Client ID on each message, we've seen this one before." ) elif er == 26: print("\t\t[-]", "Something went wrong in our API") elif er == 33: print( "\t\t[-]", "Your account is setup to check for a unique client ID on every message, one wasn't supplied in this send." ) elif er == 40: print("\t\t[-]", "MMS text has an invalid character") elif er == 41: print("\t\t[-]", "MMS Payload can't be decoded as hex") elif er == 42: print("\t\t[-]", "MMS payload can't be decoded as Base64") elif er == 43: print("\t\t[-]", "No content type provided on MMS payload") elif er == 44: print("\t\t[-]", "All MMS Payload parts must have an ID") elif er == 45: print("\t\t[-]", "The combined parts are too large to send") elif er == 49: print("\t\t[-]", "All MMS parts must have unique filenames") elif er == 57: print( "\t\t[-]", "You need to provide an API Key or a Username and Password when calling the API" ) elif er == 58: print( "\t\t[-]", "Log in to your API account to check the key or create a new one" ) elif er == 59: print( "\t\t[-]", "This account isn't allowed to use a Username and Password, log in to your account to create a key" ) elif er == 60: print( "\t\t[-]", "Sometimes your message will be caught by our spam filter. If you're having trouble because of this error - get in touch and we'll get you up and running. Include an example of the message that was caught if you can" ) elif er == 100: print("\t\t[-]", "Something went wrong in our API") elif er == 101: print("\t\t[-]", "Something went wrong in our API") elif er == 102: print("\t\t[-]", "API Post can't be parsed as XML") elif er == 305: print("\t\t[-]", "You've sent too many status requests this hour") N = (N + 1) % len(accounts) Err_N += 1 if Err_N > len(accounts): print( "problem happen with all accounts , or there is a problem with connection / and your file : job, account, sender,link, body" ) failed_jobs.append(job) return except Exception as e: print("\t\t[-]", e, ":", API_Key) print() #print("[-]\t\tLogin Failed:", API_Key) N = (N + 1) % len(accounts) Err_N += 1 if Err_N > len(accounts): print( "problem happen with all accounts , or there is a problem with connection / and your file : job, account, sender,link, body" ) failed_jobs.append(job) return