<commit_before>require 'net/http'
require 'rexml/document'

class Tweets < Dumbstore::App
	name 'Dumb Tweets'
	author '<NAME>'
	author_url 'http://github.com/antoinedc'
	description <<-DESCRIPTION
	Get the latest tweets from a user.<br />
	Format: <code>tweets [username]</code><br />
	Example: <code>tweets twitter</code>
	DESCRIPTION
	text_id 'tweets'

	def tweets params
		username = params['Body']
		url = "http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=" + username
		xml_data = Net::HTTP.get_response(URI.parse(url)).body
		doc = REXML::Document.new(xml_data)
		tweets = []
		doc.elements.each('statuses/status') do |el|
		   tweets << el.elements['text'].text
		end
		tweets.join("\r\n")
	end

	def text params
		"<Response><Sms>#{tweets(params)}</Sms></Response>"
	end
end<commit_msg>Migrate tweets app to new sms api<commit_after>require 'net/http'
require 'rexml/document'

class Tweets < Dumbstore::App
	name 'Dumb Tweets'
	author '<NAME>'
	author_url 'http://github.com/antoinedc'
	description <<-DESCRIPTION
	Get the latest tweets from a user.<br />
	Format: <code>tweets [username]</code><br />
	Example: <code>tweets twitter</code>
	DESCRIPTION
	text_id 'tweets'

	def tweets params
		username = params['Body']
		url = "http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=" + username
		xml_data = Net::HTTP.get_response(URI.parse(url)).body
		doc = REXML::Document.new(xml_data)
		tweets = []
		doc.elements.each('statuses/status') do |el|
		   tweets << el.elements['text'].text
		end
		tweets.join("\r\n")
	end

	def text params
		tweets(params).to_sms
	end
end
{'fraction_non_alphanumeric': 0.15422885572139303, 'fraction_numerical': 0.0012437810945273632, 'mean_word_length': 4.548275862068966, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4892065', 'n_tokens_mistral': 629, 'n_tokens_neox': 598, 'n_words': 123}