|
10 months ago | |
---|---|---|
config | 10 months ago | |
data | 10 months ago | |
lib | 10 months ago | |
.gitignore | 10 months ago | |
Dockerfile | 10 months ago | |
Pipfile | 10 months ago | |
README.md | 10 months ago | |
docker-compose.yml | 10 months ago | |
rename_media_files.py | 10 months ago | |
twitter_bot.py | 10 months ago |
README.md
Twitter Bot @basicbishoujo@mastodon.art
I made this for @basicbishoujo@mastodon.art to post things every day for them.
Requirements
You will need Python3 and the pipenv
package. Optionally, you can install docker
and docker-compose
and follow the docker instructions.
Installation
Python Native
In order to install the necessary python
packages needed for the bot, run a pipenv install
as usual.
pipenv install
Docker / docker-compose
You should be able to build the container with a single docker-compose
command:
docker-compose up --build --no-start
Additionally, you may need to set the permissions for the data/
directory to write for guest in order to allow the container to write to a .tmp_counter
file used to keep track of which file to upload.
sudo chmod 777 -R data/
NOTE: Be very careful with doing this, it may be safer to simply sudo chown 991:991 -R data/
instead in order to keep an entire directory from being able to be written to by any system user. However, this comes with the downside of needing to sudo cp
every file you want to have uploaded in data/
Configuration
In order to run the bot, you will need to copy the template_config.json
to config.json
and fill the required fields:
- *api_key
- *api_key_secret
- *acccess_token
- *acccess_token_secret
- valid_file_formats
- timezone
- post_time
* These can be found by creating an app at https://developer.twitter.com.
valid_file_formats
is used to help the bot filter out what kinds of file formats you are attempting to upload. I don't recommend changing this much, as there are only so many file formats officially supported by Twitter in the first place.
timezone
should follow your preferred timzone for when you want the bot to post each day, and post_time
should be in 24-hour time format an integer representing the time each day you want to post, for example: 1530
would have the bot post at 3:30 PM.
Usage
Python
You should be able to start the bot by issuing the following command:
pipenv run python twitter_bot.py
Docker / docker-compose
You should be able to start the container by issuing the following command:
docker-compose start
Functionality
This bot will take whatever is in the data/
directory that is a valid media file format and upload one media file to Twitter on the authenticated user account each day at a certain time, iterating through each item.
Once the bot finishes iterating through the available files, it will loop back to the beginning.
Contact
If you have any questions or need help setting up (or want to report a bug), you can contact me in the following places most effectively:
Discord: shadow8t4#8276
Telegram: @shadow8t4
Matrix: @shadow8t4:matrix.werefox.dev