From 8f20e6a8ca7095336834ff4e6a1ef9a88ba29c20 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 26 Oct 2018 18:19:50 -0700 Subject: [PATCH] Changed some typos I typo'd and used the wrong variable name. --- database.md | 4 +--- smslisten.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/database.md b/database.md index ac06f88..5516100 100644 --- a/database.md +++ b/database.md @@ -5,7 +5,7 @@ CREATE TABLE `messages` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `timestamp` INT(12) NOT NULL, `pid` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Flowroute Msg Id' COLLATE 'utf8_bin', - `provider_timestamp` VARCHAR(24) NOT NULL COMMENT 'Flowroute Provided Timestamp' COLLATE 'utf8_bin', + `provider_timestamp` VARCHAR(24) NULL DEFAULT NULL COMMENT 'Flowroute Provided Timestamp' COLLATE 'utf8_bin', `direction` ENUM('inbound','outbound') NULL DEFAULT 'inbound' COLLATE 'utf8_bin', `source_number` VARCHAR(11) NOT NULL COLLATE 'utf8_bin', `dest_number` VARCHAR(11) NOT NULL COLLATE 'utf8_bin', @@ -18,8 +18,6 @@ ENGINE=InnoDB AUTO_INCREMENT=15 ; - - CREATE TABLE `dids` ( `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT, `number` TINYTEXT NOT NULL COLLATE 'utf8_bin', diff --git a/smslisten.py b/smslisten.py index ac289d6..431b9a3 100644 --- a/smslisten.py +++ b/smslisten.py @@ -21,16 +21,16 @@ sqluser = config.get("sql","sqluser") sqlpass = config.get("sql","sqlpass") sqldb = config.get("sql","sqldb") - basic_auth_user_name = config.get("flowroute","fr_access_key") basic_auth_password = config.get("flowroute","fr_secret_key") - client = FlowroutenumbersandmessagingClient(basic_auth_user_name, basic_auth_password) messages_controller = client.messages #Flowroute API endpoint and reply SMS to be sent fr_api_url = "https://api.flowroute.com/v2.1/messages" + +############ Lets start our stuff db = MySQLdb.connect(host=sqlhost, user=sqluser, passwd=sqlpass, db=sqldb) @@ -46,7 +46,9 @@ def inboundsms(): reply_from = json_content['data']['attributes']['to'] msg_id = json_content['data']['id'] body = json_content['data']['attributes']['body'].decode('utf-8') - + + logmysql(msg_id, json_content['data']['attributes']['timestamp'], 'inbound', reply_from, reply_to,json_content['data']['attributes']['amount_display'], body) # Lets log to our silly db. + pprint.pprint(body) if body.lower() == u'count'.lower(): sendreply(reply_to, reply_from, "There have been " + str(counter) + " messages sent to this system.") @@ -54,8 +56,6 @@ def inboundsms(): sendreply(reply_to, reply_from, "Right now only the command 'count' works.") else: #Echo a reply sendreply(reply_to, reply_from, "What? You should type 'help' for a list of valid commands") - - logmysql(msg_id, json_content['data']['attributes']['timestamp'], 'inbound', reply_from, reply_to,json_content['data']['attributes']['amount_display'], body) # Lets log to our silly db. counter += 1 return '0' @@ -89,9 +89,9 @@ def sendreply(reply_to, reply_from, msg): print ("---Returning message") result = messages_controller.send_a_message(request_body) pprint.pprint(result) - json_content = request.json - msg_id = json_content['data']['id'] - logmysql(msg_id, json_content['data']['attributes']['timestamp'], 'outbound', reply_to, reply_from,'$0.0040', msg) # Lets log to our silly db. + + msg_id = result['data']['id'] + logmysql(msg_id, '', 'outbound', reply_to, reply_from,'$0.0040', msg) # Lets log to our silly db. print ("ID: ", msg_id) return '0'