Created
March 24, 2020 00:31
-
-
Save Shugabuga/b945fa10714d44577be1012abba525a0 to your computer and use it in GitHub Desktop.
Randomly pick a certain amount of users for a retweet raffle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Run this command to go: | |
# python3 raffle.py <count> <tweetId> | |
import requests | |
import base64, urllib, time | |
from io import BytesIO | |
import twitter | |
from random import randint | |
import sys | |
print("Raffle Drawer - by Shuga\n") | |
max = 999 | |
count = 5 | |
post = "1241834306898735106" | |
try: | |
if sys.argv[1] != '': | |
count = int(sys.argv[1]) | |
except: | |
pass | |
try: | |
if sys.argv[2] != '': | |
post = sys.argv[2] | |
except: | |
pass | |
# Put your tokens here! | |
api = twitter.Api(consumer_key='', | |
consumer_secret='', | |
access_token_key='', | |
access_token_secret='') | |
def userGet(user): | |
print(f"@{user.screen_name}: {user.description}") | |
def random(statuses): | |
random = randint(0, len(statuses)-1) | |
userGet(statuses[random]) | |
def check(): | |
ls = [] | |
print("...and the winners are:") | |
statuses = api.GetRetweets(post, count=max, trim_user=False) | |
for status in statuses: | |
ls.append(status.user) | |
for i in range(0, count): | |
random(ls) | |
check() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment