Rewrote the notify function and twitter object so that the class does more of the work

This commit is contained in:
Kevin Midboe
2017-04-14 17:01:36 +02:00
parent 351ffd777b
commit f3f4efc6a9

View File

@@ -3,7 +3,7 @@
# @Author: KevinMidboe # @Author: KevinMidboe
# @Date: 2017-04-05 18:40:11 # @Date: 2017-04-05 18:40:11
# @Last Modified by: KevinMidboe # @Last Modified by: KevinMidboe
# @Last Modified time: 2017-04-13 12:17:04 # @Last Modified time: 2017-04-14 17:00:04
import os.path, hashlib, time, glob, sqlite3, re, json, tweepy import os.path, hashlib, time, glob, sqlite3, re, json, tweepy
from functools import reduce from functools import reduce
from fuzzywuzzy import process from fuzzywuzzy import process
@@ -33,6 +33,9 @@ class twitter(object):
def api(self): def api(self):
return self.api_token return self.api_token
def dm(self, message, user='kevinmidboe'):
response = self.api_token.send_direct_message(user, text=message)
class strayEpisode(object): class strayEpisode(object):
def __init__(self, parent, childrenList): def __init__(self, parent, childrenList):
self.parent = parent self.parent = parent
@@ -108,10 +111,9 @@ class strayEpisode(object):
def notifyInsert(self): def notifyInsert(self):
# Send unique id. (time) # Send unique id. (time)
tweetObj = twitter() tweetObj = twitter()
api = tweetObj.api() message = 'Added episode:\n' + self.showName + ' S' + self.season\
tweetString = 'Added episode:\n' + self.showName + ' S' + self.season\
+ 'E' + self.episode + '\nDetails: \n https://kevinmidboe.com/seasoned/verified.html?id=' + self._id + 'E' + self.episode + '\nDetails: \n https://kevinmidboe.com/seasoned/verified.html?id=' + self._id
response = api.send_direct_message('kevinmidboe', text=tweetString) tweetObj.dm(message)
def saveToDB(self): def saveToDB(self):