This repository was archived by the owner on Nov 10, 2023. It is now read-only.
-
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.
Adding the actual code
- Loading branch information
Showing
13 changed files
with
1,481 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Environment Config | ||
|
||
SLACK_SIGNING_SECRET= | ||
SLACK_BOT_TOKEN= | ||
twitter_consumer_key= | ||
twitter_consumer_secret= | ||
twitter_access_token_key= | ||
twitter_access_token_secret= | ||
|
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,3 @@ | ||
node_modules | ||
.DS_Store | ||
.env |
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,2 +1,61 @@ | ||
# tiktok-slackbot | ||
Watch TikToks in Slack | ||
# TikTok to Twitter Slackbot | ||
|
||
Wish you could watch TikToks in Slack? Me too. I made a Slackbot fix that by uploading TikToks to Twitter and then posting the Tweets back in a Slack thread. | ||
|
||
--- | ||
1~ Slackbot replies to post: | ||
<kbd> | ||
<img src="media/reply.gif"> | ||
</kbd> | ||
|
||
<details> | ||
<summary>2~ You watch TikTok</summary> | ||
|
||
<kbd> | ||
<img src="media/thread.gif"> | ||
</kbd> | ||
</details> | ||
|
||
## Features | ||
* Works with short and long TikTok urls | ||
* Can handle many concurrent requests | ||
* Unfurls links posted in threads | ||
|
||
## How it works | ||
|
||
I hoped to use the [unfurl api](https://api.slack.com/docs/message-link-unfurling) to attach the video. Unforunately, that's not possible and Slack only shows [previews](https://slack.com/help/articles/204399343-Share-links-and-set-preview-preferences) from whitelisted apps. The good news is that Twitter is whitelisted. So we can upload a video to Twitter and then let Slack unfurl that. | ||
|
||
 | ||
|
||
|
||
I decided not to upload the MP4 directly to Slack because that would hog your Slack storage and litter the files search. | ||
|
||
### General Flow: | ||
Slack -> TikTok -> Twitter -> Slack | ||
|
||
1. Recieve a `link_shared` [event](https://api.slack.com/events/link_shared) from Slack for a TikTok | ||
2. Download the MP4 from TikTok | ||
3. Tweet the MP4 | ||
4. Reply to original Slack message with Tweet | ||
|
||
|
||
## Setup | ||
|
||
`cp .env.sample .env` to make the `.env` file. | ||
|
||
1. Create a [Twitter developer account](https://developer.twitter.com/en/apply-for-access) and put the credentials to the `.env` file. | ||
2. Create a Slackbot (follow instructions in src/slackbot.js) and put the credentials in the `.env` file. | ||
3. Run `npm start` | ||
4. Add your server address to the **Event Subscriptions** page in Slack. ex: `https://example.com/slack/events` | ||
* Your bot must be running before you can add the URL | ||
* You can use ngrok for local testing | ||
* See [Bolt docs](https://api.slack.com/tutorials/hello-world-bolt) for help setting up a Slackbot. | ||
5. Add the Slackbot to any channel you want it to respond in. | ||
|
||
### Hosting | ||
|
||
I recommend hosting for free on [glitch.com](https://glitch.com/). However, Google App Engine or even a Lambda function should work as well. | ||
|
||
## Contributing | ||
|
||
Feel free to open a PR or create an issue if you'd like to improve the project! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.