Skip to content

Instantly share code, notes, and snippets.

@Shugabuga

Shugabuga/raffle.py

Created Mar 24, 2020
Embed
What would you like to do?
Randomly pick a certain amount of users for a retweet raffle.
#!/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
You can’t perform that action at this time.