Пример #1
0
 def create(self, vals):
     telephone = vals.get('name')
     smstext = vals.get('text')
     objconfig = self.env["textmagicsms.configuration"].browse([1])
     print objconfig
     if objconfig:
         username = objconfig.name
         token = objconfig.token
         nummax = objconfig.numsms
         hoy = fields.Date.today()
         finicio = hoy + " 00:00:00"
         ffin = hoy + " 23:59:59"
         numero = self.env['textmagicsms.messages'].search_count([
             ('datetime', '<=', ffin), ('datetime', '>=', finicio)
         ])
         print "Numero de envios %s" % numero
         if numero <= nummax:
             if token and username:
                 print "Username and token and phone %s , %s , %s" % (
                     username, token, telephone)
                 client = TextmagicRestClient(username, token)
                 vals['sendstate'] = client.messages.create(
                     phones=telephone, text=smstext)
                 vals['datetime'] = fields.Datetime.now()
                 print vals
                 new_id = super(TextMagicMessages, self).create(vals)
                 return new_id
Пример #2
0
def square():
    from textmagic.rest import TextmagicRestClient
    username = "******"
    token = "P911qT2EAXDqh5Es40N6Cog7j0E6jF"
    client = TextmagicRestClient(username, token)
    data = client.messages.create(phones="+19495617269", text="Hello")
    data = jsonify(data)
    return data
Пример #3
0
    def send_sms(self):
        username = "******"
        token = "mKGVo2k0jO6fKpRrWZdu0xMEzkat7S"
        phonenum = "+4915758622065"
        txt = "I need your help"

        client = TextmagicRestClient(username, token)
        sms = client.messages.create(phones=phonenum, text=txt)
Пример #4
0
def SendSms(number, text):
    from textmagic.rest import TextmagicRestClient

    username = "******"
    token = "your_apiv2_key"
    client = TextmagicRestClient(username, token)

    message = client.messages.create(phones=number, text=text)
    return True
Пример #5
0
    def initialize(self):
        # Connecting to firebase
        self.initialize_firebase_connection()

        # Create Text Magic object
        # Text magic username, API Key
        self.client = TextmagicRestClient("anguslurcott", "83e2ltp21gWb6gx1st3WXA4EDeJmSq")

        # Email account details. Currently hardcoded but will change in future
        self.EMAIL_ADDRESS = '*****@*****.**'
        self.EMAIL_PASSWORD = '******'
Пример #6
0
def send_alert():
    #problems = sendemail(from_addr = os.environ["GMAIL_USERNAME"],
    #                    to_addr    = os.environ["EMAIL_RECEIVER"],
    #                    subject    = 'Website down',
    #                    message    = 'Fix it!',
    #                    login      = os.environ["GMAIL_USERNAME"],
    #                    password   = os.environ["GMAIL_PASSWORD"])
    username = os.environ["TEXTMAGIC_USERNAME"]
    token = os.environ["TEXTMAGIC_TOKEN"]
    client = TextmagicRestClient(username, token)
    message = client.messages.create(phones=os.environ["ADMIN_PHONE"],
                                     text="Leto checker alert!")
Пример #7
0
def sms(fillsms: dict) -> dict:
    # appointment hash
    appointment_hash = hashfunclong("|".join(fillsms.values()))

    # TextMagic
    username = "******"
    token = "VJ6O0aVQqaz5i6w3oNt7MWVgTnHnvy"
    client = TextmagicRestClient(username, token)

    # generate maps url
    address = "+".join(fillsms["Address"].split(" "))
    address = urllib.parse.quote(address)
    maps_url = "https://www.google.com/maps/dir/?api=1&destination={}&travelmode=transit".format(
        address)

    phones = ["+61430204771"]
    text = "Hello from Culture Fluent... \nDIRECTIONS VIA MAPS: {}".format(
        maps_url)

    # if audio...
    audio = None
    if fillsms['Audio']:
        # get the stuff before the url
        read = text.split(": https://")[0]
        lang = fillsms['Language']
        print("Trying to find Audio for Language = {}".format(lang),
              flush=True)
        translator = Translator()
        for key, short in reversed_ttslangs.items():
            if lang in key:
                translation = translator.translate(read, dest=short)
                audio = gtts.gTTS(translation.text, lang=short)
                print("AUDIO LANGUAGE: {}".format(short), flush=True)
        if audio:
            audio.save("{}/{}.mp3".format(config.output_dir, appointment_hash))

    try:
        #message = client.messages.create(phones=",".join(phones), text=text)
        return {
            "sms": phones,
            "text": text,
            "appointment_id": appointment_hash
        }
    except:
        return {
            "sms": phones,
            "text": text,
            "sms_failed": True,
            "appointment_id": appointment_hash
        }
Пример #8
0
    def startTextMagic(self):
        script = self.script
        phone = self.phoneNumber
        sleepTime = self.timeBetweenTexts
        username = self.username
        token = self.token

        # initializes the client to use your user credentials
        client = TextmagicRestClient(username, token)

        with open(script, 'r') as file:
            data = file.read().replace('\n', '')
            for word in data.split():
                message = client.messages.create(
                                                  phones = self.phoneNumber,
                                                  text = word
                                                 )
                time.sleep(self.sleepTime)
Пример #9
0
def sendMessage():
    # manpreetsingh3
    user_name = "manpreetsingh4"
    # rRFylATjz3sQvhTDB5w5CTe4kQ2I81
    auth_token = "xu0eI43BVNlYWzBzHwsfP6Aa7gAphr"
    try:
        client = TextmagicRestClient(user_name, auth_token)
        message = client.messages.create(phones=phoneNumber, text=msg)
        msgId = message.messageId
    except Exception as e:
        logger("Some error occurred while sending the text message -> " +
               str(e))
        return
    if msgId != "":
        logger("Text message has been sent successfully with messageId - " +
               str(msgId))
    else:
        logger(
            "There was some error in sending the text message(No Exception caused)"
        )
    return
Пример #10
0
from textmagic.rest import TextmagicRestClient
import csv

username = "******"
token = "yyy"

print('Enter no of users')
N = int(input())

with open('debt.csv', 'rU') as f:
    reader = csv.reader(f)
    data = list(list(rec) for rec in csv.reader(
        f, delimiter=','))  #reads csv into a list of lists
msg = ""
for e in range(N):
    print('Enter mobiles number')
    num = input()
    for n in range(N):
        if n != e:
            msg = msg + "pay " + str(n) + " Rs" + str(data[e][n])
            msg = msg + "\n"

    client = TextmagicRestClient(username, token)
    message = client.messages.create(phones=num, text=msg)

    msg = ""
Пример #11
0
def app(args):

    username = "******"
    token = "xxx"
    client = TextmagicRestClient(username=username, token=token)

    def send():
        print("SEND MESSAGE")
        print("============")
        text = input("Text: ")

        phones = ""
        print(
            "Enter phone numbers, separated by [ENTER]. Empty string to break."
        )
        while True:
            phone = input("Phone: ")
            if phone:
                phones += phone + ","
            if not phone and phones:
                phones = phones.rstrip(",")
                break
        print("Sending message to %s" % phones)
        prompt = input("Proceed (y/n)? ")
        if prompt == "y":
            m = client.messages.create(text=text, phones=phones)
            print("Message session %s was sent successfully." % m.id)

    def show(args):
        def pagination(title, method, template, fields):
            page = 1
            while True:
                if page < 0:
                    page = 0
                rows, pager = getattr(client, method).list(page=page)
                print("\n  %s  " % title)
                print("===============")
                print("Page %s of %s\n" % (pager["page"], pager["pageCount"]))
                for r in rows:
                    print(template % tuple(getattr(r, x) for x in fields))

                print("\n1. Next page")
                print("2. Previous page")
                print("3. Exit")
                action = input("Your choice[3]:") or 3

                if action == "1":
                    page += 1
                elif action == "2":
                    page -= 1
                else:
                    break

        if "contacts" in args:
            title = "MY CONTACTS"
            method = "contacts"
            template = "%s | %s %s | %s"
            fields = ("id", "firstName", "lastName", "phone")
            pagination(title, method, template, fields)
        elif "lists" in args:
            title = "LISTS"
            method = "lists"
            template = "%s | %s | %s"
            fields = ("id", "name", "membersCount")
            pagination(title, method, template, fields)
        elif "sent" in args:
            title = "SENT MESSAGES"
            method = "messages"
            template = "%s | %s | %s"
            fields = ("id", "receiver", "text")
            pagination(title, method, template, fields)
        elif "inbox" in args:
            title = "RECEIVED MESSAGES"
            method = "replies"
            template = "%s | %s | %s"
            fields = ("id", "sender", "text")
            pagination(title, method, template, fields)
        else:
            print("Usage:\n\tpython app.py show sent|inbox|contacts|lists")

    def info():
        user = client.user.get()
        print("ACCOUNT DETAILS")
        print("===============")
        print("User ID    : %s" % user.id)
        print("First name : %s" % user.firstName)
        print("Last name  : %s" % user.lastName)
        print("Username   : %s" % user.username)
        print("Balance    : %s %s" % (user.balance, user.currency["id"]))
        if user.timezone:
            print("Timezone   : %s" % user.timezone["timezone"])

    if "send" in args:
        send()
    elif "show" in args:
        show(args)
    elif "info" in args:
        info()
    else:
        usage()
Пример #12
0
apikey = "Rasd123sdfsdfscszxxzorsomething"

#for Text2speech, the recipient has to be a member of list
#On the textmagic Web UI contacts section to make contacts and then a list. Set the contacts to "landline"
#The easiest way to get the list ID is to go to the lists page ( https://my.textmagic.com/online/messages/lists ),
#and click on the appropriate list. The URL will end with the List ID.
#For example: https://my.textmagic.com/online/contacts/list/999999 , where the list ID would be 999999 .

recipients = '999999'

##### END OF USER CONFIGURABLE SECTION #####
##### END USER CONFIGURABLE SECTION #####

###### MAIN CODE #######
#### DO NOT EDIT #######
###### MAIN CODE #######

#Initialize the client object - provided by the textmagic library
client = TextmagicRestClient(username, apikey)

#the PRTG output is then repeated twice
#this allows the user to keep listening, since the text2speech can be spotty
args = sys.argv[1:]
arguments = ''.join(str(x) + ' ' for x in args)
arguments = arguments + arguments

try:
    client.messages.create(lists=recipients, text=arguments)
except BaseException as e:
    print(e)
Пример #13
0
from pypa.env import Environment, ENVIRONMENT
import re
from datetime import datetime, date, timedelta
import argparse
import logging
from os import getenv


log = logging.getLogger(__name__)
env = Environment('sms')

env.configure_logger(log)

log.info('Running sms with ENVIRONMENT=%s', ENVIRONMENT)

client = TextmagicRestClient(env.TEXTMAGIC_USERNAME, env.TEXTMAGIC_TOKEN)

def pet_name_combine(pets):
    names = list(map(lambda p: p.name, pets))
    if len(names) == 1:
        return names[0]
    
    comb = ', '.join(names[:-1])
    comb += ' and ' + names[-1]
    return comb

def send_sms(pa, booking, msg, customer, test):
    
    if msg:
        pass
    else:
Пример #14
0
 def setUp(self):
     self.client = TextmagicRestClient(username=username, token=token)
Пример #15
0
 def setUp(self):
     username = "******"
     token = "xxx"
     self.client = TextmagicRestClient(username, token)
Пример #16
0
def SEND_SMS_VOLUENTEER(phone_no_v, phone_no_r):

    message = "Hi! A citizen in your area needs help shopping. Please contact him/her via the following phone number: {}. Thank you for helping".format(
        phone_no_r)
    client = TextmagicRestClient(username, token)
    client.messages.create(phones=phone_no_v, text=message)
Пример #17
0
def sendSMS(number, message):
    username = "******"
    token = "ffAUkYvzr2OPhVr2RhLo1FIbo0Afmh"
    client = TextmagicRestClient(username, token)

    message = client.messages.create(phones=number, text=message)
Пример #18
0
from bs4 import BeautifulSoup
from textmagic.rest import TextmagicRestClient
import requests, json, urllib2

client = TextmagicRestClient("yradsmikham", "VlY7PjdtNSZkiiyZn6U1GX0KV7jLTl")

# inputs
# enter phone number, specify dates and campground id
phone_number = "" # must include country code
campground_id = "232472" # example correponds to Yosemite Upper Pines Campground
start_date = "2019-01-28"
end_date = "2019-01-30"

#232472 Indian Cove JTree

# specify url
url = "https://www.recreation.gov/api/camps/availability/campground/"+campground_id+"?start_date="+start_date+"T00%3A00%3A00.000Z&end_date="+end_date+"T00%3A00%3A00.000Z"

def webscrape(url):
    # query website and return html
    data = urllib2.urlopen(url)

    # parse the html using beautiful soup and store in variable 
    soup = str(BeautifulSoup(data, 'html.parser'))
    campsite_json = json.loads(soup)

    # iterate through each campsite to check for availabilities
    available_campsites = []
    for campsite in campsite_json['campsites']:
        days = campsite_json['campsites'][campsite]["availabilities"]
        availabilities = []