Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.58 KB | None | 0 0
  1. def process_mentions()
  2.     mentions = find_mentions(last_processed_id())
  3.     @highest_id_processed_locally = 0
  4.    
  5.     mentions.each do |m|
  6.         id = 0 #test value
  7.         @highest_id_processed_locally = id if id > last_processed_id()
  8.        
  9.         DATABASE.set("last_processed_id", @highest_id_processed_locally)
  10.        
  11.         text = m.text.strip.downcase
  12.         user = m.user.screen_name
  13.         id = m.id
  14.         reply = "@" + user
  15.        
  16.         if text == "all"
  17.             reply << "You're marked in the queue as eligible for all future games." +
  18.             "If you ever change your mind, just reply to any tweet of mine with 'remove'"
  19.            
  20.             player_to_db(id, user, 1)
  21.         elsif text == "remove"
  22.             reply << "You've been removed from the queue of future eligible players. If" +
  23.             " you're in an existing game, that game will still complete first as normal." +
  24.             "Reply to one of my tweets again if you ever want to be readded!"
  25.  
  26.             hashname = "eligible_player_" + id
  27.             DATABASE.del(hashname)
  28.         else
  29.             reply << "You've been added to the queue as eligible for future games! You'll" +
  30.             "remain eligible for the next week. Reply with 'all' to stay eligible forever, or" +
  31.             "'remove' to be removed from the queue."
  32.             # add this player to redis with expirary of one week
  33.            
  34.             player_to_db(id, user, 0)
  35.         end
  36.        
  37.         options = { in_reply_to_status_id: id }
  38.         #client.update(reply, options)
  39.  
  40.     end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement