A super simple Discord bot designed for helping you share TikToks without actually having to have your friends open TikTok.
TikBot will download any TikTok (or other supported link in yt_dlp) linked in a Discord channel it is in, and post the video file directly. In cases where the file is too large for Discord's free tier, the video will be compressed to fit first.
Requirements: Python 3.9+
-
Set Discord access token into
.envasTOKEN=$yourTokenGoesHere -
Add the bot to the Discord server you wish to run it in.
-
Setup any channel in the Discord server with a name starting with
tik-tok -
Ensure the bot has permission to post attachments and messages in the channel.
-
Install required packages with
pip install -r requirements.txt -
Run the bot
python main.py
TikBot includes an application version in its Discord presence, shown as Playing doomscrolling | vX.Y.Z by default.
Version resolution works like this:
- If
TIKBOT_VERSIONis set, TikBot uses that value. - If the current commit is tagged like
v1.2.3, TikBot uses1.2.3. - Otherwise, TikBot derives a version from git history as
1.<commit-count>.0. - If git metadata is unavailable, it falls back to the seeded default in
version.py, currently1.96.0.
The Docker build and GitHub Actions publish workflow pass the resolved version into the container image automatically, so the running bot keeps the same version string even without a .git directory in the container.
If you want to change the text before the version suffix, set TIKBOT_STATUS_TEXT in .env. For example: TIKBOT_STATUS_TEXT=tik-tok channels.
The provided Dockerfile builds the bot on a slim Python image and also installs ffmpeg and the Deno JavaScript runtime.
Note: The container image includes Deno so the bot can optionally use Deno to run yt-dlp remote components.
This repo includes a GitHub Actions workflow to build and push the Docker image to Docker Hub on pushes to master, and on version tags like v1.2.3.
Setup in GitHub:
- Create Docker Hub credentials (use a personal access token).
- Add repo secrets:
DOCKERHUB_USERNAMEDOCKERHUB_TOKEN
- Add a repo variable:
DOCKERHUB_REPOSITORY(example:yourname/tikbot)
By default the bot will post where a link is from 'youtube', 'tiktok', 'instagram', 'reddit', 'redd.it', or if a 🤖 emoji is included in the message.
If you'd like to modify this list, you can set the TIKBOT_AUTO_DOMAINS environment variable in .env. Supply a space separated list.
For example to add Twitter to the automatic set of posts
TIKBOT_AUTO_DOMAINS=youtube tiktok instagram reddit redd.it twitter
The bot is capable of detecing reposts if supplied with postgres database credentials.
Set DB_NAME, DB_HOST, DB_USER, DB_PASS, TIKBOT_TIMEZONE`` in .env```. Timezone is the IANA name
Only a single table is used, see maintenance/create_posts_table.sql for a create script for the table.
For domains with a mix of supported and unsupported content (e.g. Twitter), you may want the bot to try to post items, but only send a message if it actually gets a video to post.
Set the domains you want this behaviour on as a space separated list in the TIKBOT_SILENT_DOMAINS environment variable.
For example to only post Twitter videos and have the bot not show anything for text tweets:
TIKBOT_SILENT_DOMAINS=twitter
Note that this will also suppress any other messages (aside from repost detection) for these domains as well. Errors will still be logged to the console however.
Not recommended to be available as a public bot due to the bandwidth and processing requirements of downloading and encoding videos.