Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding deined auth handing. adding config randomize frequency (expect…

…ed as minutes if using every minute cron job). remove commented out line in home view.
  • Loading branch information...
commit dd99b2f140fb61fe608b0a627d326b147a2a39ce 1 parent 005e931
@gleuch authored
Showing with 36 additions and 30 deletions.
  1. +34 −28 retweet.rb
  2. +2 −1  settings.yml.default
  3. +0 −1  views/home.haml
View
62 retweet.rb
@@ -119,36 +119,43 @@ def launch_retweet_hell
# Callback URL to return to after talking with Twitter
get '/auth' do
@title = 'Authenticate with Twitter'
+
+
- twitter_connect
- @access_token = @twitter_client.authorize(session[:request_token], session[:request_token_secret], :oauth_verifier => params[:oauth_verifier])
+ unless params[:denied].blank?
+ @error = "We are sorry that you decided to not use #{configatron.site_name}. <a href=\"/\">Click</a> to return."
+ haml :fail
+ else
+ twitter_connect
+ @access_token = @twitter_client.authorize(session[:request_token], session[:request_token_secret], :oauth_verifier => params[:oauth_verifier])
- if @twitter_client.authorized?
- begin
- info = @twitter_client.info
- rescue
- twitter_fail and return
- end
+ if @twitter_client.authorized?
+ begin
+ info = @twitter_client.info
+ rescue
+ twitter_fail and return
+ end
- @user = User.first_or_create(:account_id => info['id'])
- @user.update_attributes(:account_id => info['id'], :screen_name => info['screen_name'], :oauth_token => @access_token.token, :oauth_secret => @access_token.secret)
-
- # Set and clear session data
- session[:user] = @user.id
- session[:account] = @user.account_id
- session[:request_token] = nil
- session[:request_token_secret] = nil
-
- begin
- twitter_connect(@user)
- @twitter_client.update("#{configatron.twitter_sync_tweet} #{configatron.twitter_hashtag}")
- @twitter_client.friend(configatron.twitter_screen_name)
- rescue
- twitter_fail('An error has occured while trying to post a tweet to Twitter. Please try again.')
+ @user = User.first_or_create(:account_id => info['id'])
+ @user.update_attributes(:account_id => info['id'], :screen_name => info['screen_name'], :oauth_token => @access_token.token, :oauth_secret => @access_token.secret)
+
+ # Set and clear session data
+ session[:user] = @user.id
+ session[:account] = @user.account_id
+ session[:request_token] = nil
+ session[:request_token_secret] = nil
+
+ begin
+ twitter_connect(@user)
+ @twitter_client.update("#{configatron.twitter_sync_tweet} #{configatron.twitter_hashtag}")
+ @twitter_client.friend(configatron.twitter_screen_name)
+ rescue
+ twitter_fail('An error has occured while trying to post a tweet to Twitter. Please try again.')
+ end
end
- end
- redirect '/'
+ redirect '/'
+ end
end
# Launch retweet hell...
@@ -157,9 +164,8 @@ def launch_retweet_hell
launch = true
# Randomized retweet hell if running a cron job (recommended to use '*/1 * * * * curl -s http://example.com/run/----')
- if configatron.randomize_hell
- rand_hell = rand(30).round # Expected randomization every 30 minutes.
- unless rand_hell == 1
+ if configatron.randomize_hell && configatron.randomize_hell_freq.is_a?(Integer)
+ unless rand(configatron.randomize_hell_freq).round == 1
@error = "Waiting patiently for a truely randomized hell."
launch = false
end
View
3  settings.yml.default
@@ -1,7 +1,8 @@
development: &local
site_name: Retweet Game
- randomize_hell: true
+ randomize_hell: false
+ randomize_hell_freq: 30
secret_launch_code: FFFFFAT
twitter_oauth_token: ENTER-YOUR-TOKEN-HERE
View
1  views/home.haml
@@ -1,5 +1,4 @@
%h1 Expand your Twitter reach through mass retweets #{configatron.twitter_allow_user_follow ? 'and followings' : ''} by joining #{configatron.site_name}.
-/ %h1 Spread your internet famo by connecting your Twitter account to the #{configatron.site_name} flock.
%p.button
%a.button{:href => "/connect"} Connect to Twitter now!
%p.small Connect your Twitter account and earn the chance to increase your tweet broadcast through retweets #{configatron.twitter_allow_user_follow ? 'and follows' : ''} by other #{configatron.site_name} users.
Please sign in to comment.
Something went wrong with that request. Please try again.