-
Notifications
You must be signed in to change notification settings - Fork 3
/
comptedown.py
60 lines (48 loc) · 1.77 KB
/
comptedown.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import unittest
import random
import datetime
from time import sleep
import os
from tweepy import *
"""Configurations"""
# Vous devez fournir les informations d'identification de votre application twitter
consumer_key = CONSUMERKEY
consumer_secret = CONSUMERSECRET
auth = OAuthHandler(consumer_key, consumer_secret)
# test pour avoir accès au token
auth_url = auth.get_authorization_url()
print 'S\'il vous plaît autoriser: ' + auth_url
verifier = raw_input('Entrer le code PIN: ').strip()
access_token = auth.get_access_token(verifier)
# construction de l'objet api en utilisant oauth
api = API(auth)
for tweet in range(1,100): # Boucle 100 fois
Date=datetime.datetime(2011,03,25,20,30,00,0)
now = datetime.datetime.now()
diff = Date-now
print diff
#dateformat = str(diff.strftime('%H:%M:%S'))
s = diff.seconds+3600
# hours
hours = s // 3600
# remaining seconds
s = s - (hours * 3600)
# minutes
minutes = s // 60
# remaining seconds
seconds = s - (minutes * 60)
# total time
if hours >0:
s = api.update_status('%sh:%smn:%ss Avant le [DakarLUG] GeekDinner #dakarlug #linux #dakar #senegal #fb' % (hours, minutes, seconds)) #statut
sleep(600) # attendre 600 s
else:
if minutes > 0 :
s = api.update_status('%smn:%ss Avant le [DakarLUG] GeekDinner #dakarlug #linux #dakar #senegal #fb' % (minutes, seconds)) #statut
sleep(300) # attendre 300 s
else:
if s > 0 :
s = api.update_status('%ss Avant le [DakarLUG] GeekDinner #dakarlug #linux #dakar #senegal #fb' % (seconds)) #statut
sleep(30) # attendre 30 s
else:
break
print tweet