If been working on a twitter bot for a while now, just for fun, but I've been stuck with this single problem. Sometimes it works, sometimes it does not. Here is the code:
def teste():
tweets = api.home_timeline(2, read_id(FILE_NAME), tweet_mode = 'extended')
print('Setup is ok!')
for tweet in reversed(tweets):
if 'carente' in tweet.full_text.lower():
print(str(tweet.id) + ' - ' + tweet.full_text)
api.retweet(tweet.id)
store_the_id(FILE_NAME, tweet.id)
teste.x = 1
elif 'carente' not in tweet.full_text.lower():
teste.x = 0
else:
print('Error no sistema alguem me desconfiguro')
def tweet_timer():
if time.gmtime().tm_min == '10':
api.update_status(f'Farid esteve carente {y} vezes')
else:
return
while True:
teste()
with open('number.txt', 'r') as f:
read = f.readline
z = int(read())
y = z + teste.x
print(y)
with open('number.txt', 'w') as f:
write = f.write(str(y))
write
tweet_timer()
time.sleep(40)
I'm trying access the teste.x variable out of the function, but when I do at the y = z + teste.x it gives the following error:
Traceback (most recent call last):
File "c:\Users\fredg\Desktop\Programação\Python\Twitter Bot\Website\Word.py", line 69, in <module>
y = z + teste.x
AttributeError: 'function' object has no attribute 'x'