Make sure we really have the right username
This commit is contained in:
		
							parent
							
								
									171dbea382
								
							
						
					
					
						commit
						5617544a30
					
				
					 1 changed files with 13 additions and 7 deletions
				
			
		| 
						 | 
					@ -26,7 +26,7 @@ module Ebooks
 | 
				
			||||||
    # Make an informed guess as to whether a user is a bot based
 | 
					    # Make an informed guess as to whether a user is a bot based
 | 
				
			||||||
    # on their behavior in this conversation
 | 
					    # on their behavior in this conversation
 | 
				
			||||||
    def is_bot?(username)
 | 
					    def is_bot?(username)
 | 
				
			||||||
      usertweets = @tweets.select { |t| t.user.screen_name == username }
 | 
					      usertweets = @tweets.select { |t| t.user.screen_name.downcase == username.downcase }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if usertweets.length > 2
 | 
					      if usertweets.length > 2
 | 
				
			||||||
        if (usertweets[-1].created_at - usertweets[-3].created_at) < 30
 | 
					        if (usertweets[-1].created_at - usertweets[-3].created_at) < 30
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ module Ebooks
 | 
				
			||||||
    # We want to avoid spamming non-participating users
 | 
					    # We want to avoid spamming non-participating users
 | 
				
			||||||
    def can_include?(username)
 | 
					    def can_include?(username)
 | 
				
			||||||
      @tweets.length <= 4 ||
 | 
					      @tweets.length <= 4 ||
 | 
				
			||||||
        !@tweets[-4..-1].select { |t| t.user.screen_name == username }.empty?
 | 
					        !@tweets[-4..-1].select { |t| t.user.screen_name.downcase == username.downcase }.empty?
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,18 +220,18 @@ module Ebooks
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if ev.is_a? Twitter::DirectMessage
 | 
					      if ev.is_a? Twitter::DirectMessage
 | 
				
			||||||
        return if ev.sender.screen_name == @username # Don't reply to self
 | 
					        return if ev.sender.screen_name.downcase == @username.downcase # Don't reply to self
 | 
				
			||||||
        log "DM from @#{ev.sender.screen_name}: #{ev.text}"
 | 
					        log "DM from @#{ev.sender.screen_name}: #{ev.text}"
 | 
				
			||||||
        fire(:direct_message, ev)
 | 
					        fire(:direct_message, ev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      elsif ev.respond_to?(:name) && ev.name == :follow
 | 
					      elsif ev.respond_to?(:name) && ev.name == :follow
 | 
				
			||||||
        return if ev.source.screen_name == @username
 | 
					        return if ev.source.screen_name.downcase == @username.downcase
 | 
				
			||||||
        log "Followed by #{ev.source.screen_name}"
 | 
					        log "Followed by #{ev.source.screen_name}"
 | 
				
			||||||
        fire(:follow, ev.source)
 | 
					        fire(:follow, ev.source)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      elsif ev.is_a? Twitter::Tweet
 | 
					      elsif ev.is_a? Twitter::Tweet
 | 
				
			||||||
        return unless ev.text # If it's not a text-containing tweet, ignore it
 | 
					        return unless ev.text # If it's not a text-containing tweet, ignore it
 | 
				
			||||||
        return if ev.user.screen_name == @username # Ignore our own tweets
 | 
					        return if ev.user.screen_name.downcase == @username.downcase # Ignore our own tweets
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        meta = meta(ev)
 | 
					        meta = meta(ev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,7 +283,13 @@ module Ebooks
 | 
				
			||||||
        exit 1
 | 
					        exit 1
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      twitter
 | 
					      real_name = twitter.user.screen_name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if real_name != @username
 | 
				
			||||||
 | 
					        log "connected to @#{real_name}-- please update config to match Twitter account name"
 | 
				
			||||||
 | 
					        @username = real_name
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      fire(:startup)
 | 
					      fire(:startup)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -318,7 +324,7 @@ module Ebooks
 | 
				
			||||||
    # @param username [String]
 | 
					    # @param username [String]
 | 
				
			||||||
    # @return [Boolean]
 | 
					    # @return [Boolean]
 | 
				
			||||||
    def blacklisted?(username)
 | 
					    def blacklisted?(username)
 | 
				
			||||||
      if @blacklist.include?(username)
 | 
					      if @blacklist.map(&:downcase).include?(username.downcase)
 | 
				
			||||||
        true
 | 
					        true
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
        false
 | 
					        false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue