79 lines
1.9 KiB
Python
79 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from time import sleep
|
|
from mykeys import *
|
|
from datetime import date
|
|
import random
|
|
import tweepy
|
|
|
|
lastdate = date(1,1,1)
|
|
|
|
def load():
|
|
global lastdate
|
|
|
|
datelog = open('datelog.txt', 'r')
|
|
try:
|
|
strdate = datelog.readline().split('-')
|
|
lastdate = date(strdate[0],strdate[1],strdate[2])
|
|
print('Log succesfully read.')
|
|
print('Date of last change: ' + str(lastdate))
|
|
except:
|
|
print('Reading log failed!')
|
|
datelog.close()
|
|
print('---')
|
|
|
|
def pickname():
|
|
name = None
|
|
namelist = None
|
|
namelist = open('namelist.txt', 'r')
|
|
print('Reading namelist...')
|
|
try:
|
|
names = namelist.readlines()
|
|
print('Success. Names list:')
|
|
print('\n'.join(names))
|
|
except:
|
|
print('Reading namelist failed!')
|
|
namelist.close()
|
|
if namelist is not None:
|
|
name = random.choice(names)
|
|
print('Choosen name:' + name)
|
|
|
|
print('---')
|
|
return name
|
|
|
|
def changename(api):
|
|
global lastdate
|
|
print('Checking date...')
|
|
change = (lastdate != date.today())
|
|
print('Is change due? ' + str(change))
|
|
|
|
if change:
|
|
name = pickname()
|
|
print('Updating profile...')
|
|
api.update_profile(name=name)
|
|
print('Updating date...')
|
|
lastdate = date.today()
|
|
print('Updating log...')
|
|
datelog = open('datelog.txt', 'w')
|
|
datelog.write(str(lastdate))
|
|
print('Updated log. New date: ' + str(lastdate))
|
|
datelog.close()
|
|
print('---')
|
|
|
|
def main():
|
|
global lastdate
|
|
print('Starting the Vilius CIM Name Changer...')
|
|
|
|
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
|
auth.set_access_token(access_token, access_token_secret)
|
|
api = tweepy.API(auth)
|
|
print('Done.')
|
|
print('Reading log...')
|
|
load()
|
|
|
|
while True:
|
|
changename(api)
|
|
sleep(3600)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|