-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from dergigi/feature/1-reply-with-source
Reply with source if users ask for it
- Loading branch information
Showing
7 changed files
with
311 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict'; | ||
|
||
require('./src/bot'); | ||
var bot = require('./src/bot'); | ||
|
||
bot.postRandomQuote(); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
|
||
var bot = require('./src/bot'); | ||
bot.replyAllWithSource(); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"created_at": "Fri Jan 25 23:59:44 +0000 2019", | ||
"id": 1088949574264414200, | ||
"id_str": "1088949574264414213", | ||
"text": "@QuotableSatoshi Source?", | ||
"truncated": false, | ||
"entities": { | ||
"hashtags": [], | ||
"symbols": [], | ||
"user_mentions": [ | ||
{ | ||
"screen_name": "QuotableSatoshi", | ||
"name": "Quotable Satoshi", | ||
"id": 1081377398514425900, | ||
"id_str": "1081377398514425856", | ||
"indices": [ | ||
0, | ||
16 | ||
] | ||
} | ||
], | ||
"urls": [] | ||
}, | ||
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>", | ||
"in_reply_to_status_id": 1085371334950092800, | ||
"in_reply_to_status_id_str": "1085371334950092800", | ||
"in_reply_to_user_id": 1081377398514425900, | ||
"in_reply_to_user_id_str": "1081377398514425856", | ||
"in_reply_to_screen_name": "QuotableSatoshi", | ||
"user": { | ||
"id": 18213426, | ||
"id_str": "18213426", | ||
"name": "Gigi", | ||
"screen_name": "dergigi", | ||
"location": "The Internet, Planet Earth", | ||
"description": "Bitcoin twitter is real life.", | ||
"url": "https://t.co/vrNoQgEBxT", | ||
"entities": { | ||
"url": { | ||
"urls": [ | ||
{ | ||
"url": "https://t.co/vrNoQgEBxT", | ||
"expanded_url": "https://medium.com/@dergigi", | ||
"display_url": "medium.com/@dergigi", | ||
"indices": [ | ||
0, | ||
23 | ||
] | ||
} | ||
] | ||
}, | ||
"description": { | ||
"urls": [] | ||
} | ||
}, | ||
"protected": false, | ||
"followers_count": 580, | ||
"friends_count": 162, | ||
"listed_count": 46, | ||
"created_at": "Thu Dec 18 11:49:14 +0000 2008", | ||
"favourites_count": 12596, | ||
"utc_offset": null, | ||
"time_zone": null, | ||
"geo_enabled": false, | ||
"verified": false, | ||
"statuses_count": 4665, | ||
"lang": "en", | ||
"contributors_enabled": false, | ||
"is_translator": false, | ||
"is_translation_enabled": false, | ||
"profile_background_color": "000000", | ||
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", | ||
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", | ||
"profile_background_tile": false, | ||
"profile_image_url": "http://pbs.twimg.com/profile_images/975173422119612417/h2VyxVmR_normal.jpg", | ||
"profile_image_url_https": "https://pbs.twimg.com/profile_images/975173422119612417/h2VyxVmR_normal.jpg", | ||
"profile_banner_url": "https://pbs.twimg.com/profile_banners/18213426/1529070904", | ||
"profile_link_color": "ABB8C2", | ||
"profile_sidebar_border_color": "000000", | ||
"profile_sidebar_fill_color": "000000", | ||
"profile_text_color": "000000", | ||
"profile_use_background_image": false, | ||
"has_extended_profile": false, | ||
"default_profile": false, | ||
"default_profile_image": false, | ||
"following": true, | ||
"follow_request_sent": false, | ||
"notifications": false, | ||
"translator_type": "none" | ||
}, | ||
"geo": null, | ||
"coordinates": null, | ||
"place": null, | ||
"contributors": null, | ||
"is_quote_status": false, | ||
"retweet_count": 0, | ||
"favorite_count": 0, | ||
"favorited": false, | ||
"retweeted": false, | ||
"lang": "en" | ||
} |
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
var assert = require('assert'); | ||
var bot = require('../src/bot'); | ||
|
||
const REPLY_TWEET_ID = '1088949574264414213' | ||
const EXPECTED_ROOT_TWEET_ID = '1085371334950092800' | ||
const TWEET_ASKING_FOR_SOURCE = require('./assets/tweet_asking_for_source.json') | ||
|
||
const QUOTE_BITCOINTALK = 'At equilibrium size, many nodes will be server farms with one or two network nodes that feed the rest of the farm over a LAN.' | ||
const QUOTE_BITCOINTALK_SOURCE = 'https://satoshi.nakamotoinstitute.org/posts/bitcointalk/188' | ||
|
||
const QUOTE_WHITEPAPER = 'A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution.' | ||
const QUOTE_WHITEPAPER_SOURCE = 'https://bitcoin.org/bitcoin.pdf' | ||
|
||
const QUOTE_EMAIL = 'It might make sense just to get some in case it catches on. If enough people think the same way, that becomes a self fulfilling prophecy.' | ||
const QUOTE_EMAIL_SOURCE = 'https://satoshi.nakamotoinstitute.org/emails/cryptography/17' | ||
|
||
const QUOTE_P2PFOUNDATION = 'To Sepp\'s question, indeed there is nobody to act as central bank or federal reserve to adjust the money supply as the population of users grows.' | ||
const QUOTE_P2PFOUNDATION_SOURCE = 'https://satoshi.nakamotoinstitute.org/posts/p2pfoundation/3' | ||
|
||
describe('quotableSatoshi', function() { | ||
describe('#getParentTweet()', function() { | ||
it('should get the correct root tweet id of a reply', function() { | ||
bot.getParentTweet(TWEET_ASKING_FOR_SOURCE, function(err, data, response) { | ||
assert.equal(data.id_str, EXPECTED_ROOT_TWEET_ID, 'tweet id is the expected root tweet id') | ||
assert.equal(data.user.screen_name, 'dergigi') | ||
}) | ||
}); | ||
}); | ||
describe('#getRepliesByBot()', function() { | ||
it('should detect if tweet asking for source was replied to', function() { | ||
bot.getRepliesByBot(TWEET_ASKING_FOR_SOURCE, function(err, data, response) { | ||
assert.equal(data.statuses.length, 0, 'statuses should be empty') | ||
}); | ||
}); | ||
}); | ||
describe('#getQuoteMetadata()', function() { | ||
it('should look up the source of a bitcointalk quote correctly', function() { | ||
var metadata = bot.getQuoteMetadata(QUOTE_BITCOINTALK); | ||
assert.equal(metadata.source, QUOTE_BITCOINTALK_SOURCE); | ||
assert.equal(metadata.date, "July 14, 2010"); | ||
}); | ||
it('should look up the source of a whitepaper quote correctly', function() { | ||
var metadata = bot.getQuoteMetadata(QUOTE_WHITEPAPER); | ||
assert.equal(metadata.source, QUOTE_WHITEPAPER_SOURCE); | ||
assert.equal(metadata.date, "October 31, 2008"); | ||
}); | ||
it('should look up the source of a email quote correctly', function() { | ||
var metadata = bot.getQuoteMetadata(QUOTE_EMAIL); | ||
assert.equal(metadata.source, QUOTE_EMAIL_SOURCE); | ||
assert.equal(metadata.date, "January 17, 2009"); | ||
}); | ||
it('should look up the source of a p2pfoundation quote correctly', function() { | ||
var metadata = bot.getQuoteMetadata(QUOTE_P2PFOUNDATION); | ||
assert.equal(metadata.source, QUOTE_P2PFOUNDATION_SOURCE); | ||
assert.equal(metadata.date, "February 18, 2009"); | ||
}); | ||
}); | ||
}); | ||
|
||
function onSearchComplete(err, data, response) { | ||
if (err) { | ||
fail("Search should not throw an error") | ||
} | ||
if (data) { | ||
console.log(data) | ||
assert.equal(data.count > 0, true) | ||
} else { | ||
fail("No data received") | ||
} | ||
} |