Created
March 12, 2010 18:27
-
-
Save rafapolo/330591 to your computer and use it in GitHub Desktop.
twitter social bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby19 | |
# encoding: utf8 | |
# author: rafael polo | |
# created_at 11.mar.2010 | |
# updated_at 12.mar.2010 | |
require File.join(File.dirname(__FILE__), 'Entendedor.rb') | |
require 'rubygems' | |
require 'twitter' | |
@config = YAML::load(File.open('config.yml')) | |
httpauth = Twitter::HTTPAuth.new(@config['user'], @config['passwd']) | |
@fulano = Twitter::Base.new(httpauth) | |
def faz(termo) | |
pesquisa = @config[termo] | |
mensagens = Twitter::Search.new(pesquisa) | |
termo.gsub!('"', '') | |
mensagens.each do |msg| | |
if onde = Entendedor.praOnde(msg, termo) | |
tambem = @config['tambem'][rand(@config['tambem'].size)+1] | |
vou = ("@#{msg.from_user}: #{tambem} Eu também tô indo #{termo} #{onde}. Te encontro lá!") | |
nao_vou = ("@#{msg.from_user}: #{tambem} Eu também não vou mais #{termo} #{onde}. Fica pra próxima!") | |
digo = Entendedor.naoVou?(msg, termo) ? nao_vou : vou | |
#puts digo if digo.length<=140 | |
@fulano.update(digo) if digo.length<=140 | |
end | |
end | |
end | |
faz('pro') | |
faz('pra') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment