Initial commit
This commit is contained in:
commit
f5315468ab
3 changed files with 92 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
mykeys.py
|
||||
datelog.txt
|
||||
__pycache__/*
|
79
main.py
Normal file
79
main.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/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()
|
10
namelist.txt
Normal file
10
namelist.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
vilius
|
||||
voltios
|
||||
billón
|
||||
billar
|
||||
balneario
|
||||
bilipendiado
|
||||
voltaren
|
||||
billion with a B
|
||||
10^9 (EN)
|
||||
10^12 (ES)
|
Reference in a new issue