def send_insurance(self, ip_addr, cellPhone, name, message):
     ipAddress = ip_addr
     ip = IPv4Address(ipAddress)
     session = AirmoreSession(ip, 2333)
     service = MessagingService(session)
     sendMessage = "{}님 안녕하세요. {}".format(name, message)
     service.send_message(cellPhone, sendMessage)
Example #2
0
    def send_sms_message(self, number, message):
        # now create a session
        logging.info("Trying connecting AirMore on Android Device (" +
                     self.get_srv_info() + ")")
        session = AirmoreSession(self.amipaddr, self.amport)

        if not session.is_server_running:
            logging.error("AirMore is not Running on Android Device (" +
                          self.get_srv_info() + ")")
            sys.exit(1)

        logging.info("AirMore is Running on Android Device (" +
                     self.get_srv_info() + ")")

        was_accepted = session.request_authorization()
        if not was_accepted:
            logging.error("AirMore is rejecting session on Android Device (" +
                          self.get_srv_info() + ")")
            sys.exit(2)

        logging.error("AirMore is accpeting this session on Android Device (" +
                      self.get_srv_info() + ")")

        service = MessagingService(session)
        logging.info("Sending to " + number + " message: " + message)
        service.send_message(number, message)
        logging.info("Message sent to " + number)
Example #3
0
def sending():
    global session
    rucontinue = "y"
    while rucontinue == "y":
        phone_number = input("insert your taget phone number:")
        count_massage = int(input("how many times?"))
        massage = input("your massage:")
        service = MessagingService(session)
        for i in range(0, count_massage):
            print("massage %s is seding" % str(i + 1))
            service.send_message(phone_number, massage)
        rucontinue = input("are you want to continue?(y for continue)")
class Airmore_SMS_handler(object):
    def __init__(self, phone_IP, send_number):
        self.__send_number = format_phone_number(send_number)
        self.__session = AirmoreSession(IPv4Address(phone_IP))
        self.__correct_direction = lambda x: x.type == MessageType.RECEIVED
        assert self.__session.is_server_running
        assert self.__session.request_authorization()
        self.__service = MessagingService(self.__session)
        self.__initialization_time = datetime.datetime.now()
        self.__chat_id = None
        self.__chat_id = self.__get_chat_id()
        self.__buffer = b''
        self.__already_read = set()
        # Add new messages to already read...
        self.get_new_messages()

    def send(self, message):
        assert isinstance(message, str)
        self.__service.send_message(self.__send_number, message)
    
    def get_new_messages(self):
        chat_id = self.__get_chat_id()
        new_messages = []
        if chat_id != None:
            messages = self.__service.fetch_chat_history(message_or_id=chat_id, limit=50)
            for message in messages:
                if self.__correct_direction(message) and not (message.id, message.content) in self.__already_read:
                    new_messages.append(message.content)
            self.__already_read = set((message.id, message.content) for message in messages)
        return new_messages

    def __get_chat_id(self):
        if self.__chat_id != None:
            return self.__chat_id

        for message in self.__service.fetch_message_history():
            if format_phone_number(message.phone) == self.__send_number:
                self.__chat_id = message.id
            
        return self.__chat_id

    @staticmethod
    def create_test_connection():
        handler1 = Airmore_SMS_handler('192.168.1.22', '8016605023')
        handler2 = Airmore_SMS_handler('192.168.1.23', '8016436371')
        return handler1, handler2
    def employee_send(self, ip_addr, port, cellPhone, name, info):
        # Airmore 활성화
        ipAddress = ip_addr
        ip = IPv4Address(ipAddress)

        session = AirmoreSession(ip, int(port))
        service = MessagingService(session)
        now_date = datetime.date.today()
        #보낼 문자내용
        if info == '직원등록':
            message = '{}일자로 {}님의 직원등록이 완료되었습니다.'.format(now_date, name)
        elif info == '직원수정':
            message = '{}님의 정보가 변경 완료되었습니다.'.format(name)
        elif info == '보험사서류발송':
            message = '처리 서류를 메일로 발송하였습니다. 확인 부탁드립니다.'.format(name)
        elif info == '관리자등록':
            message = '{}일자로 {}님의 관리자등록이 완료되었습니다.'.format(now_date, name)
        service.send_message(cellPhone, message)
class SmsSender:
    def __init__(self, ip, port):
        try:
            self.__session = AirmoreSession(IPv4Address(ip), port)
            self.__service = MessagingService(self.__session)

            accepted = self.__session.request_authorization()

            if not accepted:
                raise Exception(f'Autorizzazione non accettata')

        except Exception as e:
            print(f'Error: {e}')

    def send(self, receiver, content):
        try:
            self.__service.send_message(receiver, content)
        except Exception as e:
            print(f'Error: {e}')

    def send_all(self, rows):

        counter = 1
        sleep_each = 10
        sleep_second = 5

        for row in rows:

            if counter % sleep_each == 0:
                print("sleep")
                sleep(sleep_second)

            data = dict(row)
            # self.send(data['Cellulare'], f"Sono disponibili {data['Pronti']} libri su {data['Totale']}")
            self.send(
                '3356760194',
                f"Sono disponibili {data['Pronti']} libri su {data['Totale']}")
            counter += 1

        print("FINITO")

    def close(self):
        self.__session.close()
Example #7
0
 def sending(self):
     try:
         ip = str(self.ip_input.text())
         port = int(self.port_input.text())
         ip4 = IPv4Address(ip)
         phone_number = str(self.number_input.text())
         count_massage = int(self.count_input.text())
         message = str(self.content_input.toPlainText())
         session = AirmoreSession(ip4, port)
         service = MessagingService(session)
         try:
             for c in range(1, count_massage + 1):
                 service.send_message(phone_number, message)
                 percent = (c / count_massage) * 100
                 self.progressBar.setProperty("value", percent)
                 self.message_send_status.append("message %i sended" % c)
                 self.sended_lcd.display(c)
                 sleep(1)
         except:
             self.message_send_status.append(
                 "the message not send. check the information.")
     except:
         self.message_send_status.append("check the connection")
from ipaddress import IPv4Address
from pyairmore.request import AirmoreSession
from pyairmore.services.messaging import MessagingService
import sys

ip = IPv4Address(f'{sys.argv[1]}')
session = AirmoreSession(ip, 2333)

print(session.is_server_running)

req_authorization = session.request_authorization()
service = MessagingService(session)
service.send_message(f'+91{sys.argv[2]}', f'{sys.argv[3]}')
Example #9
0
for a in range(1000000):
    cell = "{}{}".format(name_column, a + 1)
    name = worksheet[cell].value
    if name == "None" or name is None:
        break
    if name != "" or name is not None:
        names.append(str(name))

if (len(names) == len(phone_numbers)):
    for j in range(len(names)):
        message = "Sayın {}, korona sürecinde 3000 TL'lik nakliyat sitenizi UCRETSIZ/BEDAVA kuruyoruz. Fırsatı kaçırmayın! Google'da yerinizi almak için acele edin! Örnek site: www.edirneevdenevenakliye.com Sadece masraflar size aittir. Sms Iptali için 'LISTECIKART' yazarak geri dönünüz.".format(
            names[j])
        #message = "Sayın {}, korona sürecinde 1 haftaligina emlak sitenizi UCRETSIZ/BEDAVA kuruyoruz. Örnek site:www.gunesemlak.com Sadece masraflar size aittir.".format(names[j])
        number = "90" + str(phone_numbers[j])
        number = "+" + str(number)
        service.send_message(number, message)
        messages = service.fetch_message_history()
        print(str(j + 1) + ". mesaj atıldı.")
else:
    print(
        "Excel dosyasına göre isim ve numaralar eşit sayıda değildir. Düzeltip tekrar deneyiniz.."
    )
printm("-------------------")
printm("Tüm mesajlar gönderildi. Toplam: " + str(len(names)))
printm("Mesajlar kontrol ediliyor.")
bekle(20)
printm("-------------------")

filepath = "C:/Users/mfurk/Desktop/SMS GÖNDERME/Kapalı Telefonlar.xlsx"

workbook = load_workbook(filename=filepath, read_only=False)
Example #10
0
session = AirmoreSession(ip)
was_accepted = session.request_authorization()

service = MessagingService(session)
messages = service.fetch_message_history()
a = messages[0].content

while 1:
    sleep(1)
    messages = service.fetch_message_history()
    print(a, l)
    if a == messages[0].content:
        pass
    else:
        if messages[0].phone == "le numero":
            if messages[0].content != liste[l - 1]:
                service.send_message("le numero", liste[l])
                a = messages[0].content
                print(a, l)
                l = l + 1
                if l == len(liste):
                    l = 0
        else:
            if messages[0].content != liste[k - 1]:
                service.send_message(messages[0].phone, liste[k])
                a = messages[0].content
                print(a, k)
                k = k + 1
                if k == len(listee):
                    k = 0
Example #11
0
for i in range(row_count):
    cellPhone = "{}{}".format(columnPhone, i + 1)
    cellName = "{}{}".format(columnName, i + 1)
    name = worksheet[cellName].value
    number = worksheet[cellPhone].value
    if number != "" or number is not None:
        phoneNumbers[name] = str(number)

for nm, pn in phoneNumbers.items():
    sendMessage = "{name}님 안녕하세요. {message}".format(name=nm, message=message)
    print(nm)
    print(pn)
    print(sendMessage)
    print("")

print("총 {count}명에게 문자메시지 발송 가능합니다.\n".format(count=len(phoneNumbers)))

order = input("위의 연락처로 문자를 발송하시겠습니까? Y or N ")

if order == "Y" or order == "YES" or order == "y" or order == "yes" or order == "Yes":
    for nm, pn in phoneNumbers.items():
        sendMessage = "{name}님 안녕하세요. {message}".format(name=nm,
                                                        message=message)
        service.send_message(pn, sendMessage)
        print("{name}님의 {number}로 문자를 발송하였습니다.".format(name=nm, number=pn))
else:
    print("발송이 취소되었습니다.")

input("아무 키나 누르면 종료합니다. ")
Example #12
0
from ipaddress import IPv4Address
from pyairmore.request import AirmoreSession
from pyairmore.services.messaging import MessagingService
from time import sleep


x = input("ip locale: ")
y = input("numéro cible: ")
z = input("message: ")
snk = int(input("nb de réptésions: "))

ip = IPv4Address(x)
session = AirmoreSession(ip)
was_accepted = session.request_authorization()

service = MessagingService(session)

a = 0

while a < snk:
	service.send_message(y, z)
	a = a+1
Example #13
0
from pyairmore.services.messaging import MessagingService  # to send messages

print("Setup your Airmore ap with the code")
ipadd1 = str(input("Enter ip address mentioned on the Airomre app: "))
ip = IPv4Address(
    ipadd1)  # let's create an IP address object# now create a session
port1 = int(input("Enter the port-number mentioned on the Airomre app: "))

#session = AirmoreSession(ip)# if your port is not 2333

session = AirmoreSession(ip, port1)  # assuming it is 2333

session.is_server_running  # True if Airmore is running

was_accepted = session.request_authorization()

print(was_accepted)  # True if accepted

#inputs to send sms

mobile_number = str(input("Enter the mobile number to send message: "))

message_content = str(input("Enter the content to send: "))

#starting sms

service = MessagingService(session)

service.send_message(mobile_number, message_content)
Example #14
0
ip = IPv4Address("192.168.0.100")
session = AirmoreSession(ip)
was_accepted = session.request_authorization()
service = MessagingService(session)
while True:
    mydb = mysql.connector.connect(host="us.dreamcometrue.studio",
                                   user="******",
                                   password="******",
                                   database="bank")
    mycursor = mydb.cursor()
    mycursor.execute("SELECT * FROM transactions;")
    myresult = mycursor.fetchall()
    if len(myresult) > done:
        c = myresult[done]
        mycursor.execute("SELECT phone FROM userdetails WHERE customerid ='" +
                         c[0] + "';")
        myresult = mycursor.fetchall()
        if len(myresult) != 0:
            try:
                msg = "This is a auto generated message\n" + c[1] + "\n" + c[2]
                ip = IPv4Address("192.168.0.100")
                service.send_message(myresult[0][0], msg)
                done += 1
            except:
                done += 1
                pass
        else:
            done += 1
    mydb.close()
Example #15
0
class Wedding():
    def __init__(self):
        self.loc = (FILENAME)
        self.ip = IPv4Address(IP_ADDRESS)
        self.session = AirmoreSession(self.ip)

        self.was_accepted = self.session.request_authorization()
        if (self.was_accepted):
            print("Connection Established")
        else:
            print("Connection Error! please verify ip address")
            exit()
            
        self.service = MessagingService(self.session)

        #Open Excel
        self.rb = xlrd.open_workbook(self.loc)
        self.sheet = self.rb.sheet_by_index(0)
        self.wb = copy(self.rb)
        self.w_sheet = self.wb.get_sheet(0)

        self.createGuestListDict()
        self.sendInvitationList()
        self.checkRecieve()

        self.createArrivedGuestsDict()
        self.sendThankYou()

    def getConfirmedGuests(self):
        column_sum = 0
        for row in range(self.sheet.nrows):
            try:
                column_sum += self.sheet.cell_value(row, 4)
            except:
                pass
        return int(column_sum)

    def createArrivedGuestsDict(self):
        arrived_guests = 0
        self.guest_dict = {}
        for i in range(1, self.sheet.nrows):
            try:
                if ((self.sheet.cell_value(i, 12)>0) and (len(self.sheet.cell_value(i, 2))==10)): #Person did not response and phone number is defined in list
                        phone_number = self.sheet.cell_value(i, 2)
                        phone_number = COUNTRY_AREA_CODE + phone_number[1:len(phone_number)]
                        self.guest_dict[phone_number] = i
                        arrived_guests += self.sheet.cell_value(i, 10)
            except:
                pass

        print("Total Arrived Guests - ", arrived_guests)


    def createGuestListDict(self):
        not_resp = 0
        self.guest_dict = {}
        for i in range(0, self.sheet.nrows):
            if ((self.sheet.cell_value(i, 9)=="לא הגיב") and (len(self.sheet.cell_value(i, 2))==10)): #Person did not response and phone number is defined in list
                    phone_number = self.sheet.cell_value(i, 2)
                    phone_number = COUNTRY_AREA_CODE + phone_number[1:len(phone_number)]
                    self.guest_dict[phone_number] = i
                    not_resp += 1

        print("Total Rows - ", self.sheet.nrows, "Did not responed - ", not_resp, " confirmed guests - ", self.getConfirmedGuests())

    def checkRecieve(self):
        while True:
            messages = self.service.fetch_message_history()
            for i in range(0,20):           #Check only last 20 messages
                #Update person with the retuned number of SMS
                try:
                    print(messages[i].phone)
                    print("Recieved Message from - ", messages[i].phone, " number of confirmed guests - ", int(messages[i].content))
                    if ((messages[i].phone in self.guest_dict) and (self.sheet.cell_value(self.guest_dict[messages[i].phone], 9)=="לא הגיב")):
                        print("Guest Confirmed!! Recieved Message from - ", messages[i].phone, " number of confirmed guests - ", int(messages[i].content))
                        self.w_sheet.write(self.guest_dict[messages[i].phone], 10, messages[i].content)
                        self.w_sheet.write(self.guest_dict[messages[i].phone], 9, "מגיע")
                        if (int(messages[i].content)>0):
                            print("Send Transportation")
                            print(messages[i].phone, TRANSPORTATION) if DEBUG else self.service.send_message(messages[i].phone, TRANSPORTATION)
                        self.wb.save('Wedding.xlsx')
                except:
                    pass
                time.sleep(0.2)

    def sendThankYou(self):
        print("Do you want to send THANK YOU SMS? \n")
        choice = input().lower()
        if (choice=="yes"):
            print ("Sending SMS")
            #Send SMS
            for i in self.guest_dict:
                print("Send SMS to - ", i)
                name = self.sheet.cell_value(self.guest_dict[i], 0)
                msg_to_send = name + ",\n" + THANK_YOU
                print(msg_to_send) if DEBUG else self.service.send_message(i, msg_to_send)
                time.sleep(2)

    def sendInvitationList(self):
        print("Do you want to send INVITATION SMS? \n")
        choice = input().lower()
        if (choice=="yes"):
            print ("Sending SMS")
            for i in self.guest_dict:
                print("Send SMS to - ", i)
                print(INVITE_REMINDER) if DEBUG else self.service.send_message(i, INVITE)
                time.sleep(1)

    def sendInvitationReminderAllList(self):
        print("Do you want to send INVITATION REMINDER SMS? \n")
        choice = input().lower()
        if (choice=="yes"):
            print ("Sending SMS")
            for i in self.guest_dict:
                print("Send SMS to - ", i)
                print(INVITE_REMINDER) if DEBUG else self.service.send_message(i, INVITE_REMINDER)
                time.sleep(1)
Example #16
0
		valid = 0
		while valid == 0:
				mess = simpledialog.askstring(title="Message à envoyer", prompt="Merci de rentrer le message à envoyer")
				if mess == None:
					messagebox.showwarning(title="Annulation", message="Envois annulés")
					exit()
				v = messagebox.askquestion(title="Confimer le message", message=f"Voulez-vous vraiment envoyer ce message à {len(phone_numbers)} numéros de téléphone? \n\n{mess}")
				if v == "yes":
					valid = 1
		bar = IncrementalBar("Envoi des SMS en cours...", max=len(phone_numbers))
		row = 0
		for num in phone_numbers:
			if row == 10:
				print("Pause des envois afin de ne pas bloquer la ligne")
				time.sleep(20)
			try:
				service.send_message(num, mess)
			except MessageRequestGSMError:
				print(f"\nEchec de l'envoi du message à {num}, le numéro peut être valide mais le problème vient plutôt du telephone utilisé")
			else:
				print(f"Message envoyé à {num}")
			bar.next()
			row = row + 1
		bar.finish()
		messagebox.showwarning(title="Fin", message="Tout les messages ont été envoyés")
	else:
		print("\nLa connexion n'a pas été autorisée merci de réessayer")
else:
	print("La connection à échoué, merci de relancer l'application avant de réessayer")