-
Notifications
You must be signed in to change notification settings - Fork 51
/
mainbot.py
40 lines (28 loc) · 1.34 KB
/
mainbot.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
import tweepy
import os # operating system library
def create_api():
consumer_key = os.getenv('consumer_key')
consumer_secret = os.getenv('consumer_secret')
access_token = os.getenv('access_token')
access_token_secret = os.getenv('access_token_secret')
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth,wait_on_rate_limit=True,wait_on_rate_limit_notify=True)
api.verify_credentials()
print('API Created')
return api
# Complete code
import time
def follower_count(user):
emoji_numbers = {0: "0️⃣", 1: "1️⃣", 2: "2️⃣", 3: "3️⃣",
4: "4️⃣", 5: "5️⃣", 6: "6️⃣", 7: "7️⃣", 8: "8️⃣", 9: "9️⃣"}
uf_split = [int(i) for i in str(user.followers_count)]# Used to seperate
emoji_followers = ''.join([emoji_numbers[j] for j in uf_split if j in emoji_numbers.keys()])
return emoji_followers
api = create_api()
while True:
user = api.get_user('Ameen91741779')
api.update_profile(name=f'ameen|{follower_count(user)} Followers')
print(f'Updating Twitter Name : ameen|{follower_count(user)} Followers')
print('Waiting to refresh')
time.sleep(60)