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:
2021-08-06 10:06:19 +01:00
parent 272ecf80a5
commit 356bbbc5c9
7 changed files with 19 additions and 13 deletions

View File

@ -1,6 +1,6 @@
FROM python:slim
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt && \
apt-get autoremove -y
CMD python3 -u ./script.py

View File

@ -1 +0,0 @@
1368349440298409985

View File

@ -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'))
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):
with open(filename, 'r') as fileRead:
@ -41,10 +44,11 @@ def interactions():
if re.search('what is.*if not.*persevering',tweet.text.lower()):
if not tweet.text.lower().startswith('rt') and tweet.user != api.me():
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.')
api.create_favorite(tweet.id)
if not tweet.retweeted:
if not t.retweeted:
print('Not retweeted.')
api.retweet(tweet.id)
storeLastSeen(lastSeenFile, tweet.id)