This commit is contained in:
0xDEAD10CC 2017-07-29 16:22:50 -07:00 committed by Steve Bouché
parent 1d8ac75c8e
commit 89aee67396
2 changed files with 20 additions and 12 deletions

View file

@ -35,7 +35,13 @@ class CurrencyTask(CoindroidAPITask):
continue continue
if self.currentTransaction: if self.currentTransaction:
self.lastTransaction = self.currentTransaction.copy() self.lastTransaction = self.currentTransaction.copy()
self.currentTransaction = request.json()[0] self.currentTransaction = request.json()
if not request.json():
self.logger.error("Response is empty!")
elif len(request.json()) < 1:
self.logger.error("Response is empty!")
else:
self.currentTransaction = request.json()[0]
self.logger.info("Retrieved currency from Coindroids...") self.logger.info("Retrieved currency from Coindroids...")
self.logger.debug("{}".format(self.currentTransaction.get("last_ingested"))) self.logger.debug("{}".format(self.currentTransaction.get("last_ingested")))
if not self.lastTransaction: if not self.lastTransaction:

View file

@ -2,7 +2,9 @@ import logging, telepot
from CoindroidAPI import CoindroidAPITask from CoindroidAPI import CoindroidAPITask
from gevent import sleep from gevent import sleep
from collections import namedtuple from collections import namedtuple
from twilio.rest import Client as TwilioClient
# from twilio.rest import Client as TwilioClient
class DroidControllerTask(CoindroidAPITask): class DroidControllerTask(CoindroidAPITask):
@ -21,12 +23,12 @@ class DroidControllerTask(CoindroidAPITask):
"experienceChangedFrom", "experienceChangedFrom",
"experienceChangedTo", "experienceChangedTo",
]) ])
twilioAccount = "ACdfcd2b529db83954e8a0041796072960" # twilioAccount = "ACdfcd2b529db83954e8a0041796072960"
twilioToken = "ab9b98a0b3da8a728d14774192773af2" # twilioToken = "ab9b98a0b3da8a728d14774192773af2"
try: # try:
self.twilioClient = TwilioClient(twilioAccount, twilioToken) # self.twilioClient = TwilioClient(twilioAccount, twilioToken)
except: # except:
self.logger.exception("Unable to initialize Twilio client!") # self.logger.exception("Unable to initialize Twilio client!")
try: try:
self.telegramBot = telepot.Bot( self.telegramBot = telepot.Bot(
"382491836:AAGj8Hf5HNAwcukRrjQ3Eyv7TSa2YvGax5s") "382491836:AAGj8Hf5HNAwcukRrjQ3Eyv7TSa2YvGax5s")
@ -132,8 +134,8 @@ class DroidControllerTask(CoindroidAPITask):
stats["targetID"] == 160): stats["targetID"] == 160):
self.logger.debug( self.logger.debug(
"bob's got an action!!! sending sms!!") "bob's got an action!!! sending sms!!")
if self.twilioClient: # if self.twilioClient:
self.sendSMS(to="+14088963912", body=message) # self.sendSMS(to="+14088963912", body=message)
if self.telegramBot: if self.telegramBot:
self.telegramBot.sendMessage(-228315434, message) self.telegramBot.sendMessage(-228315434, message)
if (stats["droid_name"] == "Mabuhay") or ( if (stats["droid_name"] == "Mabuhay") or (
@ -142,8 +144,8 @@ class DroidControllerTask(CoindroidAPITask):
"targetID"] == 165: "targetID"] == 165:
self.logger.debug( self.logger.debug(
"Mabuhay's got an action!!! sending sms!!") "Mabuhay's got an action!!! sending sms!!")
if self.twilioClient: # if self.twilioClient:
self.sendSMS(to="+14086342295", body=message) # self.sendSMS(to="+14086342295", body=message)
if self.telegramBot: if self.telegramBot:
self.telegramBot.sendMessage(-228315434, message) self.telegramBot.sendMessage(-228315434, message)
else: else: