PDA

View Full Version : bash twitter autofollow script



rob-beatz
09-22-2009, 09:40 PM
based on afterlife's script from http://digitalgangster.com/4um/showthread.php?t=80412. the script in that thread is missing the pipes and the pastebin's were expired so i rewrote it.

you'll need a linux box with:
curl: http://curl.haxx.se OR sudo apt-get install curl
&
sgrep: http://www.cs.helsinki.fi/u/jjaakkol/sgrep/download.html OR sudo apt-get install sgrep



#!/bin/bash
# twitch.sh - twitter auto follower
# USAGE: ./twitch.sh #.to.follow username-or-email password "message to send"
# EXAMPLE: ./twitch.sh 2000 BigHairyBalls cumsquirter "ooh yeah i came on my grandma"
#
# maximum number of users to follow is 2000 per day per account
#

ErrorMessage="Put the number of follows you want after the script, followed by a username, password and status message\n\n EXAMPLE: ./twitch.sh 2000 BigHairyBalls@gmail.com cumsquirter \"ooh yeah i came on my grandma\"\n"
# input error checking
[ $1 -le 0 ] && { echo -e "The amount of followers must be a number greater than zero.\n\n" $ErrorMessage; exit 1; } || [ ! -n "$2" ] && { echo -e $ErrorMessage; exit 1; } || [ ! -n "$3" ] && { echo -e $ErrorMessage; exit 1; } || [ ! -n "$4" ] && { echo -e $ErrorMessage; exit 1; } || clear
Amount2Follow=`echo $1`
status=`echo $4`
abspath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
scriptpath=`dirname "$abspath"`
[ ! -d $scriptpath/namelists ] && mkdir $scriptpath/namelists
[ ! -d $scriptpath/tmp ] && mkdir $scriptpath/tmp

touch $scriptpath/this.cnl
amount=`cat $scriptpath/this.cnl | wc -l`
while [ "$amount" -le "$(( $1 + 1 ))" ]
do

# grab recent tweeters and put 'em in a list
wget -q http://twitter.com/public_timeline
# get latest tweeters from twitter.com/public_timeline
sgrep -o "%r\n" '"<strong><a href=\"http://twitter.com/" __ "\" class=\"tweet-url"' public_timeline > $scriptpath/tmp/onepass.txt
# get the @'s from the latest tweeters
sgrep -o "%r\n" '"username\" href=\"/" __ "\">"' public_timeline > $scriptpath/tmp/twopass.txt

#combine the lists
cnl=$scriptpath/namelists/current.txt
cat $scriptpath/tmp/onepass.txt > $cnl
cat $scriptpath/tmp/twopass.txt >> $cnl
cat $cnl >> $scriptpath/namelists/allusernames.list
cat $cnl >> $scriptpath/this.cnl

# get loose with it. let bruce bruce hit it
number=`cat $cnl | wc -l`

for (( i=1; i<=number; i++ ))
do

user=`cat $cnl | sed -n $i'p'`
curl -s -u $2:$3 -d "status=/follow $user" http://twitter.com/statuses/update.xml -o /dev/null
echo "now following "$i "of" $number
done
# let new people tweet
sleep 60
cp $cnl $cnl.bak
rm $cnl
rm $scriptpath/public_timeline
done

#status update
#curl -s -u $2:$3 -d status="$status" http://twitter.com/statuses/update.xml -o /dev/null


rm $scriptpath/tmp/*
rm $scriptpath/this.cnl


notes:
line 50: sleep 60 . you can comment this out or remove it if you want the script to go faster. without it the script would sometimes try to follow the same list of usernames.

line 57: remove the # to post your status updates.

16oz
09-23-2009, 07:47 AM
This looks real real nice, so im assuming you auto-follow in hopes that users will follow you back?

thanks for the up

xevonaute
09-23-2009, 11:39 AM
You can get Twitter FriendAdder Pro 3.4.0 , do a better job (random time for addfriend, possiblity to send text qui random part etc... )There is a 2 use trial, but you can run it in a VM or a crack somewhere I can't remember.

dacks
09-29-2009, 08:58 AM
erm...

./twit-add.sh: line 11: [: -le: unary operator expected