Compare commits
No commits in common. "master" and "2f10edc3f9b2a06a2658aa062a4f8f356bb24830" have entirely different histories.
master
...
2f10edc3f9
@ -1,6 +0,0 @@
|
||||
BOT_VERSION=3.1
|
||||
BEARER_TOKEN=
|
||||
ACCESS_TOKEN=
|
||||
ACCESS_TOKEN_SECRET=
|
||||
API_TOKEN=
|
||||
API_KEY_SECRET=
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,3 @@
|
||||
# Log Files
|
||||
interaction/last_seen.txt
|
||||
posting/post_log.txt
|
||||
|
||||
# ---> VSCode
|
||||
.vscode/
|
||||
|
||||
|
@ -66,7 +66,7 @@ You will need to create your own `.env` files to store these values, and have mu
|
||||
`.env` file(s):
|
||||
|
||||
```
|
||||
BOT_VERSION=3.1
|
||||
BOT_VERSION=3.0
|
||||
BEARER_TOKEN=
|
||||
ACCESS_TOKEN=
|
||||
ACCESS_TOKEN_SECRET=
|
||||
|
@ -1,30 +1,28 @@
|
||||
version: '3.9'
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
interaction:
|
||||
perseveringbot-int:
|
||||
build: ./interaction
|
||||
container_name: vision_interaction
|
||||
volumes:
|
||||
- ./interaction:/usr/src/app
|
||||
restart: unless-stopped
|
||||
restart: always
|
||||
environment:
|
||||
- BOT_VERSION
|
||||
- BEARER_TOKEN
|
||||
- ACCESS_TOKEN
|
||||
- ACCESS_TOKEN_SECRET
|
||||
- API_TOKEN
|
||||
- API_KEY_SECRET
|
||||
|
||||
posting:
|
||||
- BOT_VERSION=${BOT_VERSION}
|
||||
- BEARER_TOKEN=${BEARER_TOKEN}
|
||||
- ACCESS_TOKEN=${ACCESS_TOKEN}
|
||||
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
|
||||
- API_TOKEN=${API_TOKEN}
|
||||
- API_KEY_SECRET=${API_KEY_SECRET}
|
||||
perseveringbot-pos:
|
||||
build: ./posting
|
||||
container_name: vision_posting
|
||||
volumes:
|
||||
- ./posting:/usr/src/app
|
||||
restart: unless-stopped
|
||||
restart: always
|
||||
environment:
|
||||
- BOT_VERSION
|
||||
- BEARER_TOKEN
|
||||
- ACCESS_TOKEN
|
||||
- ACCESS_TOKEN_SECRET
|
||||
- API_TOKEN
|
||||
- API_KEY_SECRET
|
||||
- BOT_VERSION=${BOT_VERSION}
|
||||
- BEARER_TOKEN=${BEARER_TOKEN}
|
||||
- ACCESS_TOKEN=${ACCESS_TOKEN}
|
||||
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
|
||||
- API_TOKEN=${API_TOKEN}
|
||||
- API_KEY_SECRET=${API_KEY_SECRET}
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM python:slim
|
||||
FROM python:3.8.6-buster
|
||||
COPY . /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
RUN pip install --upgrade pip && pip install -r requirements.txt && \
|
||||
apt-get autoremove -y
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
CMD python3 -u ./script.py
|
1
interaction/last_seen.txt
Normal file
1
interaction/last_seen.txt
Normal file
@ -0,0 +1 @@
|
||||
1368349440298409985
|
@ -1,4 +1,4 @@
|
||||
#!/usr/local/bin/python3.9
|
||||
#!/usr/local/bin/python3.8
|
||||
import tweepy
|
||||
import time
|
||||
import os
|
||||
@ -14,10 +14,7 @@ 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 = 'last_seen.txt'
|
||||
if not os.path.isfile(lastSeenFile):
|
||||
with open(lastSeenFile, 'w+') as fileWrite:
|
||||
fileWrite.write(str(0))
|
||||
lastSeenFile = '/usr/src/app/last_seen.txt'
|
||||
|
||||
def getLastSeen(filename):
|
||||
with open(filename, 'r') as fileRead:
|
||||
@ -32,25 +29,24 @@ def storeLastSeen(filename, lastSeen):
|
||||
def searchTweets(query):
|
||||
print('Searching for tweets')
|
||||
lastSeen = getLastSeen(lastSeenFile)
|
||||
tweets = api.search_tweets(query, since_id=lastSeen)
|
||||
tweets = api.search(query, since_id=lastSeen)
|
||||
return tweets
|
||||
|
||||
def interactions():
|
||||
tweets = searchTweets('persevering')
|
||||
for tweet in reversed(tweets):
|
||||
if not tweets:
|
||||
print('No new tweets found.')
|
||||
return
|
||||
for tweet in reversed(tweets):
|
||||
if re.search('what is.*if not.*persevering',tweet.text.lower()):
|
||||
if not tweet.text.lower().startswith('rt') and tweet.user != api.verify_credentials():
|
||||
if not tweet.text.lower().startswith('rt') and tweet.user != api.me():
|
||||
print(f'Tweet {tweet.text} by @{tweet.author.screen_name}', flush = True)
|
||||
t = api.get_status(tweet.id)
|
||||
if not t.favorited:
|
||||
if not tweet.favorited:
|
||||
print('Not favourited.')
|
||||
api.create_favorite(tweet.id)
|
||||
if not t.retweeted:
|
||||
# api.create_favorite(tweet.id)
|
||||
if not tweet.retweeted:
|
||||
print('Not retweeted.')
|
||||
api.retweet(tweet.id)
|
||||
# api.retweet(tweet.id)
|
||||
storeLastSeen(lastSeenFile, tweet.id)
|
||||
|
||||
now = datetime.now()
|
||||
|
@ -1,7 +1,7 @@
|
||||
FROM python:slim
|
||||
FROM python:3.8.6-buster
|
||||
COPY . /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
RUN pip install --upgrade pip && pip install -r requirements.txt && \
|
||||
apt-get autoremove -y
|
||||
RUN python -m nltk.downloader wordnet
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
RUN python -m nltk.downloader all
|
||||
CMD python3 -u ./script.py
|
1
posting/post_log.txt
Normal file
1
posting/post_log.txt
Normal file
@ -0,0 +1 @@
|
||||
2021-03-19-00:28:14: What is artificial intelligence, if not mucopolysaccharidosis persevering?
|
@ -1,4 +1,4 @@
|
||||
#!/usr/local/bin/python3.9
|
||||
#!/usr/local/bin/python3.8
|
||||
import tweepy
|
||||
import time
|
||||
import os
|
||||
@ -17,7 +17,7 @@ auth.set_access_token(os.getenv('ACCESS_TOKEN'), os.getenv('ACCESS_TOKEN_SECRET'
|
||||
api = tweepy.API(auth)
|
||||
|
||||
def generate_words():
|
||||
syllables = random.randint(1,sum(1 for file in os.listdir('lists')))
|
||||
syllables = random.randint(1,sum(1 for file in os.listdir('/usr/src/app/lists')))
|
||||
w1 = get_word(syllables)
|
||||
w2 = get_word(syllables)
|
||||
w1_synset = wn.synsets(w1.replace(' ', '_'))[0]
|
||||
@ -31,7 +31,7 @@ def generate_words():
|
||||
|
||||
def get_word(syl):
|
||||
fileName = f'{syl}_syllable.txt'
|
||||
with open(f'lists/{fileName}', 'r') as wordList:
|
||||
with open(f'/usr/src/app/lists/{fileName}', 'r') as wordList:
|
||||
l = sum(1 for line in wordList) - 1
|
||||
c = random.randint(0,l)
|
||||
wordList.seek(0)
|
||||
@ -46,10 +46,10 @@ def get_word(syl):
|
||||
|
||||
def posting():
|
||||
words = generate_words()
|
||||
output = f'What is {words[0]} if not {words[1]} persevering?'
|
||||
output = f'What is {words[0]}, if not {words[1]} persevering?'
|
||||
print(output)
|
||||
api.update_status(output)
|
||||
with open('post_log.txt', 'a+') as logFile:
|
||||
# api.update_status(output)
|
||||
with open('/usr/src/app/post_log.txt', 'a') as logFile:
|
||||
logFile.write(f'{datetime.now().strftime("%Y-%m-%d-%X")}: {output}\n')
|
||||
|
||||
now = datetime.now()
|
||||
|
Loading…
Reference in New Issue
Block a user