@pipedream/twitter 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/add-user-to-list/add-user-to-list.mjs +62 -0
- package/actions/advanced-search/advanced-search.mjs +113 -0
- package/actions/common.mjs +29 -0
- package/actions/create-tweet/create-tweet.mjs +146 -0
- package/actions/delete-tweet/delete-tweet.mjs +42 -0
- package/actions/follow-user/follow-user.mjs +48 -0
- package/actions/get-tweet/get-tweet.mjs +42 -0
- package/actions/get-user/get-user.mjs +50 -0
- package/actions/like-tweet/like-tweet.mjs +42 -0
- package/actions/list-favorites/list-favorites.mjs +63 -0
- package/actions/list-followers/list-followers.mjs +67 -0
- package/actions/list-lists/list-lists.mjs +69 -0
- package/actions/list-mentions/list-mentions.mjs +55 -0
- package/actions/list-pending-followers/list-pending-followers.mjs +32 -0
- package/actions/list-retweets/list-retweets.mjs +54 -0
- package/actions/list-user-tweets/list-user-tweets.mjs +80 -0
- package/actions/retweet/retweet.mjs +27 -0
- package/actions/simple-search/simple-search.mjs +62 -0
- package/actions/simple-search-in-list/simple-search-in-list.mjs +48 -0
- package/actions/unfollow-user/unfollow-user.mjs +48 -0
- package/actions/unlike-tweet/unlike-tweet.mjs +40 -0
- package/package.json +21 -21
- package/readme.md +0 -4
- package/sources/common/followed.mjs +37 -0
- package/sources/common/followers.mjs +158 -0
- package/sources/common/tweets.mjs +154 -0
- package/sources/{language-codes.js → language-codes.mjs} +6 -2
- package/sources/my-liked-tweets/my-liked-tweets.mjs +29 -0
- package/sources/my-tweets/my-tweets.mjs +48 -0
- package/sources/new-follower-of-me/new-follower-of-me.mjs +69 -0
- package/sources/new-follower-of-user/new-follower-of-user.mjs +25 -0
- package/sources/new-list-followed/new-list-followed.mjs +24 -0
- package/sources/new-trends-by-geo/new-trends-by-geo.mjs +39 -0
- package/sources/new-tweet-in-list/new-tweet-in-list.mjs +49 -0
- package/sources/new-unfollower-of-me/{new-unfollower-of-me.js → new-unfollower-of-me.mjs} +5 -4
- package/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +25 -0
- package/sources/new-user-followed/new-user-followed.mjs +25 -0
- package/sources/search-mentions/search-mentions.mjs +143 -0
- package/sources/tweets-liked-by-user/tweets-liked-by-user.mjs +37 -0
- package/sources/user-tweets/user-tweets.mjs +49 -0
- package/sources/watch-retweets-of-me/watch-retweets-of-me.mjs +36 -0
- package/sources/watch-retweets-of-my-tweet/watch-retweets-of-my-tweet.mjs +44 -0
- package/sources/watch-retweets-of-user-tweet/watch-retweets-of-user-tweet.mjs +34 -0
- package/twitter.app.mjs +1149 -0
- package/sources/common-followers.js +0 -99
- package/sources/my-liked-tweets/my-liked-tweets.js +0 -26
- package/sources/my-tweets/my-tweets.js +0 -83
- package/sources/new-follower-of-me/new-follower-of-me.js +0 -68
- package/sources/new-follower-of-user/new-follower-of-user.js +0 -69
- package/sources/new-trends-by-geo/new-trends-by-geo.js +0 -29
- package/sources/new-unfollower-of-user/new-unfollower-of-user.js +0 -22
- package/sources/search-mentions/search-mentions.js +0 -76
- package/sources/tweets-liked-by-user/tweets-liked-by-user.js +0 -27
- package/sources/user-tweets/user-tweets.js +0 -66
- package/twitter.app.js +0 -461
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const twitter = require("../twitter.app");
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
dedupe: "unique",
|
|
5
|
-
props: {
|
|
6
|
-
db: "$.service.db",
|
|
7
|
-
twitter,
|
|
8
|
-
timer: {
|
|
9
|
-
type: "$.interface.timer",
|
|
10
|
-
default: {
|
|
11
|
-
intervalSeconds: 60 * 15,
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
hooks: {
|
|
16
|
-
async activate() {
|
|
17
|
-
const followers = this.db.get("followers") || [];
|
|
18
|
-
if (followers.length > 0) {
|
|
19
|
-
console.log(`
|
|
20
|
-
Followers cache already set. Skipping initial provisioning.
|
|
21
|
-
`);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const screenName = this.getScreenName();
|
|
26
|
-
const followerIds = this.twitter.getAllFollowers(screenName);
|
|
27
|
-
for await (const id of followerIds) {
|
|
28
|
-
followers.push(id);
|
|
29
|
-
}
|
|
30
|
-
this.db.set("followers", followers);
|
|
31
|
-
console.log(`
|
|
32
|
-
Provisioned followers cache: found ${followers.length} records
|
|
33
|
-
`);
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
methods: {
|
|
37
|
-
getScreenName() {
|
|
38
|
-
// When screen name is not explicitly provided, the Twitter API defaults
|
|
39
|
-
// it to the user making the API request
|
|
40
|
-
return undefined;
|
|
41
|
-
},
|
|
42
|
-
getRelevantIds() {
|
|
43
|
-
return [];
|
|
44
|
-
},
|
|
45
|
-
generateMeta(data) {
|
|
46
|
-
const {
|
|
47
|
-
timestamp,
|
|
48
|
-
user,
|
|
49
|
-
} = data;
|
|
50
|
-
const {
|
|
51
|
-
id_str: id,
|
|
52
|
-
screen_name: summary,
|
|
53
|
-
} = user;
|
|
54
|
-
// Event timestamp is expressed in seconds, whereas Javascript timestamps
|
|
55
|
-
// are expressed in milliseconds
|
|
56
|
-
const ts = timestamp * 1000;
|
|
57
|
-
return {
|
|
58
|
-
id,
|
|
59
|
-
summary,
|
|
60
|
-
ts,
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
async pullFollowers() {
|
|
64
|
-
const screenName = this.getScreenName();
|
|
65
|
-
const followerIdsGen = this.twitter.getAllFollowers(screenName);
|
|
66
|
-
const result = [];
|
|
67
|
-
for await (const id of followerIdsGen) {
|
|
68
|
-
result.push(id);
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
},
|
|
72
|
-
async getUnfollowers() {
|
|
73
|
-
const prevFollowers = this.db.get("followers");
|
|
74
|
-
const currFollowers = await this.pullFollowers();
|
|
75
|
-
this.db.set("followers", currFollowers);
|
|
76
|
-
|
|
77
|
-
const currFollowersSet = new Set(currFollowers);
|
|
78
|
-
return prevFollowers.filter(pf => !currFollowersSet.has(pf));
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
async run(event) {
|
|
82
|
-
const { timestamp } = event;
|
|
83
|
-
const relevantIds = await this.getRelevantIds();
|
|
84
|
-
if (relevantIds.length <= 0) {
|
|
85
|
-
console.log('Follower data remains unchanged');
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const users = await this.twitter.lookupUsers(relevantIds);
|
|
90
|
-
users.forEach(user => {
|
|
91
|
-
const data = {
|
|
92
|
-
timestamp,
|
|
93
|
-
user,
|
|
94
|
-
};
|
|
95
|
-
const meta = this.generateMeta(data);
|
|
96
|
-
this.$emit(user, meta);
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
key: "twitter-my-liked-tweets",
|
|
5
|
-
name: "My Liked Tweets",
|
|
6
|
-
description: "Emit new Tweets you like on Twitter",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
props: {
|
|
9
|
-
twitter,
|
|
10
|
-
timer: {
|
|
11
|
-
type: "$.interface.timer",
|
|
12
|
-
default: {
|
|
13
|
-
intervalSeconds: 60 * 15,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
dedupe: "unique",
|
|
18
|
-
async run(event) {
|
|
19
|
-
(await this.twitter.getLikedTweets()).reverse().forEach(tweet => {
|
|
20
|
-
this.$emit(tweet, {
|
|
21
|
-
id: tweet.id_str,
|
|
22
|
-
summary: tweet.full_text,
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
const moment = require('moment')
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
key: "twitter-my-tweets",
|
|
6
|
-
name: "My Tweets",
|
|
7
|
-
description: "Emit new Tweets you post to Twitter",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
props: {
|
|
10
|
-
db: "$.service.db",
|
|
11
|
-
twitter,
|
|
12
|
-
q: { propDefinition: [twitter, "keyword_filter"] },
|
|
13
|
-
result_type: { propDefinition: [twitter, "result_type"] },
|
|
14
|
-
includeRetweets: { propDefinition: [twitter, "includeRetweets"] },
|
|
15
|
-
includeReplies: { propDefinition: [twitter, "includeReplies"] },
|
|
16
|
-
lang: { propDefinition: [twitter, "lang"] },
|
|
17
|
-
locale: { propDefinition: [twitter, "locale"] },
|
|
18
|
-
geocode: { propDefinition: [twitter, "geocode"] },
|
|
19
|
-
enrichTweets: { propDefinition: [twitter, "enrichTweets"] },
|
|
20
|
-
count: { propDefinition: [twitter, "count"] },
|
|
21
|
-
maxRequests: { propDefinition: [twitter, "maxRequests"] },
|
|
22
|
-
timer: {
|
|
23
|
-
type: "$.interface.timer",
|
|
24
|
-
default: {
|
|
25
|
-
intervalSeconds: 60 * 15,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
async run(event) {
|
|
30
|
-
const account = await this.twitter.verifyCredentials()
|
|
31
|
-
const from = `from:${account.screen_name}`
|
|
32
|
-
const since_id = this.db.get("since_id")
|
|
33
|
-
const { lang, locale, geocode, result_type, enrichTweets, includeReplies, includeRetweets, maxRequests, count } = this
|
|
34
|
-
let q = from, max_id, limitFirstPage
|
|
35
|
-
|
|
36
|
-
// join "from" filter and search keywords
|
|
37
|
-
if (this.q) {
|
|
38
|
-
q += ` ${this.q}`
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!since_id) {
|
|
42
|
-
limitFirstPage = true
|
|
43
|
-
} else {
|
|
44
|
-
limitFirstPage = false
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// run paginated search
|
|
48
|
-
const tweets = await this.twitter.paginatedSearch({
|
|
49
|
-
q,
|
|
50
|
-
since_id,
|
|
51
|
-
lang,
|
|
52
|
-
locale,
|
|
53
|
-
geocode,
|
|
54
|
-
result_type,
|
|
55
|
-
enrichTweets,
|
|
56
|
-
includeReplies,
|
|
57
|
-
includeRetweets,
|
|
58
|
-
maxRequests,
|
|
59
|
-
count,
|
|
60
|
-
limitFirstPage,
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// emit array of tweet objects
|
|
64
|
-
if(tweets.length > 0) {
|
|
65
|
-
tweets.sort(function(a, b){return a.id - b.id})
|
|
66
|
-
|
|
67
|
-
tweets.forEach(tweet => {
|
|
68
|
-
this.$emit(tweet, {
|
|
69
|
-
ts: moment(tweet.created_at, 'ddd MMM DD HH:mm:ss Z YYYY').valueOf(),
|
|
70
|
-
summary: tweet.full_text || tweet.text,
|
|
71
|
-
id: tweet.id_str,
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
if (tweet.id_str > max_id || !max_id) {
|
|
75
|
-
max_id = tweet.id_str
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
if (max_id) {
|
|
80
|
-
this.db.set("since_id", max_id)
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
key: "twitter-new-follower-of-me",
|
|
5
|
-
name: "New Follower of Me",
|
|
6
|
-
description: "Emit an event when a user follows you on Twitter",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
props: {
|
|
9
|
-
db: "$.service.db",
|
|
10
|
-
twitter,
|
|
11
|
-
timer: {
|
|
12
|
-
type: "$.interface.timer",
|
|
13
|
-
default: {
|
|
14
|
-
intervalSeconds: 60 * 15,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
async run(event) {
|
|
19
|
-
const cached = this.db.get("followers") || []
|
|
20
|
-
const activation = this.db.get("activation") || true
|
|
21
|
-
let newFollowers = []
|
|
22
|
-
const followers = (await this.twitter.getFollowers())
|
|
23
|
-
const latest = [...followers]
|
|
24
|
-
if (JSON.stringify(latest) === JSON.stringify(cached)) {
|
|
25
|
-
console.log('No new followers')
|
|
26
|
-
} else {
|
|
27
|
-
let lastDeleted
|
|
28
|
-
let lastGapIndex
|
|
29
|
-
for (let i = 0; i < cached.length; i++) {
|
|
30
|
-
if(latest.includes(cached[i])) {
|
|
31
|
-
delete latest[latest.indexOf(cached[i])]
|
|
32
|
-
if (i - 1 !== lastDeleted) {
|
|
33
|
-
//new gap detected
|
|
34
|
-
lastGapIndex = i
|
|
35
|
-
}
|
|
36
|
-
lastDeleted = i
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (lastGapIndex >= 0) {
|
|
41
|
-
latest.length = lastGapIndex + 1
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// filter out any deleted elements
|
|
45
|
-
newFollowers = latest.filter(() => true)
|
|
46
|
-
|
|
47
|
-
// emit up to the most recent 100 followers on the first execution to use for test events
|
|
48
|
-
if (activation && newFollowers.length > 100) {
|
|
49
|
-
newFollowers = newFollowers.slice(0, 100)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (newFollowers.length > 0) {
|
|
53
|
-
(await this.twitter.lookupUsers(newFollowers)).reverse().forEach(user => {
|
|
54
|
-
this.$emit(user,{
|
|
55
|
-
summary: user.screen_name,
|
|
56
|
-
id: user.id_str,
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
} else {
|
|
60
|
-
console.log('No new followers')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// set the checkpoint to the full set of followers from the last step
|
|
64
|
-
this.db.set("followers", followers)
|
|
65
|
-
this.db.set("activation", false)
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
key: "twitter-new-follower-of-user",
|
|
5
|
-
name: "New Follower of User",
|
|
6
|
-
description: "Emit an event when a specific user gains a follower",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
props: {
|
|
9
|
-
db: "$.service.db",
|
|
10
|
-
twitter,
|
|
11
|
-
screen_name: { propDefinition: [twitter, "screen_name"] },
|
|
12
|
-
timer: {
|
|
13
|
-
type: "$.interface.timer",
|
|
14
|
-
default: {
|
|
15
|
-
intervalSeconds: 60 * 15,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
async run(event) {
|
|
20
|
-
const cached = this.db.get("followers") || []
|
|
21
|
-
const activation = this.db.get("activation") || true
|
|
22
|
-
let newFollowers = []
|
|
23
|
-
const followers = (await this.twitter.getFollowers(this.screen_name))
|
|
24
|
-
const latest = [...followers]
|
|
25
|
-
if (JSON.stringify(latest) === JSON.stringify(cached)) {
|
|
26
|
-
console.log('No new followers')
|
|
27
|
-
} else {
|
|
28
|
-
let lastDeleted
|
|
29
|
-
let lastGapIndex
|
|
30
|
-
for (let i = 0; i < cached.length; i++) {
|
|
31
|
-
if(latest.includes(cached[i])) {
|
|
32
|
-
delete latest[latest.indexOf(cached[i])]
|
|
33
|
-
if (i - 1 !== lastDeleted) {
|
|
34
|
-
//new gap detected
|
|
35
|
-
lastGapIndex = i
|
|
36
|
-
}
|
|
37
|
-
lastDeleted = i
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (lastGapIndex >= 0) {
|
|
42
|
-
latest.length = lastGapIndex + 1
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// filter out any deleted elements
|
|
46
|
-
newFollowers = latest.filter(() => true)
|
|
47
|
-
|
|
48
|
-
// emit up to the most recent 100 followers on the first execution to use for test events
|
|
49
|
-
if (activation && newFollowers.length > 100) {
|
|
50
|
-
newFollowers = newFollowers.slice(0, 100)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (newFollowers.length > 0) {
|
|
54
|
-
(await this.twitter.lookupUsers(newFollowers)).reverse().forEach(user => {
|
|
55
|
-
this.$emit(user,{
|
|
56
|
-
summary: user.screen_name,
|
|
57
|
-
id: user.id_str,
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
} else {
|
|
61
|
-
console.log('No new followers')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// set the checkpoint to the full set of followers from the last step
|
|
65
|
-
this.db.set("followers", followers)
|
|
66
|
-
this.db.set("activation", false)
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
key: "twitter-new-trends-by-geo",
|
|
5
|
-
name: "New Trends by Geo",
|
|
6
|
-
description: "Emit an event when a new topic is trending on Twitter in a specific geographic location",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
props: {
|
|
9
|
-
twitter,
|
|
10
|
-
trendLocation: { propDefinition: [twitter, "trendLocation"] },
|
|
11
|
-
timer: {
|
|
12
|
-
type: "$.interface.timer",
|
|
13
|
-
default: {
|
|
14
|
-
intervalSeconds: 60 * 15,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
dedupe: "unique",
|
|
19
|
-
async run(event) {
|
|
20
|
-
const response = (await this.twitter.getTrends()).forEach(geo => {
|
|
21
|
-
geo.trends.reverse().forEach(trend => {
|
|
22
|
-
this.$emit(trend, {
|
|
23
|
-
id: trend.query,
|
|
24
|
-
summary: trend.name,
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
},
|
|
29
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const common = require("../common-followers");
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
...common,
|
|
5
|
-
key: "twitter-new-unfollower-of-user",
|
|
6
|
-
name: "New Unfollower of User",
|
|
7
|
-
description: "Emit an event when a specific user loses a follower on Twitter",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
props: {
|
|
10
|
-
...common.props,
|
|
11
|
-
screen_name: { propDefinition: [common.twitter, "screen_name"] },
|
|
12
|
-
},
|
|
13
|
-
methods: {
|
|
14
|
-
...common.methods,
|
|
15
|
-
getScreenName() {
|
|
16
|
-
return this.screen_name;
|
|
17
|
-
},
|
|
18
|
-
getRelevantIds() {
|
|
19
|
-
return this.getUnfollowers();
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
const moment = require('moment')
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
key: "twitter-search-mentions",
|
|
6
|
-
name: "Search Mentions",
|
|
7
|
-
description: "Emit new Tweets that matches your search criteria",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
props: {
|
|
10
|
-
db: "$.service.db",
|
|
11
|
-
twitter,
|
|
12
|
-
q: { propDefinition: [twitter, "q"] },
|
|
13
|
-
result_type: { propDefinition: [twitter, "result_type"] },
|
|
14
|
-
includeRetweets: { propDefinition: [twitter, "includeRetweets"] },
|
|
15
|
-
includeReplies: { propDefinition: [twitter, "includeReplies"] },
|
|
16
|
-
lang: { propDefinition: [twitter, "lang"] },
|
|
17
|
-
locale: { propDefinition: [twitter, "locale"] },
|
|
18
|
-
geocode: { propDefinition: [twitter, "geocode"] },
|
|
19
|
-
enrichTweets: { propDefinition: [twitter, "enrichTweets"] },
|
|
20
|
-
count: { propDefinition: [twitter, "count"] },
|
|
21
|
-
maxRequests: { propDefinition: [twitter, "maxRequests"] },
|
|
22
|
-
timer: {
|
|
23
|
-
type: "$.interface.timer",
|
|
24
|
-
default: {
|
|
25
|
-
intervalSeconds: 60 * 15,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
async run(event) {
|
|
30
|
-
const since_id = this.db.get("since_id")
|
|
31
|
-
const { lang, locale, geocode, result_type, enrichTweets, includeReplies, includeRetweets, maxRequests, count } = this
|
|
32
|
-
let q = this.q, max_id, limitFirstPage
|
|
33
|
-
|
|
34
|
-
if (!since_id) {
|
|
35
|
-
limitFirstPage = true
|
|
36
|
-
} else {
|
|
37
|
-
limitFirstPage = false
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// run paginated search
|
|
41
|
-
const tweets = await this.twitter.paginatedSearch({
|
|
42
|
-
q,
|
|
43
|
-
since_id,
|
|
44
|
-
lang,
|
|
45
|
-
locale,
|
|
46
|
-
geocode,
|
|
47
|
-
result_type,
|
|
48
|
-
enrichTweets,
|
|
49
|
-
includeReplies,
|
|
50
|
-
includeRetweets,
|
|
51
|
-
maxRequests,
|
|
52
|
-
count,
|
|
53
|
-
limitFirstPage,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
// emit array of tweet objects
|
|
57
|
-
if(tweets.length > 0) {
|
|
58
|
-
tweets.sort(function(a, b){return a.id - b.id})
|
|
59
|
-
|
|
60
|
-
tweets.forEach(tweet => {
|
|
61
|
-
this.$emit(tweet, {
|
|
62
|
-
ts: moment(tweet.created_at, 'ddd MMM DD HH:mm:ss Z YYYY').valueOf(),
|
|
63
|
-
summary: tweet.full_text || tweet.text,
|
|
64
|
-
id: tweet.id_str,
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (tweet.id_str > max_id || !max_id) {
|
|
68
|
-
max_id = tweet.id_str
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
if (max_id) {
|
|
73
|
-
this.db.set("since_id", max_id)
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
key: "twitter-tweet-liked-by-user",
|
|
5
|
-
name: "Tweet Liked by User",
|
|
6
|
-
description: "Emit new Tweets liked by a specific user on Twitter",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
props: {
|
|
9
|
-
twitter,
|
|
10
|
-
screen_name: { propDefinition: [twitter, "screen_name"] },
|
|
11
|
-
timer: {
|
|
12
|
-
type: "$.interface.timer",
|
|
13
|
-
default: {
|
|
14
|
-
intervalSeconds: 60 * 15,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
dedupe: "unique",
|
|
19
|
-
async run(event) {
|
|
20
|
-
(await this.twitter.getLikedTweets({ screen_name: this.screen_name })).reverse().forEach(tweet => {
|
|
21
|
-
this.$emit(tweet, {
|
|
22
|
-
id: tweet.id_str,
|
|
23
|
-
summary: tweet.full_text,
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
},
|
|
27
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
const twitter = require('../../twitter.app.js')
|
|
2
|
-
const moment = require('moment')
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
key: "twitter-user-tweets",
|
|
6
|
-
name: "User Tweets",
|
|
7
|
-
description: "Emit new Tweets posted by a user",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
props: {
|
|
10
|
-
db: "$.service.db",
|
|
11
|
-
twitter,
|
|
12
|
-
screen_name: { propDefinition: [twitter, "screen_name"] },
|
|
13
|
-
include_rts: { propDefinition: [twitter, "includeRetweets"] },
|
|
14
|
-
includeReplies: { propDefinition: [twitter, "includeReplies"] },
|
|
15
|
-
enrichTweets: { propDefinition: [twitter, "enrichTweets"] },
|
|
16
|
-
count: { propDefinition: [twitter, "count"] },
|
|
17
|
-
timer: {
|
|
18
|
-
type: "$.interface.timer",
|
|
19
|
-
default: {
|
|
20
|
-
intervalSeconds: 60 * 15,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
methods: {},
|
|
25
|
-
async run(event) {
|
|
26
|
-
const screen_name = this.screen_name //.replace('@','')
|
|
27
|
-
const since_id = this.db.get("since_id")
|
|
28
|
-
const { enrichTweets, includeReplies, include_rts, count } = this
|
|
29
|
-
let max_id
|
|
30
|
-
|
|
31
|
-
if(!includeReplies) {
|
|
32
|
-
exclude_replies = true
|
|
33
|
-
} else {
|
|
34
|
-
exclude_replies = false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const tweets = await this.twitter.getUserTimeline({
|
|
38
|
-
screen_name,
|
|
39
|
-
enrichTweets,
|
|
40
|
-
exclude_replies: !includeReplies,
|
|
41
|
-
include_rts,
|
|
42
|
-
count,
|
|
43
|
-
since_id,
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
// emit array of tweet objects
|
|
47
|
-
if(tweets.length > 0) {
|
|
48
|
-
tweets.sort(function(a, b){return a.id - b.id})
|
|
49
|
-
|
|
50
|
-
tweets.forEach(tweet => {
|
|
51
|
-
this.$emit(tweet, {
|
|
52
|
-
ts: moment(tweet.created_at, 'ddd MMM DD HH:mm:ss Z YYYY').valueOf(),
|
|
53
|
-
summary: tweet.full_text || tweet.text,
|
|
54
|
-
id: tweet.id_str,
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
if (!max_id || tweet.id_str > max_id) {
|
|
58
|
-
max_id = tweet.id_str
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
if (max_id) {
|
|
63
|
-
this.db.set("since_id", max_id)
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
}
|