<commit_before>var	Twitter = require('twitter'),
	utility = require('./utility'),
	unempty = utility.unempty;

var tweetbloat = [
	// strip thus-far unused geolocation data
	'geo',
	'place',
	'coordinates',
	// user-related, but delete these everywhere anyway
	'profile_link_color',
	'profile_sidebar_fill_color',
	'profile_sidebar_border_color',
	'profile_background_color',
	'profile_background_image_url',
	'profile_background_tile',
	'profile_text_color',
	'profile_use_background_image'
];

DenbyProxy = function(client, ripley) {
	if (!(this instanceof DenbyProxy)) return new DenbyProxy(client);

	// Send well-packed messages
	var send = function(message) {
		unempty(message, tweetbloat);
		client.send(message);
	};

	// CONFIGURATION, FIXME: hard coded, need to share with client
	var clientconfig = {DENBY: {CONFIG: {
		columns: [
			{
				id: 'home',
				header: 'Home'
			},
			{
				id: 'me',
				header: 'Me'
			},
			{	id: 'search',
				header: 'Search: nodejs, node.js, #denby, hellodenby',
				search: 'nodejs,node.js,#denby,hellodenby'
			}
		]
	}}};
	client.send(clientconfig); // yes, I wanted to client.send here

	// My Twitter REST client and related variables
	var twauth = ripley.twauth,
		user_id = twauth.user_id,
		screen_name = twauth.screen_name;

	var twitter = new Twitter({
			consumer_key: twauth.consumer_key,
			consumer_secret: twauth.consumer_secret,
			// access_token fallback for node-twitter cookies prior to v0.1.11
			access_token_key: twauth.access_token_key || twauth.access_token,
			access_token_secret: twauth.access_token_secret
		});

	// Send account information
	twitter.verifyCredentials(send);

	// Connect to the stream
	// FIXME: q'n'd user streams solution, without ripley for now
	//ripley.on('data', send);
	twitter.stream('user', {track:'nodejs,node.js,#denby,hellodenby'}, function(stream) {
		stream.on('data', send);
		// FIXME: why is end misfiring?
		/*stream.on('end', function() {
console.log('GOODBYE DENBY ' + screen_name + ', STREAM DIED!');
		});*/
	});

	// Messages from Denby
	// FIXME: at some point, factor this out into a "socket.rpc" project
	client.on('message', clientMessage);

	// Denby disco(nnected)!
	client.on('disconnect', function() {
		ripley.removeListener('message', clientMessage);
	});

	function clientMessage(message) {
		if ( message && message.jsonrpc && message.jsonrpc === '2.0' && message.method ) {
			var	rpc = {jsonrpc: '2.0', id: message.id || null};
//console.log('JSON-RPC packet received from ' + screen_name + ' ' + JSON.stringify(message, null, 2));
			if ( twitter && message.method in twitter && typeof twitter[message.method] !== 'function' ) {
				rpc.error = {
					code: -32601,
					message: "Procedure not found."
				};<commit_msg>allow jsonrpc access to shortUrl, remember to ban some functions<commit_after>var	Twitter = require('twitter'),
	utility = require('./utility'),
	unempty = utility.unempty,
	shortUrl = utility.shortUrl;

var tweetbloat = [
	// strip thus-far unused geolocation data
	'geo',
	'place',
	'coordinates',
	// user-related, but delete these everywhere anyway
	'profile_link_color',
	'profile_sidebar_fill_color',
	'profile_sidebar_border_color',
	'profile_background_color',
	'profile_background_image_url',
	'profile_background_tile',
	'profile_text_color',
	'profile_use_background_image'
];

DenbyProxy = function(client, ripley) {
	if (!(this instanceof DenbyProxy)) return new DenbyProxy(client);

	// Send well-packed messages
	var send = function(message) {
		unempty(message, tweetbloat);
		client.send(message);
	};

	// CONFIGURATION, FIXME: hard coded, need to share with client
	var clientconfig = {DENBY: {CONFIG: {
		columns: [
			{
				id: 'home',
				header: 'Home'
			},
			{
				id: 'me',
				header: 'Me'
			},
			{	id: 'search',
				header: 'Search: nodejs, node.js, #denby, hellodenby',
				search: 'nodejs,node.js,#denby,hellodenby'
			}
		]
	}}};
	client.send(clientconfig); // yes, I wanted to client.send here

	// My Twitter REST client and related variables
	var twauth = ripley.twauth,
		user_id = twauth.user_id,
		screen_name = twauth.screen_name;

	var twitter = new Twitter({
			consumer_key: twauth.consumer_key,
			consumer_secret: twauth.consumer_secret,
			// access_token fallback for node-twitter cookies prior to v0.1.11
			access_token_key: twauth.access_token_key || twauth.access_token,
			access_token_secret: twauth.access_token_secret
		});
	twitter.shortUrl = shortUrl; // so jsonrpc can get to it...

	// Send account information
	twitter.verifyCredentials(send);

	// Connect to the stream
	// FIXME: q'n'd user streams solution, without ripley for now
	//ripley.on('data', send);
	twitter.stream('user', {track:'nodejs,node.js,#denby,hellodenby'}, function(stream) {
console.log('USER STREAMING FOR ' + screen_name + ' (' + client.sessionId + ')!');
		stream.on('data', send);
	});

	// Messages from Denby
	// FIXME: at some point, factor this out into a "socket.rpc" project
	client.on('message', clientMessage);

	// Denby disco(nnected)!
	client.on('disconnect', function() {
		ripley.removeListener('message', clientMessage);
	});

	var banned = [ 'stream', 'cookie', 'login', 'gatekeeper', '_getUsingCursor' ];
	function clientMessage(message) {
		if ( message && message.jsonrpc && message.jsonrpc === '2.0' && message.method ) {
			var	rpc = {jsonrpc: '2.0', id: message.id || null};
//console.log('JSON-RPC packet received from ' + screen_name + ' ' + JSON.stringify(message, null, 2));
			if ( banned.indexOf(message.method) >= 0 && twitter && message.method in twitter && typeof twitter[message.method] !== 'function' ) {
				rpc.error = {
					code: -32601,
					message: "Procedure not found."
				};
{'fraction_non_alphanumeric': 0.14523475823405746, 'fraction_numerical': 0.005080588647512264, 'mean_word_length': 4.175883952855847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5671866', 'n_tokens_mistral': 2082, 'n_tokens_neox': 1886, 'n_words': 461}