-
Notifications
You must be signed in to change notification settings - Fork 0
/
poc.py
47 lines (36 loc) · 1.22 KB
/
poc.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
# -*- coding: utf-8 -*-
import tweepy
import conf
import subprocess
import time
#Auth and create acces for application
auth = tweepy.OAuthHandler(conf.consumer_key, conf.consumer_secret)
auth.set_access_token(conf.access_token, conf.access_token_secret)
#Create acces application, only 1 time !
#auth.get_authorization_url()
#Copy url and paste into browser with your bot twitter account !
#Copy PIN Code
#pin_code = "ENTER PIN CODE HERE"
#auth.get_access_token(pin_code)
#Get Api !
api = tweepy.API(auth)
#Get the current version of git repository
current_git_version = subprocess.check_output(["git", "rev-parse", "HEAD"])
try:
#Execute code
#Sending welcome message
api.update_status(u"J'ouvre ma boutique ! (version : %s)" %current_git_version)
while True:
#Get message to mentions timeline (20 last)
for tweet in api.mentions_timeline():
if tweet.retweeted == False:
#Send message
api.update_status("Salut @%s" %tweet.user.screen_name)
tweet.retweet()
else:
pass
#Wait 25 seconds
time.sleep(25)
except KeyboardInterrupt:
#Send message and exit
api.update_status(u"Je ferme la boutique !")