Permalink
Browse files

bump version 0.1.0

- npm 1.0 confirmed.
- log4js fix
  • Loading branch information...
1 parent 87a1198 commit 22b4df0eb2814c3f916639d2a28976e610a55b05 @yssk22 committed Jun 15, 2011
Showing with 17 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +8 −7 lib/twbot.js
  3. +5 −5 lib/twitter/index.js
  4. +3 −3 package.json
View
@@ -1 +1,2 @@
.DS_Store
+node_modules
View
@@ -8,7 +8,6 @@ var EventEmitter = require('events').EventEmitter;
var util = require('util'),
fs = require('fs');
var twitter = require('./twitter');
-var log4js = require('log4js')();
VERSION = '0.0.3';
DEFAULT_OPTIONS = {
@@ -33,24 +32,26 @@ function TwBot(auth, options){
if( typeof auth == 'string' ){
auth = JSON.parse(fs.readFileSync(auth));
}
+ // options
+ if( !options ){
+ options = {};
+ }
+
this._client = twitter.createClient(auth.consumerKey, auth.consumerSecret,
{accessKey: auth.accessKey,
- accessSecret: auth.accessSecret});
+ accessSecret: auth.accessSecret,
+ logger: options.logger});
this._account = null;
this._plugins = {};
- // options
- if( !options ){
- options = {};
- }
for(var i in DEFAULT_OPTIONS){
if( options[i] === undefined ){
options[i] = DEFAULT_OPTIONS[i];
}
}
this._options = options;
- this._logger = log4js.getLogger(options.logger);
+ this._logger = options.logger || require('log4js')().getLogger('twitter');
this._version = VERSION;
}
util.inherits(TwBot, EventEmitter);
View
@@ -9,7 +9,6 @@ var util = require('util'),
crypto = require('crypto'),
http = require('http'),
EventEmitter = require('events').EventEmitter;
-var logger = require('log4js')().getLogger('twitter');
var OAuth = require('oauth').OAuth;
var normalizeError = require('../util').normalizeError;
var buildUrl = require('../util').buildUrl;
@@ -54,6 +53,8 @@ function Twitter(consumerKey, consumerSecret, options){
);
this._accessKey = options.accessKey;
this._accessSecret = options.accessSecret;
+
+ this._logger = options.logger || require('log4js')().getLogger('twitter');
};
exports.createClient = function(consumerKey, consumerSecret, options){
@@ -123,7 +124,7 @@ Twitter.prototype.getAccessToken = function(callback){
function doGet(client){
return function(path, params, callback){
path = buildUrl(path, params);
- logger.debug('GET ' + path);
+ client._logger.debug('GET ' + path);
var url = [API_URL, path].join('');
client._oa.get(url, client._accessKey, client._accessSecret,
createResponseHandler(callback));
@@ -132,8 +133,8 @@ function doGet(client){
function doPost(client){
return function(path, body, callback){
- logger.debug('POST ' + path);
- logger.debug(">> " + util.inspect(body));
+ client._logger.debug('POST ' + path);
+ client._logger.debug(">> " + util.inspect(body));
var url = [API_URL, path].join('');
client._oa.post(url, client._accessKey, client._accessSecret,
body,
@@ -148,7 +149,6 @@ function createResponseHandler(callback){
}else{
var obj = undefined;
if( data ){
- logger.debug('<< ' + data);
try{
obj = JSON.parse(data);
}catch(e){
View
@@ -1,19 +1,19 @@
{
"name": "twbot",
- "version": "0.0.3",
+ "version": "0.1.0",
"description": "Twitter bot microframework using node.js",
"tags" : ["twitter", "bot"],
"author" : "Yohei Sasaki <yssk22@gmail.com>",
"contributors" : [],
"dependencies" : {
- "oauth" : "= 0.9.0"
+ "oauth" : "= 0.9.0",
+ "log4js" : "= 0.2.6"
},
"main": "./lib/twbot",
"bin" : {
"twbot:config": "bin/config.js"
},
"directories" : {
- "lib": "./lib",
"spec": "./spec"
},
"repository": {

0 comments on commit 22b4df0

Please sign in to comment.