Unnoficial TikTok library for chatbot making. Use at your own risk.
Project description
PyUTAL For Python
PyUTAL (Unofficial TikTok Automation Library) is a Python library designed to develop chatbots or automate TikTok's direct messages (not TikTok Live) using Selenium.
Installation
To install PyUTAL, it is recommended to first create a virtual environment to isolate project dependencies. Follow these steps:
- Install
virtualenvif you don’t have it yet:pip install virtualenv
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
- Windows:
venv\Scripts\activate
- Linux/macOS:
source venv/bin/activate
- Windows:
- Install
utalinside the virtual environment:pip install utal
Quick Start
Here is a guide to setting up a simple project using utal.
- Initialize the
webdriverwith Selenium without headless mode the first time to log in manually. - Then, use the following code:
import os
from utal.core import PyUTAL
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
def startup_selenium():
USERDATADIR = os.path.abspath("path/to/user/data/directory")
DRIVERPATH = "path/to/webdriver"
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
options.add_argument("--headless") # Run without headless mode the first time
options.add_argument(rf"user-data-dir={USERDATADIR}")
driver = webdriver.Chrome(service=Service(DRIVERPATH), options=options)
return driver # Important to return the driver
def main(driver, app: PyUTAL):
driver.get("https://tiktok.com/messages")
while True: # Important to use loops
message = app.client.listen() # Retrieves all messages
if message:
print(message)
if message and message == "hello":
user_nickname = app.conversation.get_user_nickname()
app.conversation.send(f"Hi, {user_nickname} 🌟")
if __name__ == "__main__":
driver = startup_selenium()
app = PyUTAL(driver)
main(driver, app)
- Console output (if the user sends "hello")
hello
- Bot response (if the nickname is "thiago")
Hi, thiago 🌟
Important Notes
- Headless mode must be disabled the first time to allow manual login and save session data.
- A loop is required for the bot to continuously listen for incoming messages.
- The bot does NOT have a prefix configured and does not filter its own messages in this example. See the documentation to learn how to implement that.
Next Steps
These are just recommendations.
- Implement a system of custom prefixes for each user.
- Develop a
command handlerto structure the bot’s commands better. - Use a database to store bot or user information.
- Take inspiration from Discord bot development structures.
- Experiment and test the different functions of the library.
- See the Selenium documentation to scale the project.
Disclaimers
By using PyUTAL from the utal library, you agree to the following terms. If you do not agree, we recommend you stop using PyUTAL:
- This library was created for educational purposes and must be used at your own risk. The creator and/or contributors are not responsible for any misuse of the tool.
- This is not an official TikTok tool.
- This tool does not connect to TikTok's official APIs; it only performs automation through
scraping.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file utal-0.3.0.tar.gz.
File metadata
- Download URL: utal-0.3.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b615e1d2807d0090eb09c24f108af87031a75ef8d04b6f333227cc903c7eae12
|
|
| MD5 |
b779e2d2de83438280faf4100c40b8e3
|
|
| BLAKE2b-256 |
63fd303f6fbbaabc6cbe129359981b96cdc22073d99baeb791c79dc1f544722d
|
Provenance
The following attestation bundles were made for utal-0.3.0.tar.gz:
Publisher:
python-publish.yml on thiagostilo2121/utal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
utal-0.3.0.tar.gz -
Subject digest:
b615e1d2807d0090eb09c24f108af87031a75ef8d04b6f333227cc903c7eae12 - Sigstore transparency entry: 179856862
- Sigstore integration time:
-
Permalink:
thiagostilo2121/utal@28a888db0ce8e6ae6836f938b3c6987296189620 -
Branch / Tag:
refs/tags/V0.3.0 - Owner: https://github.com/thiagostilo2121
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@28a888db0ce8e6ae6836f938b3c6987296189620 -
Trigger Event:
release
-
Statement type:
File details
Details for the file utal-0.3.0-py3-none-any.whl.
File metadata
- Download URL: utal-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2791a2bebca076cced3bb8be00f7ce18b7d85b4a0c73833ac9f931f16f31448
|
|
| MD5 |
45db3422678c522dd5e24f5b66e71413
|
|
| BLAKE2b-256 |
08f5a915134bb4448f60e239680debd3f419129264a1bec09c8206d8db6a7ade
|
Provenance
The following attestation bundles were made for utal-0.3.0-py3-none-any.whl:
Publisher:
python-publish.yml on thiagostilo2121/utal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
utal-0.3.0-py3-none-any.whl -
Subject digest:
a2791a2bebca076cced3bb8be00f7ce18b7d85b4a0c73833ac9f931f16f31448 - Sigstore transparency entry: 179856864
- Sigstore integration time:
-
Permalink:
thiagostilo2121/utal@28a888db0ce8e6ae6836f938b3c6987296189620 -
Branch / Tag:
refs/tags/V0.3.0 - Owner: https://github.com/thiagostilo2121
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@28a888db0ce8e6ae6836f938b3c6987296189620 -
Trigger Event:
release
-
Statement type: