# -*- coding: utf-8 -*-
import datetime
from datetime import timedelta, date
import random
twitfilename = 'tweets.txt'
A = 10 # начало интервала (час) постинга. Во сколько "просыпается" бот. Минимум 10.
B = 23 # конец интервала (час) постинга. Во сколько "засыпает бот.
N = 5 # кол-во твитов в день.
with open( twitfilename) as input_file:
strok = len( input_file.readlines ( ) )
okrug = strok // N
howmuchdayswenee = okrug * N + N
def daterange( start, stop, step= datetime.timedelta ( days= 1 ) , inclusive= True) :
if step.days > 0 :
while start < stop:
yield start
start = start + step
elif step.days < 0 :
while start > stop:
yield start
start = start + step
if inclusive and start == stop:
yield start
start_date = date.today ( )
end_date = date.today ( ) + timedelta( days= howmuchdayswenee)
dates = [ x for x in daterange( start_date,
end_date,
step= timedelta( days= 1 ) ,
inclusive= True) ]
datelist = [ ] # создаем пустой список для дат
for dayz in dates:
addstr = str( dayz) + ' ' + str( random.randint ( A, B) ) + ':' + str( random.randint ( 10 , 20 ) )
datelist.append ( addstr)
addstr = str( dayz) + ' ' + str( random.randint ( A, B) ) + ':' + str( random.randint ( 21 , 30 ) )
datelist.append ( addstr)
addstr = str( dayz) + ' ' + str( random.randint ( A, B) ) + ':' + str( random.randint ( 31 , 40 ) )
datelist.append ( addstr)
addstr = str( dayz) + ' ' + str( random.randint ( A, B) ) + ':' + str( random.randint ( 41 , 50 ) )
datelist.append ( addstr)
addstr = str( dayz) + ' ' + str( random.randint ( A, B) ) + ':' + str( random.randint ( 51 , 59 ) )
datelist.append ( addstr)
srez = datelist[ 0 : strok] # оставляем кол-во дат равное кол-ву строк, т.е. твитов
with open( twitfilename) as input_file:
j = 0
for line in input_file:
print( '\" ' + str( srez[ j] ) + '\" ,\" ' + str( line.strip ( ) ) + '\" ,0' ) # тут даты соединяются с твитами
j += 1
IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KaW1wb3J0IGRhdGV0aW1lCmZyb20gZGF0ZXRpbWUgaW1wb3J0IHRpbWVkZWx0YSwgZGF0ZQppbXBvcnQgcmFuZG9tCg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