-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reply functionality baked in (#21)
* refactor: set pick at random reply fn * refactor: PAR can reply `real` mentions * fix: style and build
- Loading branch information
1 parent
123416d
commit 9ec2b11
Showing
16 changed files
with
112 additions
and
24 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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...ook-listener-helpers/__tests__/handle-pick-at-random-activity-create-tweet-events.spec.ts
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,4 +1,4 @@ | ||
require("../../utils/config"); | ||
require("../../config"); | ||
|
||
import { | ||
ITweet, | ||
|
2 changes: 1 addition & 1 deletion
2
src/webhook-listener-helpers/__tests__/handle-pick-at-random-activity.spec.ts
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
export const CommandType = { | ||
Cancel: "cancel", | ||
Feedback: "feedback", | ||
}; | ||
export enum CommandType { | ||
Cancel = "cancel", | ||
Feedback = "feedback", | ||
} | ||
|
||
export enum TwitterEndpoint { | ||
StatusUpdate = "statuses/update", | ||
} |
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,51 @@ | ||
import Twitter from "twitter-lite"; | ||
import { TwitterEndpoint } from "."; | ||
import { ITweet } from "./ITweet"; | ||
|
||
class ParTwitterClient { | ||
private v1: Twitter; | ||
private v2: Twitter; | ||
|
||
/** | ||
* Initialise the parameters for PAR account | ||
*/ | ||
constructor() { | ||
this.v1 = new Twitter({ | ||
consumer_key: process.env.TWITTER_CONSUMER_KEY as string, | ||
consumer_secret: process.env.TWITTER_CONSUMER_SECRET as string, | ||
access_token_key: process.env.TWITTER_PAR_ACCESS_TOKEN as string, | ||
access_token_secret: process.env | ||
.TWITTER_PAR_ACCESS_TOKEN_SECRET as string, | ||
}); | ||
this.v2 = new Twitter({ | ||
extension: false, | ||
version: "2", | ||
consumer_key: process.env.TWITTER_CONSUMER_KEY as string, | ||
consumer_secret: process.env.TWITTER_CONSUMER_SECRET as string, | ||
access_token_key: process.env.TWITTER_PAR_ACCESS_TOKEN as string, | ||
access_token_secret: process.env | ||
.TWITTER_PAR_ACCESS_TOKEN_SECRET as string, | ||
}); | ||
} | ||
|
||
/** | ||
* Reply/Acknowledge a real mention with a feedback of the computed | ||
* result | ||
* @param {string} id - The id of the mention to reply | ||
* @param {string} message - The feedback message | ||
* @param {string} author - The screen name of the author | ||
* @returns {Promise<ITweet>} The tweeted feedback | ||
*/ | ||
async replyMention( | ||
id: string, | ||
message: string, | ||
author: string | ||
): Promise<ITweet> { | ||
return await this.v1.post(TwitterEndpoint.StatusUpdate, { | ||
status: `@${author} ${message}`, | ||
in_reply_to_status_id: id, | ||
}); | ||
} | ||
} | ||
|
||
export const parTwitterClient = new ParTwitterClient(); |
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 |
---|---|---|
|
@@ -1432,6 +1432,13 @@ create-require@^1.1.0: | |
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" | ||
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== | ||
|
||
cross-fetch@^3.0.0: | ||
version "3.1.4" | ||
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39" | ||
integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ== | ||
dependencies: | ||
node-fetch "2.6.1" | ||
|
||
cross-spawn@^6.0.0: | ||
version "6.0.5" | ||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" | ||
|
@@ -3643,6 +3650,11 @@ nice-try@^1.0.4: | |
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" | ||
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== | ||
|
||
[email protected]: | ||
version "2.6.1" | ||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" | ||
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== | ||
|
||
node-int64@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" | ||
|
@@ -3762,6 +3774,11 @@ nwsapi@^2.2.0: | |
resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" | ||
integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ== | ||
|
||
oauth-1.0a@^2.2.4: | ||
version "2.2.6" | ||
resolved "https://registry.yarnpkg.com/oauth-1.0a/-/oauth-1.0a-2.2.6.tgz#eadbccdb3bceea412d24586e6f39b2b412f0e491" | ||
integrity sha512-6bkxv3N4Gu5lty4viIcIAnq5GbxECviMBeKR3WX/q87SPQ8E8aursPZUtsXDnxCs787af09WPRBLqYrf/lwoYQ== | ||
|
||
oauth-sign@~0.9.0: | ||
version "0.9.0" | ||
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" | ||
|
@@ -4948,6 +4965,19 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: | |
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" | ||
integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= | ||
|
||
twitter-error-handler@^3.1.0: | ||
version "3.1.0" | ||
resolved "https://registry.yarnpkg.com/twitter-error-handler/-/twitter-error-handler-3.1.0.tgz#d68dd03e6ad51141ee59757a7d3939baf2e5f66d" | ||
integrity sha512-aCCrxYb0rQO18jdsD5via87YLhVoLnDZKn1RFD4DEoR0ZN5MM/2bV+FBR+WIZUdBMaW7lUjxun+vTQdwUTW6+g== | ||
|
||
twitter-lite@^1.1.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/twitter-lite/-/twitter-lite-1.1.0.tgz#77f250cc73f14ecc5a493ddb81ff0a3e9ae72680" | ||
integrity sha512-v37I0zyYXjn3/zdm/ii+1RiBFZ2SCB3wLl1N5nfW8TUqoNDYBR66oXBFbQavKEvjg5WqcTUzNhAhe6FkgylPsw== | ||
dependencies: | ||
cross-fetch "^3.0.0" | ||
oauth-1.0a "^2.2.4" | ||
|
||
type-check@^0.4.0, type-check@~0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" | ||
|
9ec2b11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: