Re-based to Slim, reduced NTLK corpus dependencies
Image now has a much smaller footprint of ca 300 MB rather than 9 GB
This commit is contained in:
parent
272ecf80a5
commit
356bbbc5c9
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,7 @@
|
|||||||
|
# Log Files
|
||||||
|
interaction/last_seen.txt
|
||||||
|
posting/post_log.txt
|
||||||
|
|
||||||
# ---> VSCode
|
# ---> VSCode
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM python:slim
|
FROM python:slim
|
||||||
COPY . /usr/src/app
|
COPY . /usr/src/app
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip && pip install -r requirements.txt && \
|
||||||
RUN pip install -r requirements.txt
|
apt-get autoremove -y
|
||||||
CMD python3 -u ./script.py
|
CMD python3 -u ./script.py
|
@ -1 +0,0 @@
|
|||||||
1368349440298409985
|
|
@ -14,7 +14,10 @@ auth = tweepy.OAuthHandler(os.getenv('API_TOKEN'), os.getenv('API_KEY_SECRET'),
|
|||||||
auth.set_access_token(os.getenv('ACCESS_TOKEN'), os.getenv('ACCESS_TOKEN_SECRET'))
|
auth.set_access_token(os.getenv('ACCESS_TOKEN'), os.getenv('ACCESS_TOKEN_SECRET'))
|
||||||
|
|
||||||
api = tweepy.API(auth)
|
api = tweepy.API(auth)
|
||||||
lastSeenFile = '/usr/src/app/last_seen.txt'
|
lastSeenFile = 'last_seen.txt'
|
||||||
|
if not os.path.isfile(lastSeenFile):
|
||||||
|
with open(lastSeenFile, 'w+') as fileWrite:
|
||||||
|
fileWrite.write(str(0))
|
||||||
|
|
||||||
def getLastSeen(filename):
|
def getLastSeen(filename):
|
||||||
with open(filename, 'r') as fileRead:
|
with open(filename, 'r') as fileRead:
|
||||||
@ -41,10 +44,11 @@ def interactions():
|
|||||||
if re.search('what is.*if not.*persevering',tweet.text.lower()):
|
if re.search('what is.*if not.*persevering',tweet.text.lower()):
|
||||||
if not tweet.text.lower().startswith('rt') and tweet.user != api.me():
|
if not tweet.text.lower().startswith('rt') and tweet.user != api.me():
|
||||||
print(f'Tweet {tweet.text} by @{tweet.author.screen_name}', flush = True)
|
print(f'Tweet {tweet.text} by @{tweet.author.screen_name}', flush = True)
|
||||||
if not tweet.favorited:
|
t = api.get_status(tweet.id)
|
||||||
|
if not t.favorited:
|
||||||
print('Not favourited.')
|
print('Not favourited.')
|
||||||
api.create_favorite(tweet.id)
|
api.create_favorite(tweet.id)
|
||||||
if not tweet.retweeted:
|
if not t.retweeted:
|
||||||
print('Not retweeted.')
|
print('Not retweeted.')
|
||||||
api.retweet(tweet.id)
|
api.retweet(tweet.id)
|
||||||
storeLastSeen(lastSeenFile, tweet.id)
|
storeLastSeen(lastSeenFile, tweet.id)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
FROM python:slim
|
FROM python:slim
|
||||||
COPY . /usr/src/app
|
COPY . /usr/src/app
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip && pip install -r requirements.txt && \
|
||||||
RUN pip install -r requirements.txt
|
apt-get autoremove -y
|
||||||
RUN python -m nltk.downloader all
|
RUN python -m nltk.downloader wordnet
|
||||||
CMD python3 -u ./script.py
|
CMD python3 -u ./script.py
|
@ -1 +0,0 @@
|
|||||||
2021-03-19-00:28:14: What is artificial intelligence, if not mucopolysaccharidosis persevering?
|
|
@ -17,7 +17,7 @@ auth.set_access_token(os.getenv('ACCESS_TOKEN'), os.getenv('ACCESS_TOKEN_SECRET'
|
|||||||
api = tweepy.API(auth)
|
api = tweepy.API(auth)
|
||||||
|
|
||||||
def generate_words():
|
def generate_words():
|
||||||
syllables = random.randint(1,sum(1 for file in os.listdir('/usr/src/app/lists')))
|
syllables = random.randint(1,sum(1 for file in os.listdir('lists')))
|
||||||
w1 = get_word(syllables)
|
w1 = get_word(syllables)
|
||||||
w2 = get_word(syllables)
|
w2 = get_word(syllables)
|
||||||
w1_synset = wn.synsets(w1.replace(' ', '_'))[0]
|
w1_synset = wn.synsets(w1.replace(' ', '_'))[0]
|
||||||
@ -31,7 +31,7 @@ def generate_words():
|
|||||||
|
|
||||||
def get_word(syl):
|
def get_word(syl):
|
||||||
fileName = f'{syl}_syllable.txt'
|
fileName = f'{syl}_syllable.txt'
|
||||||
with open(f'/usr/src/app/lists/{fileName}', 'r') as wordList:
|
with open(f'lists/{fileName}', 'r') as wordList:
|
||||||
l = sum(1 for line in wordList) - 1
|
l = sum(1 for line in wordList) - 1
|
||||||
c = random.randint(0,l)
|
c = random.randint(0,l)
|
||||||
wordList.seek(0)
|
wordList.seek(0)
|
||||||
@ -49,7 +49,7 @@ def posting():
|
|||||||
output = f'What is {words[0]} if not {words[1]} persevering?'
|
output = f'What is {words[0]} if not {words[1]} persevering?'
|
||||||
print(output)
|
print(output)
|
||||||
api.update_status(output)
|
api.update_status(output)
|
||||||
with open('/usr/src/app/post_log.txt', 'a') as logFile:
|
with open('post_log.txt', 'a+') as logFile:
|
||||||
logFile.write(f'{datetime.now().strftime("%Y-%m-%d-%X")}: {output}\n')
|
logFile.write(f'{datetime.now().strftime("%Y-%m-%d-%X")}: {output}\n')
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
Loading…
Reference in New Issue
Block a user