예제 #1
0
파일: sms.py 프로젝트: Greenwicher/qtpylib
def _send_twilio(msg, numbers):
    global SMS_CREDENTIALS

    twilio_sid = SMS_CREDENTIALS['sid'].strip().split(
        ' ')[0] if "sid" in SMS_CREDENTIALS else None

    twilio_token = SMS_CREDENTIALS['token'].strip().split(
        ' ')[0] if "token" in SMS_CREDENTIALS else None

    twilio_from = SMS_CREDENTIALS['from'].strip().split(
        ' ')[0] if "from" in SMS_CREDENTIALS else "QTPyLib"

    if twilio_sid is None or twilio_token is None or twilio_from is None:
        return

    # send message
    sent = 0
    smsClient = twilioClient(twilio_sid, twilio_token)
    for number in numbers:
        if "+" not in number:
            number = "+" + str(number)
        response = smsClient.messages.create(
            body=msg, to=number, from_=twilio_from)
        if response.sid != '':
            sent += 1

    return len(numbers) == sent
예제 #2
0
파일: sms.py 프로젝트: nnajiih/qtpylib
def _send_twilio(msg, numbers):

    twilio_sid = SMS_CREDENTIALS['sid'].strip().split(
        ' ')[0] if "sid" in SMS_CREDENTIALS else None

    twilio_token = SMS_CREDENTIALS['token'].strip().split(
        ' ')[0] if "token" in SMS_CREDENTIALS else None

    twilio_from = SMS_CREDENTIALS['from'].strip().split(
        ' ')[0] if "from" in SMS_CREDENTIALS else "QTPyLib"

    if twilio_sid is None or twilio_token is None or twilio_from is None:
        return 0

    # send message
    sent = 0
    smsClient = twilioClient(twilio_sid, twilio_token)
    for number in numbers:
        if "+" not in number:
            number = "+" + str(number)
        response = smsClient.messages.create(body=msg,
                                             to=number,
                                             from_=twilio_from)
        if response.sid != '':
            sent += 1

    return len(numbers) == sent
예제 #3
0
파일: commute.py 프로젝트: KhoiBui/Commute
def send_update(message):
    twilio_client = twilioClient(keys.account_sid, keys.auth_token)
    twilio_client.api.messages.create(to=keys.to_number,
                                      from_=keys.from_number,
                                      body=message)
예제 #4
0
 def __init__(self, accountID, keyID):
     self.twilioCli = twilioClient(accountID, keyID)
예제 #5
0
# Import Exchange Clients
from binance.client import Client as binanceClient
from kucoin.client import Client as kucoinClient
from bittrex.bittrex import Bittrex as bittrexClient, API_V2_0


# Twilio Dependencies
from sendsms import *
from twilio.rest import Client as twilioClient

# initiate Clients
binanceclient = binanceClient(binance_key(), binance_secret())
kucoinclient = kucoinClient(kucoin_key(), kucoin_secret())
bittrexclient = bittrexClient(bittrex_key(), bittrex_secret(), api_version=API_V2_0)
twilioclient = twilioClient(twilio_account_sid(), twilio_auth_token())

print "checking trading pairs..."
new_exchange_symbols = {}

# get exchange api returns for tickers TODO add exchange class with abstracted get_pairs(), get_name(), etc. methods
binance_trading_symbols = binanceclient.get_all_tickers()
kucoin_trading_symbols = kucoinclient.get_trading_symbols()
bittrex_currencies = bittrexclient.get_currencies()[u'result']

# encode pairs/symbols to lists
new_exchange_symbols['binance'] = [price['symbol'].encode('utf-8') for price in binance_trading_symbols]
new_exchange_symbols['kucoin'] = [dicts[u'symbol'].encode('utf-8') for dicts in kucoin_trading_symbols]
new_exchange_symbols['bittrex'] = [dicts[u'Currency'].encode('utf-8') for dicts in bittrex_currencies]

# Load recent exchange symbols as dict
예제 #6
0
#!/usr/bin/python3
import discord
from print_m import print_m
from twilio.rest import Client as twilioClient
from getTwilioInfo import *
from send_message import *

client = discord.Client()

twilioInfo = getTwilioInfo()
twilioSID = twilioInfo[0]
twilioToken = twilioInfo[1]
from_number = twilioInfo[2]
to_number = twilioInfo[3]
twilio_client = twilioClient(twilioSID, twilioToken)


@client.event
async def on_message(message):
    update = "Server: " + str(message.guild) + "\n"
    update += "Channel: " + str(message.channel) + "\n"
    update += "Author: " + str(message.author) + "\n"
    update += "Message: " + str(message.content)  # + "\n"
    #update += "Mentions: " + str(message.mentions) + "\n"
    #update += "Role Mentions: " + str(message.role_mentions) + "\n"
    #print_m(update)
    #if(message.author == client.user):
    #	return

    if (message.mention_everyone):
        page = f"Ping: @everyone\n" + update
예제 #7
0
proxy_client = TwilioHttpClient(proxy={'http': os.environ['http_proxy'], 'https': os.environ['https_proxy']})

account_num = "twilio phone number you bought"

# Twilio authentication
os.environ["TWILIO_ACCOUNT_SID"] = "twilio sid"
os.environ["TWILIO_AUTH_TOKEN"] = "twilio auth token"

'''
More convenient, less secure
account_sid = "twilio sid"
auth_token = "twilio auth_token"
'''

# Instantiates a Twilio client
twilio_client = twilioClient(account_sid, auth_token, http_client=proxy_client)

# GoogleCloud authentication for Dialogflow service account
path_to_key = '/home/<your-name-here>/mysite/secret-key.json'
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = path_to_key

# Instantiates a Google Cloud storage client before doing anything else
# https://cloud.google.com/storage/docs/reference/libraries for more info
# you do not need to make buckets for this to work
google_cloud_storage_client = storage.Client()

# Dialogflow options
DIALOGFLOW_PROJECT_ID = 'google cloud project id'
DIALOGFLOW_LANGUAGE_CODE = 'en-US'
SESSION_ID = "anything you like, it doesn't matter"